From 948e03dcbf4a9f0175455e98a83ac3319c47a03b Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 18 Aug 2013 20:58:52 +0000 Subject: [PATCH 01/24] Copy mission parameters properly so that D1 missions load Copying unrelated structures with an undocumented assumption that one is a prefix of the other is dangerous and broken. Remove it and copy the relevant fields explicitly. --- d2x-rebirth/main/mission.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/d2x-rebirth/main/mission.c b/d2x-rebirth/main/mission.c index 8110c9633..fbd4ec674 100644 --- a/d2x-rebirth/main/mission.c +++ b/d2x-rebirth/main/mission.c @@ -730,7 +730,10 @@ int load_mission(mle *mission) free_mission(); MALLOC(Current_mission, Mission, 1); if (!Current_mission) return 0; - *(mle *) Current_mission = *mission; + Current_mission->builtin_hogsize = mission->builtin_hogsize; + strcpy(Current_mission->mission_name, mission->mission_name); + Current_mission->descent_version = mission->descent_version; + Current_mission->anarchy_only_flag = mission->anarchy_only_flag; Current_mission->path = d_strdup(mission->path); Current_mission->filename = Current_mission->path + (mission->filename - mission->path); Current_mission->n_secret_levels = 0; From b3e2c99b174e1498eb5dac6374229aaef59e2851 Mon Sep 17 00:00:00 2001 From: Kp Date: Tue, 20 Aug 2013 02:58:15 +0000 Subject: [PATCH 02/24] Use MALLOC for ogl_init_pixel_buffers --- similar/arch/ogl/ogl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/similar/arch/ogl/ogl.c b/similar/arch/ogl/ogl.c index 48ba9d7f0..41045fd5e 100644 --- a/similar/arch/ogl/ogl.c +++ b/similar/arch/ogl/ogl.c @@ -1268,11 +1268,11 @@ void ogl_init_pixel_buffers(int w, int h) if (pixels) d_free(pixels); - pixels = d_malloc(w*h*4); + MALLOC(pixels, GLubyte, w*h*4); if (texbuf) d_free(texbuf); - texbuf = d_malloc(max(w, 1024)*max(h, 256)*4); // must also fit big font texture + MALLOC(texbuf, GLubyte, max(w, 1024u)*max(h, 256u)*4); // must also fit big font texture if ((pixels == NULL) || (texbuf == NULL)) Error("Not enough memory for current resolution"); From 9c0be7cdfac8340049ff5ee83aaa884b61db80c3 Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 16 Aug 2013 02:19:11 +0000 Subject: [PATCH 03/24] Remove unused kconfig globals --- d2x-rebirth/main/kconfig.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/d2x-rebirth/main/kconfig.c b/d2x-rebirth/main/kconfig.c index 93abf9540..b01c3d19d 100644 --- a/d2x-rebirth/main/kconfig.c +++ b/d2x-rebirth/main/kconfig.c @@ -57,15 +57,6 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "ogl_init.h" #endif -vms_vector ExtForceVec; -vms_matrix ExtApplyForceMatrix; - -int ExtJoltInfo[3]={0,0,0}; -int ExtXVibrateInfo[2]={0,0}; -int ExtYVibrateInfo[2]={0,0}; -ubyte ExtXVibrateClear=0; -ubyte ExtYVibrateClear=0; - #define TABLE_CREATION 1 // Array used to 'blink' the cursor while waiting for a keypress. @@ -1159,11 +1150,6 @@ void kconfig(int n, const char * title) } } -fix Last_angles_p = 0; -fix Last_angles_b = 0; -fix Last_angles_h = 0; -ubyte Last_angles_read = 0; - void kconfig_read_controls(d_event *event, int automap_flag) { int i = 0, j = 0, speed_factor = cheats.turbo?2:1; From 00381b265258ef81afdce7deebbc200683c3ef0a Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 16 Aug 2013 02:43:25 +0000 Subject: [PATCH 04/24] Abstract out weapon names --- d1x-rebirth/main/kconfig.c | 74 ++++++++++++++++++++++---------------- d2x-rebirth/main/kconfig.c | 73 +++++++++++++++++++++---------------- 2 files changed, 87 insertions(+), 60 deletions(-) diff --git a/d1x-rebirth/main/kconfig.c b/d1x-rebirth/main/kconfig.c index 3ab82f56f..9d1c418f3 100644 --- a/d1x-rebirth/main/kconfig.c +++ b/d1x-rebirth/main/kconfig.c @@ -261,37 +261,51 @@ kc_item kc_mouse[NUM_MOUSE_CONTROLS] = { { 27, 25,102, 85, 26, 25, 28, 11, 12,"Cycle Primary", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.cycle_primary_count }, { 28, 25,110, 85, 26, 27, 14, 12, 13,"Cycle Secondary", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.cycle_secondary_count }, }; + +#define D2X_EXTENDED_WEAPON_STRING(X) + +#define WEAPON_STRING_LASER D2X_EXTENDED_WEAPON_STRING("(SUPER)") "LASER CANNON" +#define WEAPON_STRING_VULCAN "VULCAN" D2X_EXTENDED_WEAPON_STRING("/GAUSS") " CANNON" +#define WEAPON_STRING_SPREADFIRE "SPREADFIRE" D2X_EXTENDED_WEAPON_STRING("/HELIX") " CANNON" +#define WEAPON_STRING_PLASMA "PLASMA" D2X_EXTENDED_WEAPON_STRING("/PHOENIX") " CANNON" +#define WEAPON_STRING_FUSION "FUSION" D2X_EXTENDED_WEAPON_STRING("/OMEGA") " CANNON" +#define WEAPON_STRING_CONCUSSION "CONCUSSION" D2X_EXTENDED_WEAPON_STRING("/FLASH") " MISSILE" +#define WEAPON_STRING_HOMING "HOMING" D2X_EXTENDED_WEAPON_STRING("/GUIDED") " MISSILE" +#define WEAPON_STRING_PROXIMITY "PROXIMITY BOMB" D2X_EXTENDED_WEAPON_STRING("/SMART MINE") +#define WEAPON_STRING_SMART "SMART" D2X_EXTENDED_WEAPON_STRING("/MERCURY") " MISSILE" +#define WEAPON_STRING_MEGA "MEGA" D2X_EXTENDED_WEAPON_STRING("/EARTHSHAKER") " MISSILE" + kc_item kc_d1x[NUM_D1X_CONTROLS] = { - { 0, 15, 69,142, 26, 29, 3, 29, 1,"LASER CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 1, 15, 69,200, 26, 27, 4, 0, 2,"LASER CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 2, 15, 69,258, 26, 28, 5, 1, 3,"LASER CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 3, 15, 77,142, 26, 0, 6, 2, 4,"VULCAN CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 4, 15, 77,200, 26, 1, 7, 3, 5,"VULCAN CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 5, 15, 77,258, 26, 2, 8, 4, 6,"VULCAN CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 6, 15, 85,142, 26, 3, 9, 5, 7,"SPREADFIRE CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 7, 15, 85,200, 26, 4, 10, 6, 8,"SPREADFIRE CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 8, 15, 85,258, 26, 5, 11, 7, 9,"SPREADFIRE CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 9, 15, 93,142, 26, 6, 12, 8, 10,"PLASMA CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 10, 15, 93,200, 26, 7, 13, 9, 11,"PLASMA CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 11, 15, 93,258, 26, 8, 14, 10, 12,"PLASMA CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 12, 15,101,142, 26, 9, 15, 11, 13,"FUSION CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 13, 15,101,200, 26, 10, 16, 12, 14,"FUSION CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 14, 15,101,258, 26, 11, 17, 13, 15,"FUSION CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 15, 15,109,142, 26, 12, 18, 14, 16,"CONCUSSION MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 16, 15,109,200, 26, 13, 19, 15, 17,"CONCUSSION MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 17, 15,109,258, 26, 14, 20, 16, 18,"CONCUSSION MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 18, 15,117,142, 26, 15, 21, 17, 19,"HOMING MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 19, 15,117,200, 26, 16, 22, 18, 20,"HOMING MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 20, 15,117,258, 26, 17, 23, 19, 21,"HOMING MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 21, 15,125,142, 26, 18, 24, 20, 22,"PROXIMITY BOMB", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 22, 15,125,200, 26, 19, 25, 21, 23,"PROXIMITY BOMB", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 23, 15,125,258, 26, 20, 26, 22, 24,"PROXIMITY BOMB", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 24, 15,133,142, 26, 21, 27, 23, 25,"SMART MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 25, 15,133,200, 26, 22, 28, 24, 26,"SMART MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 26, 15,133,258, 26, 23, 29, 25, 27,"SMART MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 27, 15,141,142, 26, 24, 1, 26, 28,"MEGA MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 28, 15,141,200, 26, 25, 2, 27, 29,"MEGA MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 29, 15,141,258, 26, 26, 0, 28, 0,"MEGA MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 0, 15, 69,142, 26, 29, 3, 29, 1,WEAPON_STRING_LASER, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 1, 15, 69,200, 26, 27, 4, 0, 2,WEAPON_STRING_LASER, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 2, 15, 69,258, 26, 28, 5, 1, 3,WEAPON_STRING_LASER, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 3, 15, 77,142, 26, 0, 6, 2, 4,WEAPON_STRING_VULCAN, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 4, 15, 77,200, 26, 1, 7, 3, 5,WEAPON_STRING_VULCAN, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 5, 15, 77,258, 26, 2, 8, 4, 6,WEAPON_STRING_VULCAN, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 6, 15, 85,142, 26, 3, 9, 5, 7,WEAPON_STRING_SPREADFIRE, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 7, 15, 85,200, 26, 4, 10, 6, 8,WEAPON_STRING_SPREADFIRE, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 8, 15, 85,258, 26, 5, 11, 7, 9,WEAPON_STRING_SPREADFIRE, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 9, 15, 93,142, 26, 6, 12, 8, 10,WEAPON_STRING_PLASMA, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 10, 15, 93,200, 26, 7, 13, 9, 11,WEAPON_STRING_PLASMA, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 11, 15, 93,258, 26, 8, 14, 10, 12,WEAPON_STRING_PLASMA, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 12, 15,101,142, 26, 9, 15, 11, 13,WEAPON_STRING_FUSION, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 13, 15,101,200, 26, 10, 16, 12, 14,WEAPON_STRING_FUSION, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 14, 15,101,258, 26, 11, 17, 13, 15,WEAPON_STRING_FUSION, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 15, 15,109,142, 26, 12, 18, 14, 16,WEAPON_STRING_CONCUSSION, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 16, 15,109,200, 26, 13, 19, 15, 17,WEAPON_STRING_CONCUSSION, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 17, 15,109,258, 26, 14, 20, 16, 18,WEAPON_STRING_CONCUSSION, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 18, 15,117,142, 26, 15, 21, 17, 19,WEAPON_STRING_HOMING, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 19, 15,117,200, 26, 16, 22, 18, 20,WEAPON_STRING_HOMING, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 20, 15,117,258, 26, 17, 23, 19, 21,WEAPON_STRING_HOMING, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 21, 15,125,142, 26, 18, 24, 20, 22,WEAPON_STRING_PROXIMITY, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 22, 15,125,200, 26, 19, 25, 21, 23,WEAPON_STRING_PROXIMITY, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 23, 15,125,258, 26, 20, 26, 22, 24,WEAPON_STRING_PROXIMITY, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 24, 15,133,142, 26, 21, 27, 23, 25,WEAPON_STRING_SMART, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 25, 15,133,200, 26, 22, 28, 24, 26,WEAPON_STRING_SMART, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 26, 15,133,258, 26, 23, 29, 25, 27,WEAPON_STRING_SMART, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 27, 15,141,142, 26, 24, 1, 26, 28,WEAPON_STRING_MEGA, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 28, 15,141,200, 26, 25, 2, 27, 29,WEAPON_STRING_MEGA, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 29, 15,141,258, 26, 26, 0, 28, 0,WEAPON_STRING_MEGA, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, }; void kc_drawitem( kc_item *item, int is_current ); diff --git a/d2x-rebirth/main/kconfig.c b/d2x-rebirth/main/kconfig.c index b01c3d19d..6719f5a72 100644 --- a/d2x-rebirth/main/kconfig.c +++ b/d2x-rebirth/main/kconfig.c @@ -281,37 +281,50 @@ kc_item kc_mouse[NUM_MOUSE_CONTROLS] = { { 29, 25,118, 85, 26, 28, 14, 28, 13,"Cycle Secondary", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.cycle_secondary_count }, }; +#define D2X_EXTENDED_WEAPON_STRING(X) X + +#define WEAPON_STRING_LASER D2X_EXTENDED_WEAPON_STRING("(SUPER)") "LASER CANNON" +#define WEAPON_STRING_VULCAN "VULCAN" D2X_EXTENDED_WEAPON_STRING("/GAUSS") " CANNON" +#define WEAPON_STRING_SPREADFIRE "SPREADFIRE" D2X_EXTENDED_WEAPON_STRING("/HELIX") " CANNON" +#define WEAPON_STRING_PLASMA "PLASMA" D2X_EXTENDED_WEAPON_STRING("/PHOENIX") " CANNON" +#define WEAPON_STRING_FUSION "FUSION" D2X_EXTENDED_WEAPON_STRING("/OMEGA") " CANNON" +#define WEAPON_STRING_CONCUSSION "CONCUSSION" D2X_EXTENDED_WEAPON_STRING("/FLASH") " MISSILE" +#define WEAPON_STRING_HOMING "HOMING" D2X_EXTENDED_WEAPON_STRING("/GUIDED") " MISSILE" +#define WEAPON_STRING_PROXIMITY "PROXIMITY BOMB" D2X_EXTENDED_WEAPON_STRING("/SMART MINE") +#define WEAPON_STRING_SMART "SMART" D2X_EXTENDED_WEAPON_STRING("/MERCURY") " MISSILE" +#define WEAPON_STRING_MEGA "MEGA" D2X_EXTENDED_WEAPON_STRING("/EARTHSHAKER") " MISSILE" + kc_item kc_d2x[NUM_D2X_CONTROLS] = { - { 0, 15, 69,142, 26, 29, 3, 29, 1,"(SUPER)LASER CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 1, 15, 69,200, 26, 27, 4, 0, 2,"(SUPER)LASER CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 2, 15, 69,258, 26, 28, 5, 1, 3,"(SUPER)LASER CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 3, 15, 77,142, 26, 0, 6, 2, 4,"VULCAN/GAUSS CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 4, 15, 77,200, 26, 1, 7, 3, 5,"VULCAN/GAUSS CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 5, 15, 77,258, 26, 2, 8, 4, 6,"VULCAN/GAUSS CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 6, 15, 85,142, 26, 3, 9, 5, 7,"SPREADFIRE/HELIX CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 7, 15, 85,200, 26, 4, 10, 6, 8,"SPREADFIRE/HELIX CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 8, 15, 85,258, 26, 5, 11, 7, 9,"SPREADFIRE/HELIX CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 9, 15, 93,142, 26, 6, 12, 8, 10,"PLASMA/PHOENIX CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 10, 15, 93,200, 26, 7, 13, 9, 11,"PLASMA/PHOENIX CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 11, 15, 93,258, 26, 8, 14, 10, 12,"PLASMA/PHOENIX CANNON", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 12, 15,101,142, 26, 9, 15, 11, 13,"FUSION/OMEGA CANNON", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 13, 15,101,200, 26, 10, 16, 12, 14,"FUSION/OMEGA CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 14, 15,101,258, 26, 11, 17, 13, 15,"FUSION/OMEGA CANNON", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 15, 15,109,142, 26, 12, 18, 14, 16,"CONCUSSION/FLASH MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 16, 15,109,200, 26, 13, 19, 15, 17,"CONCUSSION/FLASH MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 17, 15,109,258, 26, 14, 20, 16, 18,"CONCUSSION/FLASH MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 18, 15,117,142, 26, 15, 21, 17, 19,"HOMING/GUIDED MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 19, 15,117,200, 26, 16, 22, 18, 20,"HOMING/GUIDED MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 20, 15,117,258, 26, 17, 23, 19, 21,"HOMING/GUIDED MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 21, 15,125,142, 26, 18, 24, 20, 22,"PROXIMITY BOMB/SMART MINE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 22, 15,125,200, 26, 19, 25, 21, 23,"PROXIMITY BOMB/SMART MINE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 23, 15,125,258, 26, 20, 26, 22, 24,"PROXIMITY BOMB/SMART MINE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 24, 15,133,142, 26, 21, 27, 23, 25,"SMART/MERCURY MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 25, 15,133,200, 26, 22, 28, 24, 26,"SMART/MERCURY MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 26, 15,133,258, 26, 23, 29, 25, 27,"SMART/MERCURY MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 27, 15,141,142, 26, 24, 1, 26, 28,"MEGA/EARTHSHAKER MISSILE", BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, - { 28, 15,141,200, 26, 25, 2, 27, 29,"MEGA/EARTHSHAKER MISSILE", BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, - { 29, 15,141,258, 26, 26, 0, 28, 0,"MEGA/EARTHSHAKER MISSILE", BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 0, 15, 69,142, 26, 29, 3, 29, 1,WEAPON_STRING_LASER, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 1, 15, 69,200, 26, 27, 4, 0, 2,WEAPON_STRING_LASER, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 2, 15, 69,258, 26, 28, 5, 1, 3,WEAPON_STRING_LASER, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 3, 15, 77,142, 26, 0, 6, 2, 4,WEAPON_STRING_VULCAN, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 4, 15, 77,200, 26, 1, 7, 3, 5,WEAPON_STRING_VULCAN, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 5, 15, 77,258, 26, 2, 8, 4, 6,WEAPON_STRING_VULCAN, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 6, 15, 85,142, 26, 3, 9, 5, 7,WEAPON_STRING_SPREADFIRE, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 7, 15, 85,200, 26, 4, 10, 6, 8,WEAPON_STRING_SPREADFIRE, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 8, 15, 85,258, 26, 5, 11, 7, 9,WEAPON_STRING_SPREADFIRE, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 9, 15, 93,142, 26, 6, 12, 8, 10,WEAPON_STRING_PLASMA, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 10, 15, 93,200, 26, 7, 13, 9, 11,WEAPON_STRING_PLASMA, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 11, 15, 93,258, 26, 8, 14, 10, 12,WEAPON_STRING_PLASMA, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 12, 15,101,142, 26, 9, 15, 11, 13,WEAPON_STRING_FUSION, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 13, 15,101,200, 26, 10, 16, 12, 14,WEAPON_STRING_FUSION, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 14, 15,101,258, 26, 11, 17, 13, 15,WEAPON_STRING_FUSION, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 15, 15,109,142, 26, 12, 18, 14, 16,WEAPON_STRING_CONCUSSION, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 16, 15,109,200, 26, 13, 19, 15, 17,WEAPON_STRING_CONCUSSION, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 17, 15,109,258, 26, 14, 20, 16, 18,WEAPON_STRING_CONCUSSION, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 18, 15,117,142, 26, 15, 21, 17, 19,WEAPON_STRING_HOMING, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 19, 15,117,200, 26, 16, 22, 18, 20,WEAPON_STRING_HOMING, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 20, 15,117,258, 26, 17, 23, 19, 21,WEAPON_STRING_HOMING, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 21, 15,125,142, 26, 18, 24, 20, 22,WEAPON_STRING_PROXIMITY, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 22, 15,125,200, 26, 19, 25, 21, 23,WEAPON_STRING_PROXIMITY, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 23, 15,125,258, 26, 20, 26, 22, 24,WEAPON_STRING_PROXIMITY, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 24, 15,133,142, 26, 21, 27, 23, 25,WEAPON_STRING_SMART, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 25, 15,133,200, 26, 22, 28, 24, 26,WEAPON_STRING_SMART, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 26, 15,133,258, 26, 23, 29, 25, 27,WEAPON_STRING_SMART, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 27, 15,141,142, 26, 24, 1, 26, 28,WEAPON_STRING_MEGA, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, + { 28, 15,141,200, 26, 25, 2, 27, 29,WEAPON_STRING_MEGA, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, + { 29, 15,141,258, 26, 26, 0, 28, 0,WEAPON_STRING_MEGA, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, }; void kc_drawitem( kc_item *item, int is_current ); From 045082f3eb49997906873b9ac0dfa2e29874fa66 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 17 Aug 2013 16:09:44 +0000 Subject: [PATCH 05/24] Use static const fix Flash_rate --- d1x-rebirth/main/render.c | 4 ++-- d2x-rebirth/main/render.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/d1x-rebirth/main/render.c b/d1x-rebirth/main/render.c index 068dea5d4..9117c89ae 100644 --- a/d1x-rebirth/main/render.c +++ b/d1x-rebirth/main/render.c @@ -148,7 +148,7 @@ fix flash_scale; #define FLASH_CYCLE_RATE f1_0 -fix flash_rate = FLASH_CYCLE_RATE; +static const fix Flash_rate = FLASH_CYCLE_RATE; //cycle the flashing light for when mine destroyed void flash_frame() @@ -165,7 +165,7 @@ void flash_frame() return; // flash_ang += fixmul(FLASH_CYCLE_RATE,FrameTime); - flash_ang += fixmul(flash_rate,FrameTime); + flash_ang += fixmul(Flash_rate,FrameTime); fix_fastsincos(flash_ang,&flash_scale,NULL); diff --git a/d2x-rebirth/main/render.c b/d2x-rebirth/main/render.c index e6cad9ab8..cd55d080c 100644 --- a/d2x-rebirth/main/render.c +++ b/d2x-rebirth/main/render.c @@ -153,7 +153,7 @@ fix flash_scale; #define FLASH_CYCLE_RATE f1_0 -fix Flash_rate = FLASH_CYCLE_RATE; +static const fix Flash_rate = FLASH_CYCLE_RATE; //cycle the flashing light for when mine destroyed void flash_frame() From 8ef83715639c804bb232626b44c519f8a0084ab8 Mon Sep 17 00:00:00 2001 From: Kp Date: Tue, 13 Aug 2013 23:11:49 +0000 Subject: [PATCH 06/24] Use unsigned screen width/height --- common/include/gr.h | 4 ++-- similar/arch/ogl/ogl.c | 16 +++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/common/include/gr.h b/common/include/gr.h index 3df31f643..5db4ff259 100644 --- a/common/include/gr.h +++ b/common/include/gr.h @@ -146,7 +146,7 @@ typedef struct _grs_canvas { typedef struct _grs_screen { // This is a video screen grs_canvas sc_canvas; // Represents the entire screen u_int32_t sc_mode; // Video mode number - short sc_w, sc_h; // Actual Width and Height + unsigned short sc_w, sc_h; // Actual Width and Height fix sc_aspect; //aspect ratio (w/h) for this screen } grs_screen; @@ -400,7 +400,7 @@ int gr_check_fullscreen(void); */ int gr_toggle_fullscreen(void); void ogl_do_palfx(void); -void ogl_init_pixel_buffers(int w, int h); +void ogl_init_pixel_buffers(unsigned w, unsigned h); void ogl_close_pixel_buffers(void); #ifdef __cplusplus diff --git a/similar/arch/ogl/ogl.c b/similar/arch/ogl/ogl.c index 41045fd5e..92cb4f8db 100644 --- a/similar/arch/ogl/ogl.c +++ b/similar/arch/ogl/ogl.c @@ -101,7 +101,7 @@ int ogl_texture_list_cur; #define GL_TEXTURE0_ARB 0x84C0 extern GLubyte *pixels; extern GLubyte *texbuf; -void ogl_filltexbuf(unsigned char *data, GLubyte *texp, int truewidth, int width, int height, int dxo, int dyo, int twidth, int theight, int type, int bm_flags, int data_format); +void ogl_filltexbuf(unsigned char *data, GLubyte *texp, unsigned truewidth, unsigned width, unsigned height, int dxo, int dyo, unsigned twidth, unsigned theight, int type, int bm_flags, int data_format); void ogl_loadbmtexture(grs_bitmap *bm); int ogl_loadtexture(unsigned char *data, int dxo, int dyo, ogl_texture *tex, int bm_flags, int data_format, int texfilt); void ogl_freetexture(ogl_texture *gltexture); @@ -1261,7 +1261,7 @@ int pow2ize(int x){ GLubyte *texbuf = NULL; // Allocate the pixel buffers 'pixels' and 'texbuf' based on current screen resolution -void ogl_init_pixel_buffers(int w, int h) +void ogl_init_pixel_buffers(unsigned w, unsigned h) { w = pow2ize(w); // convert to OpenGL texture size h = pow2ize(h); @@ -1284,19 +1284,17 @@ void ogl_close_pixel_buffers(void) d_free(texbuf); } -void ogl_filltexbuf(unsigned char *data, GLubyte *texp, int truewidth, int width, int height, int dxo, int dyo, int twidth, int theight, int type, int bm_flags, int data_format) +void ogl_filltexbuf(unsigned char *data, GLubyte *texp, unsigned truewidth, unsigned width, unsigned height, int dxo, int dyo, unsigned twidth, unsigned theight, int type, int bm_flags, int data_format) { - int x,y,c,i; - if ((width > max(grd_curscreen->sc_w, 1024)) || (height > max(grd_curscreen->sc_h, 256))) Error("Texture is too big: %ix%i", width, height); - i=0; - for (y=0;y Date: Wed, 14 Aug 2013 21:12:51 +0000 Subject: [PATCH 07/24] Mark various OGL functions static --- common/include/internal.h | 5 +-- common/include/ogl_init.h | 3 -- similar/arch/ogl/gr.cpp | 1 - similar/arch/ogl/ogl.c | 77 ++++++++++++++++++--------------------- similar/main/gamerend.c | 1 - 5 files changed, 37 insertions(+), 50 deletions(-) diff --git a/common/include/internal.h b/common/include/internal.h index 07c4a1829..c5be0a1da 100644 --- a/common/include/internal.h +++ b/common/include/internal.h @@ -12,8 +12,6 @@ extern "C" { /* I assume this ought to be >= MAX_BITMAP_FILES in piggy.h? */ #define OGL_TEXTURE_LIST_SIZE 20000 -extern ogl_texture ogl_texture_list[OGL_TEXTURE_LIST_SIZE]; - void ogl_init_texture_list_internal(void); void ogl_smash_texture_list_internal(void); void ogl_vivify_texture_list_internal(void); @@ -21,6 +19,7 @@ void ogl_vivify_texture_list_internal(void); extern int ogl_brightness_ok; extern int ogl_brightness_r, ogl_brightness_g, ogl_brightness_b; extern int ogl_fullscreen; +extern int r_upixelc; extern int GL_TEXTURE_2D_enabled; #define OGL_ENABLE2(a,f) {if (a ## _enabled!=1) {f;a ## _enabled=1;}} @@ -51,8 +50,6 @@ static inline void OGL_VIEWPORT(const unsigned x, const unsigned y, const unsign //platform specific funcs extern void ogl_swap_buffers_internal(void); -extern unsigned char *ogl_pal; - //whee //#define PAL2Tr(c) ((gr_palette[c*3]+gr_palette_gamma)/63.0) //#define PAL2Tg(c) ((gr_palette[c*3+1]+gr_palette_gamma)/63.0) diff --git a/common/include/ogl_init.h b/common/include/ogl_init.h index cd8c4f09a..bb53bbc35 100644 --- a/common/include/ogl_init.h +++ b/common/include/ogl_init.h @@ -71,9 +71,6 @@ typedef struct _ogl_texture { extern ogl_texture* ogl_get_free_texture(); void ogl_init_texture(ogl_texture* t, int w, int h, int flags); -extern int ogl_rgba_internalformat; -extern int ogl_rgb_internalformat; - void ogl_init_shared_palette(void); extern int gl_initialized; diff --git a/similar/arch/ogl/gr.cpp b/similar/arch/ogl/gr.cpp index b2f1e56af..db1845733 100644 --- a/similar/arch/ogl/gr.cpp +++ b/similar/arch/ogl/gr.cpp @@ -821,7 +821,6 @@ void gr_close() #endif } -extern int r_upixelc; void ogl_upixelc(int x, int y, int c) { GLfloat vertex_array[] = { (x+grd_curcanv->cv_bitmap.bm_x)/(float)last_width, 1.0-(y+grd_curcanv->cv_bitmap.bm_y)/(float)last_height }; diff --git a/similar/arch/ogl/ogl.c b/similar/arch/ogl/ogl.c index 92cb4f8db..059cf712c 100644 --- a/similar/arch/ogl/ogl.c +++ b/similar/arch/ogl/ogl.c @@ -69,46 +69,50 @@ #define sinf(a) sin(a) #endif -unsigned char *ogl_pal=gr_palette; +static GLubyte *pixels = NULL; +static GLubyte *texbuf = NULL; + +static unsigned char *ogl_pal=gr_palette; unsigned last_width=~0u,last_height=~0u; int GL_TEXTURE_2D_enabled=-1; -int GL_texclamp_enabled=-1; GLfloat ogl_maxanisotropy = 0; -int r_texcount = 0, r_cachedtexcount = 0; +static int r_texcount = 0, r_cachedtexcount = 0; #ifdef OGLES -int ogl_rgba_internalformat = GL_RGBA; -int ogl_rgb_internalformat = GL_RGB; +static int ogl_rgba_internalformat = GL_RGBA; +static int ogl_rgb_internalformat = GL_RGB; #else -int ogl_rgba_internalformat = GL_RGBA8; -int ogl_rgb_internalformat = GL_RGB8; +static int ogl_rgba_internalformat = GL_RGBA8; +static int ogl_rgb_internalformat = GL_RGB8; #endif -GLfloat *sphere_va = NULL, *circle_va = NULL, *disk_va = NULL; -GLfloat *secondary_lva[3]={NULL, NULL, NULL}; -int r_polyc,r_tpolyc,r_bitmapc,r_ubitbltc,r_upixelc; +static GLfloat *sphere_va = NULL, *circle_va = NULL, *disk_va = NULL; +static GLfloat *secondary_lva[3]={NULL, NULL, NULL}; +static int r_polyc,r_tpolyc,r_bitmapc,r_ubitbltc; +int r_upixelc; extern int linedotscale; #define f2glf(x) (f2fl(x)) #define OGL_BINDTEXTURE(a) glBindTexture(GL_TEXTURE_2D, a); -ogl_texture ogl_texture_list[OGL_TEXTURE_LIST_SIZE]; -int ogl_texture_list_cur; +static ogl_texture ogl_texture_list[OGL_TEXTURE_LIST_SIZE]; +static int ogl_texture_list_cur; /* some function prototypes */ #define GL_TEXTURE0_ARB 0x84C0 -extern GLubyte *pixels; -extern GLubyte *texbuf; -void ogl_filltexbuf(unsigned char *data, GLubyte *texp, unsigned truewidth, unsigned width, unsigned height, int dxo, int dyo, unsigned twidth, unsigned theight, int type, int bm_flags, int data_format); -void ogl_loadbmtexture(grs_bitmap *bm); -int ogl_loadtexture(unsigned char *data, int dxo, int dyo, ogl_texture *tex, int bm_flags, int data_format, int texfilt); -void ogl_freetexture(ogl_texture *gltexture); +static int ogl_loadtexture(unsigned char *data, int dxo, int dyo, ogl_texture *tex, int bm_flags, int data_format, int texfilt); +static void ogl_freetexture(ogl_texture *gltexture); + +static void ogl_loadbmtexture(grs_bitmap *bm) +{ + ogl_loadbmtexture_f(bm, GameCfg.TexFilt); +} #ifdef OGLES // Replacement for gluPerspective -void perspective(double fovy, double aspect, double zNear, double zFar) +static void perspective(double fovy, double aspect, double zNear, double zFar) { double xmin, xmax, ymin, ymax; @@ -127,7 +131,7 @@ void perspective(double fovy, double aspect, double zNear, double zFar) } #endif -void ogl_init_texture_stats(ogl_texture* t){ +static void ogl_init_texture_stats(ogl_texture* t){ t->prio=0.3;//default prio t->numrend=0; } @@ -191,12 +195,12 @@ void ogl_init_texture(ogl_texture* t, int w, int h, int flags) ogl_init_texture_stats(t); } -void ogl_reset_texture(ogl_texture* t) +static void ogl_reset_texture(ogl_texture* t) { ogl_init_texture(t, 0, 0, 0); } -void ogl_reset_texture_stats_internal(void){ +static void ogl_reset_texture_stats_internal(void){ int i; for (i=0;i0){ @@ -314,7 +318,7 @@ void ogl_texture_stats(void) gr_printf(FSPACX(2), FSPACY(1)+(LINE_SPACING*3), "total=%iK", (colorsize + depthsize + truebytes) / 1024); } -void ogl_bindbmtex(grs_bitmap *bm){ +static void ogl_bindbmtex(grs_bitmap *bm){ if (bm->gltexture==NULL || bm->gltexture->handle<=0) ogl_loadbmtexture(bm); OGL_BINDTEXTURE(bm->gltexture->handle); @@ -322,7 +326,7 @@ void ogl_bindbmtex(grs_bitmap *bm){ } //gltexture MUST be bound first -void ogl_texwrap(ogl_texture *gltexture,int state) +static void ogl_texwrap(ogl_texture *gltexture,int state) { if (gltexture->wrapstate != state || gltexture->numrend < 1) { @@ -533,7 +537,7 @@ void ogl_drawcircle(int nsides, int type, GLfloat *vertex_array) glDisableClientState(GL_VERTEX_ARRAY); } -GLfloat *circle_array_init(int nsides) +static GLfloat *circle_array_init(int nsides) { int i; float ang; @@ -547,8 +551,8 @@ GLfloat *circle_array_init(int nsides) return vertex_array; } - -GLfloat *circle_array_init_2(int nsides, float xsc, float xo, float ysc, float yo) + +static GLfloat *circle_array_init_2(int nsides, float xsc, float xo, float ysc, float yo) { int i; float ang; @@ -1193,8 +1197,6 @@ void ogl_set_blending() } } -GLubyte *pixels = NULL; - void ogl_start_frame(void){ r_polyc=0;r_tpolyc=0;r_bitmapc=0;r_ubitbltc=0;r_upixelc=0; @@ -1258,8 +1260,6 @@ int pow2ize(int x){ return i; } -GLubyte *texbuf = NULL; - // Allocate the pixel buffers 'pixels' and 'texbuf' based on current screen resolution void ogl_init_pixel_buffers(unsigned w, unsigned h) { @@ -1284,7 +1284,7 @@ void ogl_close_pixel_buffers(void) d_free(texbuf); } -void ogl_filltexbuf(unsigned char *data, GLubyte *texp, unsigned truewidth, unsigned width, unsigned height, int dxo, int dyo, unsigned twidth, unsigned theight, int type, int bm_flags, int data_format) +static void ogl_filltexbuf(unsigned char *data, GLubyte *texp, unsigned truewidth, unsigned width, unsigned height, int dxo, int dyo, unsigned twidth, unsigned theight, int type, int bm_flags, int data_format) { if ((width > max(grd_curscreen->sc_w, 1024)) || (height > max(grd_curscreen->sc_h, 256))) Error("Texture is too big: %ix%i", width, height); @@ -1416,7 +1416,7 @@ void ogl_filltexbuf(unsigned char *data, GLubyte *texp, unsigned truewidth, unsi } } -void tex_set_size1(ogl_texture *tex,int dbits,int bits,int w, int h){ +static void tex_set_size1(ogl_texture *tex,int dbits,int bits,int w, int h){ int u; if (tex->tw!=w || tex->th!=h){ u=(tex->w/(float)tex->tw*w) * (tex->h/(float)tex->th*h); @@ -1433,7 +1433,7 @@ void tex_set_size1(ogl_texture *tex,int dbits,int bits,int w, int h){ glmprintf((0,"tex_set_size1: %ix%i, %ib(%i) %iB\n",w,h,bits,dbits,tex->bytes)); } -void tex_set_size(ogl_texture *tex){ +static void tex_set_size(ogl_texture *tex){ GLint w,h; int bi=16,a=0; #ifndef OGLES @@ -1482,7 +1482,7 @@ void tex_set_size(ogl_texture *tex){ //In theory this could be a problem for repeating textures, but all real //textures (not sprites, etc) in descent are 64x64, so we are ok. //stores OpenGL textured id in *texid and u/v values required to get only the real data in *u/*v -int ogl_loadtexture (unsigned char *data, int dxo, int dyo, ogl_texture *tex, int bm_flags, int data_format, int texfilt) +static int ogl_loadtexture (unsigned char *data, int dxo, int dyo, ogl_texture *tex, int bm_flags, int data_format, int texfilt) { GLubyte *bufP = texbuf; tex->tw = pow2ize (tex->w); @@ -1653,12 +1653,7 @@ void ogl_loadbmtexture_f(grs_bitmap *bm, int texfilt) ogl_loadtexture(buf, 0, 0, bm->gltexture, bm->bm_flags, 0, texfilt); } -void ogl_loadbmtexture(grs_bitmap *bm) -{ - ogl_loadbmtexture_f(bm, GameCfg.TexFilt); -} - -void ogl_freetexture(ogl_texture *gltexture) +static void ogl_freetexture(ogl_texture *gltexture) { if (gltexture->handle>0) { r_texcount--; diff --git a/similar/main/gamerend.c b/similar/main/gamerend.c index 1f16b808f..ff60cb90a 100644 --- a/similar/main/gamerend.c +++ b/similar/main/gamerend.c @@ -661,7 +661,6 @@ void toggle_cockpit() } int last_drawn_cockpit = -1; -extern void ogl_loadbmtexture(grs_bitmap *bm); // This actually renders the new cockpit onto the screen. void update_cockpits() From d909692148b8748480b95d0d2738e089bbb832ee Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 16 Aug 2013 02:00:35 +0000 Subject: [PATCH 08/24] Allow compiler to unroll pow2ize --- common/include/ogl_init.h | 2 +- similar/arch/ogl/ogl.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/common/include/ogl_init.h b/common/include/ogl_init.h index bb53bbc35..419efdc0f 100644 --- a/common/include/ogl_init.h +++ b/common/include/ogl_init.h @@ -108,7 +108,7 @@ bool g3_draw_tmap_2(int nv,g3s_point **pointlist,g3s_uvl *uvl_list,g3s_lrgb *lig void ogl_draw_vertex_reticle(int cross,int primary,int secondary,int color,int alpha,int size_offs); void ogl_toggle_depth_test(int enable); void ogl_set_blending(); -int pow2ize(int x);//from ogl.c +unsigned pow2ize(unsigned x);//from ogl.c #ifdef __cplusplus } diff --git a/similar/arch/ogl/ogl.c b/similar/arch/ogl/ogl.c index 059cf712c..305788e36 100644 --- a/similar/arch/ogl/ogl.c +++ b/similar/arch/ogl/ogl.c @@ -1254,10 +1254,15 @@ void gr_flip(void) } //little hack to find the nearest bigger power of 2 for a given number -int pow2ize(int x){ - int i; - for (i=2; i 0;) + f1 |= f1 >> (1 << i); + unsigned f2 = f1 + 1; + assert(f2 >= f0); + assert(!(f2 & f1)); + assert((f2 >> 1) < f0); + return f2; } // Allocate the pixel buffers 'pixels' and 'texbuf' based on current screen resolution From afcbfe8e544705cd735b8a2547d52244b679f820 Mon Sep 17 00:00:00 2001 From: Kp Date: Fri, 16 Aug 2013 21:47:00 +0000 Subject: [PATCH 09/24] Rename d1x/d2x variables to unify names between D1X and D2X --- common/main/kconfig.h | 14 ++++------- common/main/playsave.h | 6 +---- d1x-rebirth/main/kconfig.c | 48 ++++++++++++++++++------------------- d1x-rebirth/main/playsave.c | 28 +++++++++++----------- d2x-rebirth/main/kconfig.c | 48 ++++++++++++++++++------------------- d2x-rebirth/main/playsave.c | 28 +++++++++++----------- 6 files changed, 82 insertions(+), 90 deletions(-) diff --git a/common/main/kconfig.h b/common/main/kconfig.h index a2c3c1b03..d34c0d3a1 100644 --- a/common/main/kconfig.h +++ b/common/main/kconfig.h @@ -49,15 +49,15 @@ typedef struct _control_info { #define CONTROL_USING_MOUSE 2 #define MOUSEFS_DELTA_RANGE 512 #if defined(DXX_BUILD_DESCENT_I) -#define NUM_D1X_CONTROLS 30 -#define MAX_D1X_CONTROLS 30 +#define NUM_DXX_REBIRTH_CONTROLS 30 +#define MAX_DXX_REBIRTH_CONTROLS 30 #define NUM_KEY_CONTROLS 50 #define NUM_JOYSTICK_CONTROLS 48 #define NUM_MOUSE_CONTROLS 29 #define MAX_CONTROLS 50 #elif defined(DXX_BUILD_DESCENT_II) -#define NUM_D2X_CONTROLS 30 -#define MAX_D2X_CONTROLS 30 +#define NUM_DXX_REBIRTH_CONTROLS 30 +#define MAX_DXX_REBIRTH_CONTROLS 30 #define NUM_KEY_CONTROLS 57 #define NUM_JOYSTICK_CONTROLS 56 #define NUM_MOUSE_CONTROLS 30 @@ -68,12 +68,8 @@ extern control_info Controls; extern void kconfig_read_controls(d_event *event, int automap_flag); extern void kconfig(int n, const char *title); -#if defined(DXX_BUILD_DESCENT_I) -extern const ubyte DefaultKeySettingsD1X[MAX_D1X_CONTROLS]; -#elif defined(DXX_BUILD_DESCENT_II) -extern const ubyte DefaultKeySettingsD2X[MAX_D2X_CONTROLS]; -#endif #if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II) +extern const ubyte DefaultKeySettingsRebirth[MAX_DXX_REBIRTH_CONTROLS]; extern const ubyte DefaultKeySettings[3][MAX_CONTROLS]; #endif diff --git a/common/main/playsave.h b/common/main/playsave.h index 6146f9281..9ee28ba26 100644 --- a/common/main/playsave.h +++ b/common/main/playsave.h @@ -65,11 +65,7 @@ typedef struct player_config ubyte PrimaryOrder[MAX_PRIMARY_WEAPONS+1]; ubyte SecondaryOrder[MAX_SECONDARY_WEAPONS+1]; ubyte KeySettings[3][MAX_CONTROLS]; -#if defined(DXX_BUILD_DESCENT_I) - ubyte KeySettingsD1X[MAX_D1X_CONTROLS]; -#elif defined(DXX_BUILD_DESCENT_II) - ubyte KeySettingsD2X[MAX_D2X_CONTROLS]; -#endif + ubyte KeySettingsRebirth[MAX_DXX_REBIRTH_CONTROLS]; int DefaultDifficulty; int AutoLeveling; short NHighestLevels; diff --git a/d1x-rebirth/main/kconfig.c b/d1x-rebirth/main/kconfig.c index 9d1c418f3..cca9ad706 100644 --- a/d1x-rebirth/main/kconfig.c +++ b/d1x-rebirth/main/kconfig.c @@ -125,7 +125,7 @@ const ubyte DefaultKeySettings[3][MAX_CONTROLS] = { {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0}, {0x0,0x1,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x1,0x0,0x0,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0x0,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0}, }; -const ubyte DefaultKeySettingsD1X[MAX_D1X_CONTROLS] = { 0x2,0xff,0xff,0x3,0xff,0xff,0x4,0xff,0xff,0x5,0xff,0xff,0x6,0xff,0xff,0x7,0xff,0xff,0x8,0xff,0xff,0x9,0xff,0xff,0xa,0xff,0xff,0xb,0xff,0xff }; +const ubyte DefaultKeySettingsRebirth[MAX_DXX_REBIRTH_CONTROLS] = { 0x2,0xff,0xff,0x3,0xff,0xff,0x4,0xff,0xff,0x5,0xff,0xff,0x6,0xff,0xff,0x7,0xff,0xff,0x8,0xff,0xff,0x9,0xff,0xff,0xa,0xff,0xff,0xb,0xff,0xff }; // id, x, y, w1, w2, u, d, l, r, text, type, value kc_item kc_keyboard[NUM_KEY_CONTROLS] = { @@ -275,7 +275,7 @@ kc_item kc_mouse[NUM_MOUSE_CONTROLS] = { #define WEAPON_STRING_SMART "SMART" D2X_EXTENDED_WEAPON_STRING("/MERCURY") " MISSILE" #define WEAPON_STRING_MEGA "MEGA" D2X_EXTENDED_WEAPON_STRING("/EARTHSHAKER") " MISSILE" -kc_item kc_d1x[NUM_D1X_CONTROLS] = { +kc_item kc_rebirth[NUM_DXX_REBIRTH_CONTROLS] = { { 0, 15, 69,142, 26, 29, 3, 29, 1,WEAPON_STRING_LASER, BT_KEY, 255, NULL, 0, &Controls.select_weapon_count }, { 1, 15, 69,200, 26, 27, 4, 0, 2,WEAPON_STRING_LASER, BT_JOY_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, { 2, 15, 69,258, 26, 28, 5, 1, 3,WEAPON_STRING_LASER, BT_MOUSE_BUTTON, 255, NULL, 0, &Controls.select_weapon_count }, @@ -540,7 +540,7 @@ void kconfig_draw(kc_menu *menu) gr_string( FSPACX(242), FSPACY(145), TXT_AXIS ); gr_string( FSPACX(274), FSPACY(145), TXT_INVERT ); } - else if ( menu->items == kc_d1x ) + else if ( menu->items == kc_rebirth ) { gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); gr_setcolor( BM_XRGB(31,27,6) ); @@ -667,9 +667,9 @@ int kconfig_key_command(window *wind, d_event *event, kc_menu *menu) for (i=0; iitems[i].value = DefaultKeySettings[2][i]; - if ( menu->items==kc_d1x ) - for(i=0;iitems[i].value=DefaultKeySettingsD1X[i]; + if ( menu->items==kc_rebirth ) + for(unsigned i=0;iitems) / sizeof(menu->items[0]);i++) + menu->items[i].value=DefaultKeySettingsRebirth[i]; return 1; case KEY_DELETE: menu->items[menu->citem].value=255; @@ -735,11 +735,11 @@ int kconfig_key_command(window *wind, d_event *event, kc_menu *menu) kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_MOUSE_CONTROLS, i); kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_MOUSE_CONTROLS, i); } - for (i=0; itype == EVENT_KEY_COMMAND) for (i = 0, j = 0; i < 28; i += 3, j++) - if (kc_d1x[i].value < 255 && kc_d1x[i].value == event_key_get_raw(event)) + if (kc_rebirth[i].value < 255 && kc_rebirth[i].value == event_key_get_raw(event)) { Controls.select_weapon_count = j+1; break; @@ -1204,7 +1204,7 @@ void kconfig_read_controls(d_event *event, int automap_flag) } if (!automap_flag && event->type == EVENT_JOYSTICK_BUTTON_DOWN) for (i = 1, j = 0; i < 29; i += 3, j++) - if (kc_d1x[i].value < 255 && kc_d1x[i].value == event_joystick_get_button(event)) + if (kc_rebirth[i].value < 255 && kc_rebirth[i].value == event_joystick_get_button(event)) { Controls.select_weapon_count = j+1; break; @@ -1231,7 +1231,7 @@ void kconfig_read_controls(d_event *event, int automap_flag) } if (!automap_flag && event->type == EVENT_MOUSE_BUTTON_DOWN) for (i = 2, j = 0; i < 30; i += 3, j++) - if (kc_d1x[i].value < 255 && kc_d1x[i].value == event_mouse_get_button(event)) + if (kc_rebirth[i].value < 255 && kc_rebirth[i].value == event_mouse_get_button(event)) { Controls.select_weapon_count = j+1; break; @@ -1637,6 +1637,6 @@ void kc_set_controls() } } - for (i=0; iitems == kc_d2x ) + else if ( menu->items == kc_rebirth ) { gr_set_fontcolor( BM_XRGB(31,27,6), -1 ); gr_setcolor( BM_XRGB(31,27,6) ); @@ -685,9 +685,9 @@ int kconfig_key_command(window *wind, d_event *event, kc_menu *menu) if ( menu->items==kc_mouse ) for (i=0; iitems[i].value = DefaultKeySettings[2][i]; - if ( menu->items==kc_d2x ) - for(i=0;iitems[i].value=DefaultKeySettingsD2X[i]; + if ( menu->items==kc_rebirth ) + for(unsigned i=0;iitems) / sizeof(menu->items[0]);i++) + menu->items[i].value=DefaultKeySettingsRebirth[i]; return 1; case KEY_DELETE: menu->items[menu->citem].value=255; @@ -753,11 +753,11 @@ int kconfig_key_command(window *wind, d_event *event, kc_menu *menu) kc_mouse[i].l = find_next_item_left( kc_mouse,NUM_MOUSE_CONTROLS, i); kc_mouse[i].r = find_next_item_right( kc_mouse,NUM_MOUSE_CONTROLS, i); } - for (i=0; itype == EVENT_KEY_COMMAND) for (i = 0, j = 0; i < 28; i += 3, j++) - if (kc_d2x[i].value < 255 && kc_d2x[i].value == event_key_get_raw(event)) + if (kc_rebirth[i].value < 255 && kc_rebirth[i].value == event_key_get_raw(event)) { Controls.select_weapon_count = j+1; break; @@ -1227,7 +1227,7 @@ void kconfig_read_controls(d_event *event, int automap_flag) } if (!automap_flag && event->type == EVENT_JOYSTICK_BUTTON_DOWN) for (i = 1, j = 0; i < 29; i += 3, j++) - if (kc_d2x[i].value < 255 && kc_d2x[i].value == event_joystick_get_button(event)) + if (kc_rebirth[i].value < 255 && kc_rebirth[i].value == event_joystick_get_button(event)) { Controls.select_weapon_count = j+1; break; @@ -1254,7 +1254,7 @@ void kconfig_read_controls(d_event *event, int automap_flag) } if (!automap_flag && event->type == EVENT_MOUSE_BUTTON_DOWN) for (i = 2, j = 0; i < 30; i += 3, j++) - if (kc_d2x[i].value < 255 && kc_d2x[i].value == event_mouse_get_button(event)) + if (kc_rebirth[i].value < 255 && kc_rebirth[i].value == event_mouse_get_button(event)) { Controls.select_weapon_count = j+1; break; @@ -1661,6 +1661,6 @@ void kc_set_controls() } } - for (i=0; i Date: Sat, 17 Aug 2013 14:46:50 +0000 Subject: [PATCH 10/24] Declare newdemo_count_demos for D2 menu system --- common/main/newdemo.h | 1 + d2x-rebirth/main/menu.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/common/main/newdemo.h b/common/main/newdemo.h index 2061bd5d7..d070193e1 100644 --- a/common/main/newdemo.h +++ b/common/main/newdemo.h @@ -122,5 +122,6 @@ extern int newdemo_get_percent_done(); extern void newdemo_record_link_sound_to_object3( int soundno, short objnum, fix max_volume, fix max_distance, int loop_start, int loop_end ); extern int newdemo_find_object( int signature ); extern void newdemo_record_kill_sound_linked_to_object( int objnum ); +int newdemo_count_demos(); #endif // _NEWDEMO_H diff --git a/d2x-rebirth/main/menu.c b/d2x-rebirth/main/menu.c index 7fe7c80c5..8dffcde8b 100644 --- a/d2x-rebirth/main/menu.c +++ b/d2x-rebirth/main/menu.c @@ -409,9 +409,6 @@ void draw_copyright() gr_string(0x8000,SHEIGHT-(LINE_SPACING*2),DESCENT_VERSION); } -//returns the number of demo files on the disk -int newdemo_count_demos(); - // ------------------------------------------------------------------------ int main_menu_handler(newmenu *menu, d_event *event, int *menu_choice ) { From 1b44fe5844b67f6779e8b5fd06a7917b3cfeacfc Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 18 Aug 2013 17:53:50 +0000 Subject: [PATCH 11/24] Move alpha blend test to helper to simplify merge --- d1x-rebirth/main/render.c | 7 ++++++- d2x-rebirth/main/render.c | 9 ++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/d1x-rebirth/main/render.c b/d1x-rebirth/main/render.c index 9117c89ae..41349c9ee 100644 --- a/d1x-rebirth/main/render.c +++ b/d1x-rebirth/main/render.c @@ -177,6 +177,11 @@ void flash_frame() extern int Current_level_num; #endif +static inline int is_alphablend_eclip(int eclip_num) +{ + return eclip_num == ECLIP_NUM_FUELCEN; +} + // ----------------------------------------------------------------------------------- // Render a face. // It would be nice to not have to pass in segnum and sidenum, but they are used for our @@ -280,7 +285,7 @@ void render_face(int segnum, int sidenum, int nv, int *vp, int tmap1, int tmap2, } - if ( PlayerCfg.AlphaEffects && ( TmapInfo[tmap1].eclip_num == ECLIP_NUM_FUELCEN ) ) // set nice transparency/blending for some special effects (if we do more, we should maybe use switch here) + if ( PlayerCfg.AlphaEffects && is_alphablend_eclip(TmapInfo[tmap1].eclip_num) ) // set nice transparency/blending for some special effects (if we do more, we should maybe use switch here) gr_settransblend(GR_FADE_OFF, GR_BLEND_ADDITIVE_C); #ifdef EDITOR diff --git a/d2x-rebirth/main/render.c b/d2x-rebirth/main/render.c index cd55d080c..38e5c555b 100644 --- a/d2x-rebirth/main/render.c +++ b/d2x-rebirth/main/render.c @@ -191,6 +191,13 @@ void flash_frame() } +static inline int is_alphablend_eclip(int eclip_num) +{ + if (eclip_num == ECLIP_NUM_FORCE_FIELD) + return 1; + return eclip_num == ECLIP_NUM_FUELCEN; +} + // ---------------------------------------------------------------------------- // Render a face. // It would be nice to not have to pass in segnum and sidenum, but @@ -313,7 +320,7 @@ void render_face(int segnum, int sidenum, int nv, int *vp, int tmap1, int tmap2, } } - if ( PlayerCfg.AlphaEffects && ( TmapInfo[tmap1].eclip_num == ECLIP_NUM_FUELCEN || TmapInfo[tmap1].eclip_num == ECLIP_NUM_FORCE_FIELD ) ) // set nice transparency/blending for some special effects (if we do more, we should maybe use switch here) + if ( PlayerCfg.AlphaEffects && is_alphablend_eclip(TmapInfo[tmap1].eclip_num) ) // set nice transparency/blending for some special effects (if we do more, we should maybe use switch here) gr_settransblend(GR_FADE_OFF, GR_BLEND_ADDITIVE_C); #ifdef EDITOR From b1b40bfe99a1c0ea7da4e648e8ffff9a82287171 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 18 Aug 2013 22:56:32 +0000 Subject: [PATCH 12/24] Remove unused set_rotvel_and_saturate --- d1x-rebirth/main/ai.c | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/d1x-rebirth/main/ai.c b/d1x-rebirth/main/ai.c index ec6169133..23b059f9f 100644 --- a/d1x-rebirth/main/ai.c +++ b/d1x-rebirth/main/ai.c @@ -400,22 +400,6 @@ void init_ai_objects(void) Ai_initialized = 1; } -// ---------------------------------------------------------------- -// Do *dest = *delta unless: -// *delta is pretty small -// and they are of different signs. -void set_rotvel_and_saturate(fix *dest, fix delta) -{ - if ((delta ^ *dest) < 0) { - if (abs(delta) < F1_0/8) { - *dest = delta/4; - } else - *dest = delta; - } else { - *dest = delta; - } -} - //--debug-- #ifndef NDEBUG //--debug-- int Total_turns=0; //--debug-- int Prevented_turns=0; From 335c56111bbf63ed5b30afac4c42e75fd71172c1 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 18 Aug 2013 23:08:28 +0000 Subject: [PATCH 13/24] Remove unused move_object_to_legal_spot --- d1x-rebirth/main/ai.c | 65 ------------------------------------------- 1 file changed, 65 deletions(-) diff --git a/d1x-rebirth/main/ai.c b/d1x-rebirth/main/ai.c index 23b059f9f..cdde86ab3 100644 --- a/d1x-rebirth/main/ai.c +++ b/d1x-rebirth/main/ai.c @@ -1309,42 +1309,6 @@ void compute_vis_and_vec(object *objp, vms_vector *pos, ai_local *ailp, vms_vect } -// -------------------------------------------------------------------------------------------------------------------- -// Move the object objp to a spot in which it doesn't intersect a wall. -// It might mean moving it outside its current segment. -void move_object_to_legal_spot(object *objp) -{ - vms_vector original_pos = objp->pos; - int i; - segment *segp = &Segments[objp->segnum]; - - for (i=0; ichildren[i]]); - vm_vec_sub(&goal_dir, &segment_center, &objp->pos); - vm_vec_normalize_quick(&goal_dir); - vm_vec_scale(&goal_dir, objp->size); - vm_vec_add2(&objp->pos, &goal_dir); - if (!object_intersects_wall(objp)) { - int new_segnum = find_point_seg(&objp->pos, objp->segnum); - - if (new_segnum != -1) { - obj_relink(objp-Objects, new_segnum); - return; - } - } else - objp->pos = original_pos; - } - } - - // Int3(); // Darn you John, you done it again! (But contact Mike) - con_printf(CON_DEBUG, "Note: Killing robot #%hu because he's badly stuck outside the mine.\n", (unsigned short)(objp-Objects)); - - apply_damage_to_robot(objp, objp->shields*2, objp-Objects); -} - // -------------------------------------------------------------------------------------------------------------------- // Move object one object radii from current position towards segment center. // If segment center is nearer than 2 radii, move it to center. @@ -1354,41 +1318,12 @@ void move_towards_segment_center(object *objp) Make move to segment center smoother by using move_towards vector. Bot's should not jump around and maybe even intersect with each other! In case it breaks something what I do not see, yet, old code is still there. */ -#if 1 int segnum = objp->segnum; vms_vector vec_to_center, segment_center; compute_segment_center(&segment_center, &Segments[segnum]); vm_vec_normalized_dir_quick(&vec_to_center, &segment_center, &objp->pos); move_towards_vector(objp, &vec_to_center); -#else - int segnum = objp->segnum; - fix dist_to_center; - vms_vector segment_center, goal_dir; - - compute_segment_center(&segment_center, &Segments[segnum]); - - vm_vec_sub(&goal_dir, &segment_center, &objp->pos); - dist_to_center = vm_vec_normalize_quick(&goal_dir); - - if (dist_to_center < objp->size) { - // Center is nearer than the distance we want to move, so move to center. - objp->pos = segment_center; - if (object_intersects_wall(objp)) { - move_object_to_legal_spot(objp); - } - } else { - int new_segnum; - // Move one radii towards center. - vm_vec_scale(&goal_dir, objp->size); - vm_vec_add2(&objp->pos, &goal_dir); - new_segnum = find_point_seg(&objp->pos, objp->segnum); - if (new_segnum == -1) { - objp->pos = segment_center; - move_object_to_legal_spot(objp); - } - } -#endif } // ----------------------------------------------------------------------------------------------------------- From 0365b3600fa2f9aa9861a15b4e23dcd598a33d0b Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 18 Aug 2013 23:12:26 +0000 Subject: [PATCH 14/24] Remove unused special_object_in_seg --- d1x-rebirth/main/ai.c | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/d1x-rebirth/main/ai.c b/d1x-rebirth/main/ai.c index cdde86ab3..b2d82def6 100644 --- a/d1x-rebirth/main/ai.c +++ b/d1x-rebirth/main/ai.c @@ -1382,24 +1382,6 @@ int openable_doors_in_segment(object *objp) } -// -------------------------------------------------------------------------------------------------------------------- -// Return true if a special object (player or control center) is in this segment. -int special_object_in_seg(int segnum) -{ - int objnum; - - objnum = Segments[segnum].objects; - - while (objnum != -1) { - if ((Objects[objnum].type == OBJ_PLAYER) || (Objects[objnum].type == OBJ_CNTRLCEN)) { - return 1; - } else - objnum = Objects[objnum].next; - } - - return 0; -} - // -------------------------------------------------------------------------------------------------------------------- // Randomly select a segment attached to *segp, reachable by flying. int get_random_child(int segnum) From e8776caf16584ef91f03b7ddb4e3f0ee00388d9e Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 18 Aug 2013 23:13:16 +0000 Subject: [PATCH 15/24] Remove unused get_random_child --- d1x-rebirth/main/ai.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/d1x-rebirth/main/ai.c b/d1x-rebirth/main/ai.c index b2d82def6..5f85911a9 100644 --- a/d1x-rebirth/main/ai.c +++ b/d1x-rebirth/main/ai.c @@ -1382,23 +1382,6 @@ int openable_doors_in_segment(object *objp) } -// -------------------------------------------------------------------------------------------------------------------- -// Randomly select a segment attached to *segp, reachable by flying. -int get_random_child(int segnum) -{ - int sidenum; - segment *segp = &Segments[segnum]; - - sidenum = (d_rand() * 6) >> 15; - - while (!(WALL_IS_DOORWAY(segp, sidenum) & WID_FLY_FLAG)) - sidenum = (d_rand() * 6) >> 15; - - segnum = segp->children[sidenum]; - - return segnum; -} - // -------------------------------------------------------------------------------------------------------------------- // Return true if placing an object of size size at pos *pos intersects a (player or robot or control center) in segment *segp. int check_object_object_intersection(vms_vector *pos, fix size, segment *segp) From 3f0f68e862f7abd00f9d5b1b3d0ce90ca68881f4 Mon Sep 17 00:00:00 2001 From: Kp Date: Tue, 20 Aug 2013 01:53:21 +0000 Subject: [PATCH 16/24] Remove unused move_object_to_goal --- d1x-rebirth/main/aipath.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/d1x-rebirth/main/aipath.c b/d1x-rebirth/main/aipath.c index babb1596e..bcb0facf2 100644 --- a/d1x-rebirth/main/aipath.c +++ b/d1x-rebirth/main/aipath.c @@ -572,43 +572,6 @@ void create_n_segment_path_to_door(object *objp, int path_length, int avoid_seg) extern int Connected_segment_distance; -// ---------------------------------------------------------------------------------------------------- -void move_object_to_goal(object *objp, vms_vector *goal_point, int goal_seg) -{ - ai_static *aip = &objp->ctype.ai_info; - int segnum; - - Assert(objp->segnum != -1); - - aip->cur_path_index += aip->PATH_DIR; - - if (aip->cur_path_index <= 0) { - if (aip->behavior == AIB_STATION) { - create_path_to_station(objp, 15); - return; - } - aip->cur_path_index = 0; - aip->PATH_DIR = -aip->PATH_DIR; - } else if (aip->cur_path_index >= aip->path_length) { - if (aip->behavior == AIB_STATION) { - create_path_to_station(objp, 15); - return; - } - aip->cur_path_index = aip->path_length-1; - aip->PATH_DIR = -aip->PATH_DIR; - } - - objp->pos = *goal_point; - segnum = find_object_seg(objp); - - if (segnum == -1) { - Int3(); // Oops, object is not in any segment. - // Contact Mike: This is impossible. - // Hack, move object to center of segment it used to be in. - compute_segment_center(&objp->pos, &Segments[objp->segnum]); - } else - obj_relink(objp-Objects, segnum); -} // ---------------------------------------------------------------------------------------------------------- // Optimization: If current velocity will take robot near goal, don't change velocity From 897023eda51604b4a207a3efbaa37d311a5c4f30 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 18 Aug 2013 22:27:33 +0000 Subject: [PATCH 17/24] Reorder vertex render lookups to simplify merge --- d1x-rebirth/main/render.c | 8 ++++---- d2x-rebirth/main/render.c | 10 ++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/d1x-rebirth/main/render.c b/d1x-rebirth/main/render.c index 41349c9ee..fe5b32414 100644 --- a/d1x-rebirth/main/render.c +++ b/d1x-rebirth/main/render.c @@ -401,16 +401,16 @@ void render_side(segment *segp, int sidenum) normals[1] = segp->sides[sidenum].normals[1]; #endif + get_side_verts(vertnum_list,segp-Segments,sidenum); + // Regardless of whether this side is comprised of a single quad, or two triangles, we need to know one normal, so // deal with it, get the dot product. if (sidep->type == SIDE_IS_TRI_13) { - vm_vec_normalized_dir(&tvec, &Viewer_eye, &Vertices[segp->verts[Side_to_verts[sidenum][1]]]); + vm_vec_normalized_dir(&tvec, &Viewer_eye, &Vertices[vertnum_list[1]]); } else { - vm_vec_normalized_dir(&tvec, &Viewer_eye, &Vertices[segp->verts[Side_to_verts[sidenum][0]]]); + vm_vec_normalized_dir(&tvec, &Viewer_eye, &Vertices[vertnum_list[0]]); } - get_side_verts(vertnum_list,segp-Segments,sidenum); - v_dot_n0 = vm_vec_dot(&tvec, &normals[0]); if (sidep->type == SIDE_IS_QUAD) { diff --git a/d2x-rebirth/main/render.c b/d2x-rebirth/main/render.c index 38e5c555b..d8551422e 100644 --- a/d2x-rebirth/main/render.c +++ b/d2x-rebirth/main/render.c @@ -434,12 +434,13 @@ void render_side(segment *segp, int sidenum) normals[0] = segp->sides[sidenum].normals[0]; normals[1] = segp->sides[sidenum].normals[1]; #endif + get_side_verts(vertnum_list,segp-Segments,sidenum); // ========== Mark: Here is the change...beginning here: ========== if (sidep->type == SIDE_IS_QUAD) { - vm_vec_sub(&tvec, &Viewer_eye, &Vertices[segp->verts[Side_to_verts[sidenum][0]]]); + vm_vec_sub(&tvec, &Viewer_eye, &Vertices[vertnum_list[0]]); // -- Old, slow way -- // Regardless of whether this side is comprised of a single quad, or two triangles, we need to know one normal, so // -- Old, slow way -- // deal with it, get the dot product. @@ -448,7 +449,6 @@ void render_side(segment *segp, int sidenum) // -- Old, slow way -- else // -- Old, slow way -- vm_vec_normalized_dir(&tvec, &Viewer_eye, &Vertices[segp->verts[Side_to_verts[sidenum][0]]]); - get_side_verts(vertnum_list,segp-Segments,sidenum); v_dot_n0 = vm_vec_dot(&tvec, &normals[0]); // -- flare creates point -- { @@ -501,11 +501,9 @@ void render_side(segment *segp, int sidenum) // Regardless of whether this side is comprised of a single quad, or two triangles, we need to know one normal, so // deal with it, get the dot product. if (sidep->type == SIDE_IS_TRI_13) - vm_vec_normalized_dir_quick(&tvec, &Viewer_eye, &Vertices[segp->verts[Side_to_verts[sidenum][1]]]); + vm_vec_normalized_dir_quick(&tvec, &Viewer_eye, &Vertices[vertnum_list[1]]); else - vm_vec_normalized_dir_quick(&tvec, &Viewer_eye, &Vertices[segp->verts[Side_to_verts[sidenum][0]]]); - - get_side_verts(vertnum_list,segp-Segments,sidenum); + vm_vec_normalized_dir_quick(&tvec, &Viewer_eye, &Vertices[vertnum_list[0]]); v_dot_n0 = vm_vec_dot(&tvec, &normals[0]); From af52e78a50e0c36a23743aeba58433572b4d057d Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 11 Nov 2012 22:12:51 +0000 Subject: [PATCH 18/24] Move similar/arch/ogl/ogl.c -> similar/arch/ogl/ogl.cpp --- SConstruct | 2 +- common/include/gr.h | 1 + common/main/effects.h | 8 ++++++++ common/main/piggy.h | 8 ++++++++ common/main/texmerge.h | 8 ++++++++ d2x-rebirth/main/bm.c | 4 ---- similar/arch/ogl/{ogl.c => ogl.cpp} | 9 ++++++--- 7 files changed, 32 insertions(+), 8 deletions(-) rename similar/arch/ogl/{ogl.c => ogl.cpp} (99%) diff --git a/SConstruct b/SConstruct index bd260ce7a..5ac0a2e35 100644 --- a/SConstruct +++ b/SConstruct @@ -719,7 +719,7 @@ class DXXProgram(DXXCommon): objects_similar_arch_ogl = DXXCommon.create_lazy_object_property([{ 'source':[os.path.join('similar', f) for f in [ 'arch/ogl/gr.cpp', -'arch/ogl/ogl.c', +'arch/ogl/ogl.cpp', ] ], 'transform_target':_apply_target_name, diff --git a/common/include/gr.h b/common/include/gr.h index 5db4ff259..c93f7b20e 100644 --- a/common/include/gr.h +++ b/common/include/gr.h @@ -402,6 +402,7 @@ int gr_toggle_fullscreen(void); void ogl_do_palfx(void); void ogl_init_pixel_buffers(unsigned w, unsigned h); void ogl_close_pixel_buffers(void); +void ogl_cache_polymodel_textures(int model_num);; #ifdef __cplusplus } diff --git a/common/main/effects.h b/common/main/effects.h index 149e7baaa..04ac2e3d1 100644 --- a/common/main/effects.h +++ b/common/main/effects.h @@ -23,6 +23,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "vclip.h" +#ifdef __cplusplus +extern "C" { +#endif + #if defined(DXX_BUILD_DESCENT_I) #define MAX_EFFECTS 60 #elif defined(DXX_BUILD_DESCENT_II) @@ -83,4 +87,8 @@ void restart_effect(int effect_num); */ extern int eclip_read_n(eclip *ec, int n, PHYSFS_file *fp); +#ifdef __cplusplus +} +#endif + #endif /* _EFFECTS_H */ diff --git a/common/main/piggy.h b/common/main/piggy.h index bd7baeb5d..91c30ed59 100644 --- a/common/main/piggy.h +++ b/common/main/piggy.h @@ -25,6 +25,10 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "sounds.h" #include "inferno.h" +#ifdef __cplusplus +extern "C" { +#endif + #define D1_SHARE_BIG_PIGSIZE 5092871 // v1.0 - 1.4 before RLE compression #define D1_SHARE_10_PIGSIZE 2529454 // v1.0 - 1.2 #define D1_SHARE_PIGSIZE 2509799 // v1.4 @@ -163,4 +167,8 @@ extern digi_sound bogus_sound; extern const char space[3]; extern const char equal_space[4]; +#ifdef __cplusplus +} +#endif + #endif //_PIGGY_H diff --git a/common/main/texmerge.h b/common/main/texmerge.h index 40dc4af85..d37c2390e 100644 --- a/common/main/texmerge.h +++ b/common/main/texmerge.h @@ -21,9 +21,17 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #ifndef _TEXMERGE_H #define _TEXMERGE_H +#ifdef __cplusplus +extern "C" { +#endif + int texmerge_init(int num_cached_textures); grs_bitmap *texmerge_get_cached_bitmap(int tmap_bottom, int tmap_top); void texmerge_close(); void texmerge_flush(); +#ifdef __cplusplus +} +#endif + #endif /* _TEXMERGE_H */ diff --git a/d2x-rebirth/main/bm.c b/d2x-rebirth/main/bm.c index e115d2db1..940e67e2c 100644 --- a/d2x-rebirth/main/bm.c +++ b/d2x-rebirth/main/bm.c @@ -478,10 +478,6 @@ grs_bitmap *bm_load_extra_objbitmap(char *name) } } -#ifdef OGL -void ogl_cache_polymodel_textures(int model_num); -#endif - int load_exit_models() { PHYSFS_file *exit_hamfile; diff --git a/similar/arch/ogl/ogl.c b/similar/arch/ogl/ogl.cpp similarity index 99% rename from similar/arch/ogl/ogl.c rename to similar/arch/ogl/ogl.cpp index 305788e36..76609fb93 100644 --- a/similar/arch/ogl/ogl.c +++ b/similar/arch/ogl/ogl.cpp @@ -53,6 +53,9 @@ #include "playsave.h" #include "args.h" +#include +using std::max; + //change to 1 for lots of spew. #if 0 #define glmprintf(0,a) con_printf(CON_DEBUG, a) @@ -865,11 +868,11 @@ bool g3_draw_poly(int nv,g3s_point **pointlist) return 0; } -void gr_upoly_tmap(int nverts, const int *vert ){ +void gr_upoly_tmap(int, const int *){ glmprintf((0,"gr_upoly_tmap: unhandled\n"));//should never get called } -void draw_tmap_flat(grs_bitmap *bm,int nv,g3s_point **vertlist){ +void draw_tmap_flat(grs_bitmap *,int,g3s_point **){ glmprintf((0,"draw_tmap_flat: unhandled\n"));//should never get called } @@ -1291,7 +1294,7 @@ void ogl_close_pixel_buffers(void) static void ogl_filltexbuf(unsigned char *data, GLubyte *texp, unsigned truewidth, unsigned width, unsigned height, int dxo, int dyo, unsigned twidth, unsigned theight, int type, int bm_flags, int data_format) { - if ((width > max(grd_curscreen->sc_w, 1024)) || (height > max(grd_curscreen->sc_h, 256))) + if ((width > max(static_cast(grd_curscreen->sc_w), 1024u)) || (height > max(static_cast(grd_curscreen->sc_h), 256u))) Error("Texture is too big: %ix%i", width, height); for (unsigned y=0;y Date: Sun, 25 Aug 2013 17:13:37 +0000 Subject: [PATCH 19/24] Fix level load hang on >=mingw32-gcc-4.7 Starting in gcc 4.7 "Windows mingw targets are using the -mms-bitfields option by default." . This causes __attribute__((packed)) not to be effective on structures that are used to express the layout of on-disk data. In turn, that causes piggy.c to mishandle texture loads, eventually resulting in an infinite loop. Add a pragma pack to force the headers to pack tightly on Windows. --- common/include/pstypes.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/include/pstypes.h b/common/include/pstypes.h index 7f9a059f3..7fe6e1a64 100644 --- a/common/include/pstypes.h +++ b/common/include/pstypes.h @@ -84,6 +84,9 @@ defined(__LITTLE_ENDIAN__) // from physfs_internal.h #ifdef __GNUC__ # define __pack__ __attribute__((packed)) +#ifdef WIN32 +# pragma pack(1) +#endif #elif defined(_MSC_VER) # pragma pack(push, packing) # pragma pack(1) From 1abcfcb8449ca6b760f45f2c7e71ca5b8e435f52 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 25 Aug 2013 17:15:58 +0000 Subject: [PATCH 20/24] Add sanity check that DiskBitmapHeader is the right size This would have caught the -mms-bitfields bug at build time. --- d2x-rebirth/main/piggy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/d2x-rebirth/main/piggy.c b/d2x-rebirth/main/piggy.c index 091469645..88e09a836 100644 --- a/d2x-rebirth/main/piggy.c +++ b/d2x-rebirth/main/piggy.c @@ -130,6 +130,7 @@ typedef struct DiskBitmapHeader { ubyte avg_color; int offset; } __pack__ DiskBitmapHeader; +typedef char padding_check[sizeof(DiskBitmapHeader) == 0x12 ? 1 : -1]; #define DISKBITMAPHEADER_D1_SIZE 17 // no wh_extra From 20fdaa3fa7246154e18d069b056adfe18cad18df Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 24 Aug 2013 20:54:29 +0000 Subject: [PATCH 21/24] Remove duplicate object addition in SConstruct --- SConstruct | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SConstruct b/SConstruct index 5ac0a2e35..8fa1510f4 100644 --- a/SConstruct +++ b/SConstruct @@ -520,7 +520,6 @@ class DXXCommon(LazyObjectConstructor): # Acquire environment object... self.env = Environment(ENV = os.environ, tools = platform.tools) self.platform_settings.adjust_environment(self, self.env) - self.sources += self.platform_settings.platform_sources def process_user_settings(self): env = self.env @@ -886,6 +885,8 @@ class DXXProgram(DXXCommon): @property def objects_common(self): objects_common = self.__objects_common + if (self.user_settings.use_udp == 1): + objects_common = objects_common + self.objects_use_udp return objects_common + self.platform_settings.platform_objects def __init__(self,prefix): self.variables = Variables('site-local.py', ARGUMENTS) @@ -959,8 +960,6 @@ class DXXProgram(DXXCommon): message(self, "building with Software Renderer") objects.extend(static_archive_construction.objects_arch_sdl) objects.extend(self.objects_similar_arch_sdl) - if (self.user_settings.use_udp == 1): - objects.extend(self.objects_use_udp) if (self.user_settings.editor == 1): objects.extend(self.objects_editor) objects.extend(static_archive_construction.objects_editor) From 16039a3f9995ad73467434d90775819fe650261e Mon Sep 17 00:00:00 2001 From: Kp Date: Tue, 27 Aug 2013 02:28:27 +0000 Subject: [PATCH 22/24] Remove unused extern global hitobj_list --- common/main/object.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/main/object.h b/common/main/object.h index cfd415b0a..fda72f0b8 100644 --- a/common/main/object.h +++ b/common/main/object.h @@ -227,8 +227,6 @@ typedef struct laser_info_rw { fix multiplier; // Power if this is a fusion bolt (or other super weapon to be added). } __pack__ laser_info_rw; -extern ubyte hitobj_list[MAX_OBJECTS][MAX_OBJECTS]; - typedef struct explosion_info { fix spawn_time; // when lifeleft is < this, spawn another fix delete_time; // when to delete object From 6e7462134e66ba7996b076acda1d153cb8ca7080 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 25 Aug 2013 20:43:28 +0000 Subject: [PATCH 23/24] Print builddir into platform banner --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 8fa1510f4..e997cd69e 100644 --- a/SConstruct +++ b/SConstruct @@ -509,7 +509,7 @@ class DXXCommon(LazyObjectConstructor): prefix = ' with prefix list %s' % list(self._argument_prefix_list) else: prefix = '' - message(self, "compiling on %s for %s%s" % (sys.platform, platform_name, prefix)) + message(self, "compiling on %s for %s into %s%s" % (sys.platform, platform_name, self.user_settings.builddir or '.', prefix)) if platform_name == 'win32': platform = self.Win32PlatformSettings elif platform_name == 'darwin': From 6be4dc01c57e2c3acb77a4148f6bfd4316bc59f3 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 24 Nov 2012 20:09:16 +0000 Subject: [PATCH 24/24] Pass non-const string to putenv --- similar/misc/args.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/similar/misc/args.c b/similar/misc/args.c index 11a75b27d..a48e82d65 100644 --- a/similar/misc/args.c +++ b/similar/misc/args.c @@ -124,10 +124,10 @@ static void ReadCmdArgs(void) GameArg.CtlNoMouse = FindArg("-nomouse"); GameArg.CtlNoJoystick = FindArg("-nojoystick"); GameArg.CtlNoStickyKeys = FindArg("-nostickykeys"); + static char sdl_disable_lock_keys[] = "SDL_DISABLE_LOCK_KEYS=0"; if (GameArg.CtlNoStickyKeys) // Must happen before SDL_Init! - SDL_putenv("SDL_DISABLE_LOCK_KEYS=1"); - else - SDL_putenv("SDL_DISABLE_LOCK_KEYS=0"); + sdl_disable_lock_keys[sizeof(sdl_disable_lock_keys) - 1] = '1'; + SDL_putenv(sdl_disable_lock_keys); // Sound Options