shithub: choc

Download patch

ref: 1ec21c92ed4c3f792e642524c5cd5bc30b6d7457
parent: d64626ff417323e05a479caeee02168c1eafd798
author: Simon Howard <[email protected]>
date: Sun Oct 23 09:29:09 EDT 2011

Fix compiler warnings (thanks Edward-San).

Subversion-branch: /branches/v2-branch
Subversion-revision: 2459

--- a/src/heretic/mn_menu.c
+++ b/src/heretic/mn_menu.c
@@ -145,7 +145,7 @@
 static boolean soundchanged;
 
 boolean askforquit;
-boolean typeofask;
+static int typeofask;
 static boolean FileMenuKeySteal;
 static boolean slottextloaded;
 static char SlotText[6][SLOTTEXTLEN + 2];
--- a/src/heretic/p_spec.c
+++ b/src/heretic/p_spec.c
@@ -1065,8 +1065,12 @@
         s2 = getNextSector(s1->lines[0], s1);
         for (i = 0; i < s2->linecount; i++)
         {
-            if ((!s2->lines[i]->flags & ML_TWOSIDED) ||
-                (s2->lines[i]->backsector == s1))
+            // Note: This was originally part of the following test:
+            //   (!s2->lines[i]->flags & ML_TWOSIDED) ||
+            // Due to the apparent mistaken formatting, this can never be
+            // true.
+
+            if (s2->lines[i]->backsector == s1)
                 continue;
             s3 = s2->lines[i]->backsector;
 
--- a/src/hexen/mn_menu.c
+++ b/src/hexen/mn_menu.c
@@ -153,7 +153,7 @@
 static boolean soundchanged;
 
 boolean askforquit;
-boolean typeofask;
+static int typeofask;
 static boolean FileMenuKeySteal;
 static boolean slottextloaded;
 static char SlotText[6][SLOTTEXTLEN + 2];
--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -1135,7 +1135,7 @@
     {
         // Turn
         if (P_Random() & 1)
-            actor->movedir = (++actor->movedir) % 8;
+            actor->movedir = (actor->movedir + 1) % 8;
         else
             actor->movedir = (actor->movedir + 7) % 8;
         FaceMovementDirection(actor);
--- a/src/hexen/sb_bar.c
+++ b/src/hexen/sb_bar.c
@@ -1798,10 +1798,20 @@
     {
         return;
     }
-    for (i = 1; i < 8; i++)
+    for (i = 1; i < NUMWEAPONS; i++)
     {
         player->weaponowned[i] = false;
     }
+
+    // In the original code, NUMWEAPONS was 8. So the writes to weaponowned
+    // overflowed the array. We must set the following fields to zero as
+    // well:
+
+    player->mana[0] = 0;
+    player->mana[1] = 0;
+    player->attackdown = 0;
+    player->usedown = 0;
+
     player->pendingweapon = WP_FIRST;
     P_SetMessage(player, TXT_CHEATIDKFA, true);
 }
--- a/src/net_structrw.c
+++ b/src/net_structrw.c
@@ -475,7 +475,7 @@
      || !NET_ReadInt8(packet, (unsigned int *) &data->num_drones)
      || !NET_ReadInt8(packet, (unsigned int *) &data->max_players)
      || !NET_ReadInt8(packet, (unsigned int *) &data->is_controller)
-     || !NET_ReadSInt8(packet, (unsigned int *) &data->consoleplayer))
+     || !NET_ReadSInt8(packet, &data->consoleplayer))
     {
         return false;
     }