From 714d7a29397b44fcb2b1fef2d675d296cb984264 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 19 Feb 2015 23:50:04 -0500 Subject: doom: Change weaponowned[] to an int array. The st_stuff.c status bar code passes pointer to an entry in weaponowned[] as an int pointer, but weaponowned[] is an array of booleans and booleans are not always represented as 32-bit ints. Remove the (int *) cast and ensure correct behavior. This fixes the immediate issue in #509 (thanks floppes). --- src/doom/d_player.h | 2 +- src/doom/st_stuff.c | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src/doom') diff --git a/src/doom/d_player.h b/src/doom/d_player.h index a72c2f5f..04e47109 100644 --- a/src/doom/d_player.h +++ b/src/doom/d_player.h @@ -111,7 +111,7 @@ typedef struct player_s // Is wp_nochange if not changing. weapontype_t pendingweapon; - boolean weaponowned[NUMWEAPONS]; + int weaponowned[NUMWEAPONS]; int ammo[NUMAMMO]; int maxammo[NUMAMMO]; diff --git a/src/doom/st_stuff.c b/src/doom/st_stuff.c index 9a25865c..693b6ef2 100644 --- a/src/doom/st_stuff.c +++ b/src/doom/st_stuff.c @@ -1261,11 +1261,12 @@ void ST_createWidgets(void) // weapons owned for(i=0;i<6;i++) { - STlib_initMultIcon(&w_arms[i], - ST_ARMSX+(i%3)*ST_ARMSXSPACE, - ST_ARMSY+(i/3)*ST_ARMSYSPACE, - arms[i], (int *) &plyr->weaponowned[i+1], - &st_armson); + STlib_initMultIcon(&w_arms[i], + ST_ARMSX+(i%3)*ST_ARMSXSPACE, + ST_ARMSY+(i/3)*ST_ARMSYSPACE, + arms[i], + &plyr->weaponowned[i+1], + &st_armson); } // frags sum -- cgit v1.2.3 From 1f5ce047ad6cb709f746b794b4a2dea9e2f89fb6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 20 Feb 2015 00:03:15 -0500 Subject: Fix game code that makes false boolean assumptions. Various bits of code assume that booleans are represented as 32-bit ints and that they can be assigned to from 32-bit values. This isn't true on all systems; fix code that does this to convert to boolean values properly. This is more progress towards fixing #509. --- src/doom/p_inter.c | 15 +++++++++------ src/doom/p_map.c | 2 +- src/doom/p_maputl.c | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src/doom') diff --git a/src/doom/p_inter.c b/src/doom/p_inter.c index c9965799..633408fe 100644 --- a/src/doom/p_inter.c +++ b/src/doom/p_inter.c @@ -603,8 +603,9 @@ P_TouchSpecialThing break; case SPR_MGUN: - if (!P_GiveWeapon (player, wp_chaingun, special->flags&MF_DROPPED) ) - return; + if (!P_GiveWeapon(player, wp_chaingun, + (special->flags & MF_DROPPED) != 0)) + return; player->message = DEH_String(GOTCHAINGUN); sound = sfx_wpnup; break; @@ -631,15 +632,17 @@ P_TouchSpecialThing break; case SPR_SHOT: - if (!P_GiveWeapon (player, wp_shotgun, special->flags&MF_DROPPED ) ) - return; + if (!P_GiveWeapon(player, wp_shotgun, + (special->flags & MF_DROPPED) != 0)) + return; player->message = DEH_String(GOTSHOTGUN); sound = sfx_wpnup; break; case SPR_SGN2: - if (!P_GiveWeapon (player, wp_supershotgun, special->flags&MF_DROPPED ) ) - return; + if (!P_GiveWeapon(player, wp_supershotgun, + (special->flags & MF_DROPPED) != 0)) + return; player->message = DEH_String(GOTSHOTGUN2); sound = sfx_wpnup; break; diff --git a/src/doom/p_map.c b/src/doom/p_map.c index e371869a..9d3086fd 100644 --- a/src/doom/p_map.c +++ b/src/doom/p_map.c @@ -357,7 +357,7 @@ boolean PIT_CheckThing (mobj_t* thing) // check for special pickup if (thing->flags & MF_SPECIAL) { - solid = thing->flags&MF_SOLID; + solid = (thing->flags & MF_SOLID) != 0; if (tmflags&MF_PICKUP) { // can remove thing diff --git a/src/doom/p_maputl.c b/src/doom/p_maputl.c index 916f2b64..098c2c73 100644 --- a/src/doom/p_maputl.c +++ b/src/doom/p_maputl.c @@ -887,7 +887,7 @@ P_PathTraverse int count; - earlyout = flags & PT_EARLYOUT; + earlyout = (flags & PT_EARLYOUT) != 0; validcount++; intercept_p = intercepts; -- cgit v1.2.3 From b39121c6a682eb8ae5efd29a875bd7c098185f04 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 20 Feb 2015 00:31:09 -0500 Subject: Refactor config file API. The config file API previously relied on binding config variables using M_BindVariable() which took a void pointer. It occurred to me that if used on a boolean variable, this would be erroneous, but the void pointer would make it impossible to tell. Split this into separate M_Bind{Foo}Variable() functions based on type, which allows for proper type checking on the pointers that are passed. Vaguely related to #509. --- src/doom/d_main.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src/doom') diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 1e9e950e..ca722dc6 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -359,16 +359,16 @@ void D_BindVariables(void) NET_BindVariables(); #endif - M_BindVariable("mouse_sensitivity", &mouseSensitivity); - M_BindVariable("sfx_volume", &sfxVolume); - M_BindVariable("music_volume", &musicVolume); - M_BindVariable("show_messages", &showMessages); - M_BindVariable("screenblocks", &screenblocks); - M_BindVariable("detaillevel", &detailLevel); - M_BindVariable("snd_channels", &snd_channels); - M_BindVariable("vanilla_savegame_limit", &vanilla_savegame_limit); - M_BindVariable("vanilla_demo_limit", &vanilla_demo_limit); - M_BindVariable("show_endoom", &show_endoom); + M_BindIntVariable("mouse_sensitivity", &mouseSensitivity); + M_BindIntVariable("sfx_volume", &sfxVolume); + M_BindIntVariable("music_volume", &musicVolume); + M_BindIntVariable("show_messages", &showMessages); + M_BindIntVariable("screenblocks", &screenblocks); + M_BindIntVariable("detaillevel", &detailLevel); + M_BindIntVariable("snd_channels", &snd_channels); + M_BindIntVariable("vanilla_savegame_limit", &vanilla_savegame_limit); + M_BindIntVariable("vanilla_demo_limit", &vanilla_demo_limit); + M_BindIntVariable("show_endoom", &show_endoom); // Multiplayer chat macros @@ -377,7 +377,7 @@ void D_BindVariables(void) char buf[12]; M_snprintf(buf, sizeof(buf), "chatmacro%i", i); - M_BindVariable(buf, &chat_macros[i]); + M_BindStringVariable(buf, &chat_macros[i]); } } -- cgit v1.2.3 From bfda08cf5275a70a705b3d290ca5271d40481993 Mon Sep 17 00:00:00 2001 From: Fabian Greffrath Date: Thu, 5 Mar 2015 20:43:06 +0100 Subject: Initialize floor->type and floor->crush fields in EV_BuildStairs() The floor->type and floor->crush fields of the floor thinkers added in EV_BuildStairs() were originally left uninitialized and thus contained random memory content. Initialize them to make sure the floor->type field does not trigger propagation of random content into the special and texture fields of the adjacent sector in T_MoveFloor(). That is, make sure its value is neither donutRaise, i.e. 11, nor lowerAndChange, i.e. 6. Also, the chances of 32 bit of random memory being "true", i.e. 0, are negligible. This is functionally equivalent to what PrBoom+ is doing. Fixes desync of mm09-512.lmp. Fixes #368. --- src/doom/p_floor.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/doom') diff --git a/src/doom/p_floor.c b/src/doom/p_floor.c index 1384ee6b..c120d616 100644 --- a/src/doom/p_floor.c +++ b/src/doom/p_floor.c @@ -493,6 +493,9 @@ EV_BuildStairs floor->speed = speed; height = sec->floorheight + stairsize; floor->floordestheight = height; + // Initialize + floor->type = lowerFloor; + floor->crush = true; texture = sec->floorpic; @@ -536,6 +539,9 @@ EV_BuildStairs floor->sector = sec; floor->speed = speed; floor->floordestheight = height; + // Initialize + floor->type = lowerFloor; + floor->crush = true; ok = 1; break; } -- cgit v1.2.3