shithub: choc

Download patch

ref: 1f5ce047ad6cb709f746b794b4a2dea9e2f89fb6
parent: 714d7a29397b44fcb2b1fef2d675d296cb984264
author: Simon Howard <[email protected]>
date: Thu Feb 19 19:03:15 EST 2015

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.

--- a/src/doom/p_inter.c
+++ b/src/doom/p_inter.c
@@ -603,8 +603,9 @@
 	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 @@
 	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;
--- a/src/doom/p_map.c
+++ b/src/doom/p_map.c
@@ -357,7 +357,7 @@
     // 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
--- a/src/doom/p_maputl.c
+++ b/src/doom/p_maputl.c
@@ -887,7 +887,7 @@
 
     int		count;
 		
-    earlyout = flags & PT_EARLYOUT;
+    earlyout = (flags & PT_EARLYOUT) != 0;
 		
     validcount++;
     intercept_p = intercepts;
--- a/src/heretic/p_map.c
+++ b/src/heretic/p_map.c
@@ -428,7 +428,7 @@
     // Check for special thing
     if (thing->flags & MF_SPECIAL)
     {
-        solid = thing->flags & MF_SOLID;
+        solid = (thing->flags & MF_SOLID) != 0;
         if (tmflags & MF_PICKUP)
         {                       // Can be picked up by tmthing
             P_TouchSpecialThing(thing, tmthing);        // Can remove thing
--- a/src/heretic/p_maputl.c
+++ b/src/heretic/p_maputl.c
@@ -667,7 +667,7 @@
     int mapx, mapy, mapxstep, mapystep;
     int count;
 
-    earlyout = flags & PT_EARLYOUT;
+    earlyout = (flags & PT_EARLYOUT) != 0;
 
     validcount++;
     intercept_p = intercepts;
--- a/src/hexen/p_map.c
+++ b/src/hexen/p_map.c
@@ -661,7 +661,7 @@
     // Check for special thing
     if (thing->flags & MF_SPECIAL)
     {
-        solid = thing->flags & MF_SOLID;
+        solid = (thing->flags & MF_SOLID) != 0;
         if (tmflags & MF_PICKUP)
         {                       // Can be picked up by tmthing
             P_TouchSpecialThing(thing, tmthing);        // Can remove thing
--- a/src/hexen/p_maputl.c
+++ b/src/hexen/p_maputl.c
@@ -699,7 +699,7 @@
     int mapx, mapy, mapxstep, mapystep;
     int count;
 
-    earlyout = flags & PT_EARLYOUT;
+    earlyout = (flags & PT_EARLYOUT) != 0;
 
     validcount++;
     intercept_p = intercepts;
--- a/src/hexen/p_spec.c
+++ b/src/hexen/p_spec.c
@@ -864,7 +864,7 @@
         if (line->flags & ML_SECRET)
             return false;       // never open secret doors
     }
-    repeat = line->flags & ML_REPEAT_SPECIAL;
+    repeat = (line->flags & ML_REPEAT_SPECIAL) != 0;
     buttonSuccess = false;
 
     // Construct args[] array to contain the arguments from the line, as we
--- a/src/strife/p_enemy.c
+++ b/src/strife/p_enemy.c
@@ -891,7 +891,7 @@
     // 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 @@
             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;
--- a/src/strife/p_inter.c
+++ b/src/strife/p_inter.c
@@ -537,7 +537,7 @@
 
     // 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 @@
 
     // 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,7 +575,8 @@
 
     // 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;
@@ -581,7 +583,7 @@
 
     // 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;
--- a/src/strife/p_map.c
+++ b/src/strife/p_map.c
@@ -384,7 +384,7 @@
     // 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
--- a/src/strife/p_maputl.c
+++ b/src/strife/p_maputl.c
@@ -941,7 +941,7 @@
 
     int     count;
 
-    earlyout = flags & PT_EARLYOUT;
+    earlyout = (flags & PT_EARLYOUT) != 0;
 
     validcount++;
     intercept_p = intercepts;