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/strife/p_enemy.c | 4 ++-- src/strife/p_inter.c | 10 ++++++---- src/strife/p_map.c | 2 +- src/strife/p_maputl.c | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src/strife') diff --git a/src/strife/p_enemy.c b/src/strife/p_enemy.c index 8aad08fc..e358e616 100644 --- a/src/strife/p_enemy.c +++ b/src/strife/p_enemy.c @@ -891,7 +891,7 @@ void A_Look (mobj_t* actor) // as a parameter to control allaround look behavior. Did they just run out of // flags, or what? // STRIFE-TODO: Needs serious verification. - if (!P_LookForPlayers (actor, actor->flags & MF_GIVEQUEST) ) + if (!P_LookForPlayers(actor, (actor->flags & MF_GIVEQUEST) != 0)) return; // go into chase state @@ -975,7 +975,7 @@ void A_FriendLook(mobj_t* actor) gamemap != 3 && gamemap != 34) { // STRIFE-TODO: Needs serious verification. - if(P_LookForPlayers(actor, actor->flags & MF_GIVEQUEST)) + if(P_LookForPlayers(actor, (actor->flags & MF_GIVEQUEST) != 0)) { P_SetMobjState(actor, actor->info->seestate); actor->flags |= MF_NODIALOG; diff --git a/src/strife/p_inter.c b/src/strife/p_inter.c index 71db6fe1..f2e16efb 100644 --- a/src/strife/p_inter.c +++ b/src/strife/p_inter.c @@ -537,7 +537,7 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) // rifle case SPR_RIFL: - if(!P_GiveWeapon(player, wp_rifle, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_rifle, (special->flags & MF_DROPPED) != 0)) return; sound = sfx_wpnup; // haleyjd: SHK-CHK! break; @@ -560,7 +560,8 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) // grenade launcher case SPR_GRND: - if(!P_GiveWeapon(player, wp_hegrenade, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_hegrenade, + (special->flags & MF_DROPPED) != 0)) return; sound = sfx_wpnup; // haleyjd: SHK-CHK! break; @@ -574,14 +575,15 @@ void P_TouchSpecialThing(mobj_t* special, mobj_t* toucher) // electric bolt crossbow case SPR_CBOW: - if(!P_GiveWeapon(player, wp_elecbow, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_elecbow, + (special->flags & MF_DROPPED) != 0)) return; sound = sfx_wpnup; // haleyjd: SHK-CHK! break; // haleyjd 09/21/10: missed case: THE SIGIL! case SPR_SIGL: - if(!P_GiveWeapon(player, wp_sigil, special->flags & MF_DROPPED)) + if(!P_GiveWeapon(player, wp_sigil, (special->flags & MF_DROPPED) != 0)) { player->sigiltype = special->frame; return; diff --git a/src/strife/p_map.c b/src/strife/p_map.c index 13a1bb54..03b57edd 100644 --- a/src/strife/p_map.c +++ b/src/strife/p_map.c @@ -384,7 +384,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 (tmthing->player) // villsa [STRIFE] no longer checks MF_PICKUP flag { // can remove thing diff --git a/src/strife/p_maputl.c b/src/strife/p_maputl.c index 4ecb5566..f1773858 100644 --- a/src/strife/p_maputl.c +++ b/src/strife/p_maputl.c @@ -941,7 +941,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/strife/d_main.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/strife') diff --git a/src/strife/d_main.c b/src/strife/d_main.c index 5cc8be5e..35d2c908 100644 --- a/src/strife/d_main.c +++ b/src/strife/d_main.c @@ -431,21 +431,22 @@ void D_BindVariables(void) // * screenblocks -> screensize // * Added nickname, comport - M_BindVariable("mouse_sensitivity", &mouseSensitivity); - M_BindVariable("sfx_volume", &sfxVolume); - M_BindVariable("music_volume", &musicVolume); - M_BindVariable("voice_volume", &voiceVolume); - M_BindVariable("show_talk", &dialogshowtext); - M_BindVariable("screensize", &screenblocks); - 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_BindVariable("back_flat", &back_flat); - M_BindVariable("graphical_startup", &graphical_startup); - - M_BindVariable("nickname", &nickname); - M_BindVariable("comport", &comport); + M_BindIntVariable("mouse_sensitivity", &mouseSensitivity); + M_BindIntVariable("sfx_volume", &sfxVolume); + M_BindIntVariable("music_volume", &musicVolume); + M_BindIntVariable("voice_volume", &voiceVolume); + M_BindIntVariable("show_talk", &dialogshowtext); + M_BindIntVariable("screensize", &screenblocks); + 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); + M_BindIntVariable("graphical_startup", &graphical_startup); + + M_BindStringVariable("back_flat", &back_flat); + M_BindStringVariable("nickname", &nickname); + + M_BindIntVariable("comport", &comport); // Multiplayer chat macros @@ -454,7 +455,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 5160ceb4512b8bb5839df898a4aff0c6779578c5 Mon Sep 17 00:00:00 2001 From: James Haley Date: Fri, 20 Feb 2015 20:01:02 -0600 Subject: Strife sound priority fix The Strife binary has another priority check in the first loop inside S_GetChannel. TODO: Does DOS Doom have this as well? Find out. Resolves issue #506. --- src/strife/s_sound.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/strife') diff --git a/src/strife/s_sound.c b/src/strife/s_sound.c index 7a919737..d22f84e4 100644 --- a/src/strife/s_sound.c +++ b/src/strife/s_sound.c @@ -277,7 +277,7 @@ static int S_GetChannel(mobj_t *origin, sfxinfo_t *sfxinfo, boolean isvoice) channel_t* c; // Find an open channel - for (cnum=0 ; cnumpriority > channels[cnum].sfxinfo->priority) + return -1; + S_StopChannel(cnum); break; } -- cgit v1.2.3