Skip to content
This repository was archived by the owner on Dec 8, 2018. It is now read-only.

Commit 10925c8

Browse files
author
zakk
committed
Patch from Tim Angus, to fix a longstanding bug
in the server, wherein running the server for more than 24 hours would cause the game to exhibit weirdness as described here: http://forums.wireheadstudios.org/index.php?act=ST&f=11&t=2749 That page would also indicate that more work needs to be done if the map isn't going to change for more than 24 hours. git-svn-id: svn://svn.icculus.org/quake3/trunk@91 edf5b092-35ff-0310-97b2-ce42778d08ea
1 parent 468c8b3 commit 10925c8

File tree

6 files changed

+21
-13
lines changed

6 files changed

+21
-13
lines changed

code/server/server.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef struct {
7878
int gameClientSize; // will be > sizeof(playerState_t) due to game private data
7979

8080
int restartTime;
81+
int time;
8182
} server_t;
8283

8384

code/server/sv_ccmds.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,10 @@ static void SV_MapRestart_f( void ) {
272272
SV_RestartGameProgs();
273273

274274
// run a few frames to allow everything to settle
275-
for ( i = 0 ;i < 3 ; i++ ) {
276-
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
275+
for (i = 0; i < 3; i++)
276+
{
277+
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
278+
sv.time += 100;
277279
svs.time += 100;
278280
}
279281

@@ -314,7 +316,8 @@ static void SV_MapRestart_f( void ) {
314316
}
315317

316318
// run another frame to allow things to look at all the players
317-
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
319+
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
320+
sv.time += 100;
318321
svs.time += 100;
319322
}
320323

code/server/sv_game.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ static void SV_InitGameVM( qboolean restart ) {
898898

899899
// use the current msec count for a random seed
900900
// init for this gamestate
901-
VM_Call( gvm, GAME_INIT, svs.time, Com_Milliseconds(), restart );
901+
VM_Call (gvm, GAME_INIT, sv.time, Com_Milliseconds(), restart);
902902
}
903903

904904

code/server/sv_init.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,9 +438,11 @@ void SV_SpawnServer( char *server, qboolean killBots ) {
438438
sv_gametype->modified = qfalse;
439439

440440
// run a few frames to allow everything to settle
441-
for ( i = 0 ;i < 3 ; i++ ) {
442-
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
443-
SV_BotFrame( svs.time );
441+
for (i = 0;i < 3; i++)
442+
{
443+
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
444+
SV_BotFrame (sv.time);
445+
sv.time += 100;
444446
svs.time += 100;
445447
}
446448

@@ -495,8 +497,9 @@ void SV_SpawnServer( char *server, qboolean killBots ) {
495497
}
496498

497499
// run another frame to allow things to look at all the players
498-
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
499-
SV_BotFrame( svs.time );
500+
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
501+
SV_BotFrame (sv.time);
502+
sv.time += 100;
500503
svs.time += 100;
501504

502505
if ( sv_pure->integer ) {

code/server/sv_main.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ void SV_Frame( int msec ) {
785785

786786
sv.timeResidual += msec;
787787

788-
if (!com_dedicated->integer) SV_BotFrame( svs.time + sv.timeResidual );
788+
if (!com_dedicated->integer) SV_BotFrame (sv.time + sv.timeResidual);
789789

790790
if ( com_dedicated->integer && sv.timeResidual < frameMsec ) {
791791
// NET_Sleep will give the OS time slices until either get a packet
@@ -835,15 +835,16 @@ void SV_Frame( int msec ) {
835835
// update ping based on the all received frames
836836
SV_CalcPings();
837837

838-
if (com_dedicated->integer) SV_BotFrame( svs.time );
838+
if (com_dedicated->integer) SV_BotFrame (sv.time);
839839

840840
// run the game simulation in chunks
841841
while ( sv.timeResidual >= frameMsec ) {
842842
sv.timeResidual -= frameMsec;
843843
svs.time += frameMsec;
844+
sv.time += frameMsec;
844845

845846
// let everything in the world think and move
846-
VM_Call( gvm, GAME_RUN_FRAME, svs.time );
847+
VM_Call (gvm, GAME_RUN_FRAME, sv.time);
847848
}
848849

849850
if ( com_speeds->integer ) {

code/server/sv_snapshot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ static void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ) {
160160

161161
// send over the current server time so the client can drift
162162
// its view of time to try to match
163-
MSG_WriteLong (msg, svs.time);
163+
MSG_WriteLong (msg, sv.time);
164164

165165
// what we are delta'ing from
166166
MSG_WriteByte (msg, lastframe);

0 commit comments

Comments
 (0)