From d6693cc9e17fdbee7033e47b7b8da249da118d8f Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Wed, 19 Oct 2011 23:26:23 +0000 Subject: Fix lockups in Hexen and Strife when playing with more than four players. Subversion-branch: /branches/v2-branch Subversion-revision: 2444 --- src/hexen/p_enemy.c | 12 ++++++++++-- src/strife/p_enemy.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/hexen/p_enemy.c b/src/hexen/p_enemy.c index 456cc7a9..a8477b22 100644 --- a/src/hexen/p_enemy.c +++ b/src/hexen/p_enemy.c @@ -539,8 +539,16 @@ boolean P_LookForPlayers(mobj_t * actor, boolean allaround) } 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; 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; -- cgit v1.2.3