diff options
author | Simon Howard | 2007-08-09 00:04:03 +0000 |
---|---|---|
committer | Simon Howard | 2007-08-09 00:04:03 +0000 |
commit | f0c7aa035a81c84e26edd0cd9aafd13f00e0a2fe (patch) | |
tree | 3089afec3d9a21dbc9bc0237fed133f5af208f9e /src | |
parent | 7e59c3bc40bf8c3ffdd5d43978160feb643d71d2 (diff) | |
download | chocolate-doom-f0c7aa035a81c84e26edd0cd9aafd13f00e0a2fe.tar.gz chocolate-doom-f0c7aa035a81c84e26edd0cd9aafd13f00e0a2fe.tar.bz2 chocolate-doom-f0c7aa035a81c84e26edd0cd9aafd13f00e0a2fe.zip |
Don't crash when all players have quit.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 955
Diffstat (limited to 'src')
-rw-r--r-- | src/am_map.c | 12 | ||||
-rw-r--r-- | src/d_net.c | 32 |
2 files changed, 39 insertions, 5 deletions
diff --git a/src/am_map.c b/src/am_map.c index 347d592f..cad46a70 100644 --- a/src/am_map.c +++ b/src/am_map.c @@ -472,13 +472,21 @@ void AM_initVariables(void) m_w = FTOM(f_w); m_h = FTOM(f_h); + plr = &players[0]; + // find player to center on initially if (!playeringame[pnum = consoleplayer]) + { for (pnum=0;pnum<MAXPLAYERS;pnum++) + { if (playeringame[pnum]) + { + plr = &players[pnum]; break; - - plr = &players[pnum]; + } + } + } + m_x = plr->mo->x - m_w/2; m_y = plr->mo->y - m_h/2; AM_changeWindowLoc(); diff --git a/src/d_net.c b/src/d_net.c index b8ecd645..4e87a813 100644 --- a/src/d_net.c +++ b/src/d_net.c @@ -207,7 +207,6 @@ void NetUpdate (void) } #endif - netcmds[consoleplayer][maketic % BACKUPTICS] = cmd; ++maketic; @@ -408,6 +407,23 @@ void D_QuitNetGame (void) } +// Returns true if there are currently any players in the game. + +static boolean PlayersInGame(void) +{ + int i; + + for (i=0; i<MAXPLAYERS; ++i) + { + if (playeringame[i]) + { + return true; + } + } + + return false; +} + static int GetLowTic(void) { int i; @@ -454,7 +470,7 @@ void TryRunTics (void) int realtics; int availabletics; int counts; - + // get real tics entertic = I_GetTime() / ticdup; realtics = entertic - oldentertics; @@ -539,7 +555,8 @@ void TryRunTics (void) counts = 1; // wait for new tics if needed - while (lowtic < gametic/ticdup + counts) + + while (!PlayersInGame() || lowtic < gametic/ticdup + counts) { NetUpdate (); @@ -564,6 +581,14 @@ void TryRunTics (void) { for (i=0 ; i<ticdup ; i++) { + // check that there are players in the game. if not, we cannot + // run a tic. + + if (!PlayersInGame()) + { + return; + } + if (gametic/ticdup > lowtic) I_Error ("gametic>lowtic"); if (advancedemo) @@ -592,3 +617,4 @@ void TryRunTics (void) NetUpdate (); // check for new console commands } } + |