summaryrefslogtreecommitdiff
path: root/src/strife
diff options
context:
space:
mode:
Diffstat (limited to 'src/strife')
-rw-r--r--src/strife/p_enemy.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/strife/p_enemy.c b/src/strife/p_enemy.c
index 79e6ffb8..c7104a75 100644
--- a/src/strife/p_enemy.c
+++ b/src/strife/p_enemy.c
@@ -803,9 +803,17 @@ P_LookForPlayers
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;