shithub: choc

Download patch

ref: d6693cc9e17fdbee7033e47b7b8da249da118d8f
parent: c31392111bbb81043b70531264f0e06f51b174cd
author: Simon Howard <[email protected]>
date: Wed Oct 19 19:26:23 EDT 2011

Fix lockups in Hexen and Strife when playing with more than four
players.

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

--- a/src/hexen/p_enemy.c
+++ b/src/hexen/p_enemy.c
@@ -539,8 +539,16 @@
     }
     sector = actor->subsector->sector;
     c = 0;
-    stop = (actor->lastlook - 1) & 3;
-    for (;; actor->lastlook = (actor->lastlook + 1) & 3)
+
+    // NOTE: This behavior has been changed from the Vanilla behavior, where
+    // an infinite loop can occur if players 0-3 all quit the game. Although
+    // technically this is not what Vanilla does, fixing this is highly
+    // desirable, and having the game simply lock up is not acceptable.
+    // stop = (actor->lastlook - 1) & 3;
+    // for (;; actor->lastlook = (actor->lastlook + 1) & 3)
+
+    stop = (actor->lastlook + MAXPLAYERS - 1) % MAXPLAYERS;
+    for (;; actor->lastlook = (actor->lastlook + 1) % MAXPLAYERS)
     {
         if (!playeringame[actor->lastlook])
             continue;
--- a/src/strife/p_enemy.c
+++ b/src/strife/p_enemy.c
@@ -803,9 +803,17 @@
     sector = actor->subsector->sector;
 
     c = 0;
-    stop = (actor->lastlook-1)&3;
 
-    for ( ; ; actor->lastlook = (actor->lastlook+1)&3 )
+    // NOTE: This behavior has been changed from the Vanilla behavior, where
+    // an infinite loop can occur if players 0-3 all quit the game. Although
+    // technically this is not what Vanilla does, fixing this is highly
+    // desirable, and having the game simply lock up is not acceptable.
+    // stop = (actor->lastlook - 1) & 3;
+    // for (;; actor->lastlook = (actor->lastlook + 1) & 3)
+
+    stop = (actor->lastlook + MAXPLAYERS - 1) % MAXPLAYERS;
+
+    for ( ; ; actor->lastlook = (actor->lastlook + 1) % MAXPLAYERS)
     {
         if (!playeringame[actor->lastlook])
             continue;