summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/sv_ents.c2
-rw-r--r--src/sv_init.c6
-rw-r--r--src/sv_main.c24
-rw-r--r--src/sv_send.c8
-rw-r--r--src/sv_user.c4
-rw-r--r--src/sv_world.c16
6 files changed, 23 insertions, 37 deletions
diff --git a/src/sv_ents.c b/src/sv_ents.c
index 498c531..1f71b23 100644
--- a/src/sv_ents.c
+++ b/src/sv_ents.c
@@ -143,7 +143,7 @@ static client_frame_t *get_last_frame( client_t *client ) {
client->frames_nodelta = 0;
- if( client->framenum - client->lastframe > UPDATE_BACKUP - 1 ) {
+ if( client->framenum - client->lastframe >= UPDATE_BACKUP ) {
// client hasn't gotten a good message through in a long time
Com_DPrintf( "%s: delta request from out-of-date packet.\n", client->name );
return NULL;
diff --git a/src/sv_init.c b/src/sv_init.c
index dd98b58..bb1e466 100644
--- a/src/sv_init.c
+++ b/src/sv_init.c
@@ -30,7 +30,7 @@ void SV_ClientReset( client_t *client ) {
// any partially connected client will be restarted
client->state = cs_connected;
- client->framenum = 0;
+ client->framenum = 1; // frame 0 can't be used
client->lastframe = -1;
client->frames_nodelta = 0;
client->send_delta = 0;
@@ -223,8 +223,8 @@ void SV_SpawnServer( cm_t *cm, const char *server, const char *spawnpoint ) {
sv.entitystring : cm->cache->entitystring, spawnpoint );
// run two frames to allow everything to settle
- sv.framenum++; ge->RunFrame ();
- sv.framenum++; ge->RunFrame ();
+ ge->RunFrame (); sv.framenum++;
+ ge->RunFrame (); sv.framenum++;
X86_POP_FPCW;
diff --git a/src/sv_main.c b/src/sv_main.c
index a7c7f80..e944720 100644
--- a/src/sv_main.c
+++ b/src/sv_main.c
@@ -977,6 +977,7 @@ static void SVC_DirectConnect( void ) {
Com_DPrintf( "Going from cs_free to cs_assigned for %s\n", newcl->name );
newcl->state = cs_assigned;
+ newcl->framenum = 1; // frame 0 can't be used
newcl->lastframe = -1;
newcl->lastmessage = svs.realtime; // don't timeout
newcl->min_ping = 9999;
@@ -1121,7 +1122,7 @@ static int ping_min( client_t *cl ) {
int i, j, count = INT_MAX;
for( i = 0; i < UPDATE_BACKUP; i++ ) {
- j = cl->framenum - i;
+ j = cl->framenum - i - 1;
frame = &cl->frames[j & UPDATE_MASK];
if( frame->number != j )
continue;
@@ -1139,7 +1140,7 @@ static int ping_avg( client_t *cl ) {
int i, j, total = 0, count = 0;
for( i = 0; i < UPDATE_BACKUP; i++ ) {
- j = cl->framenum - i;
+ j = cl->framenum - i - 1;
frame = &cl->frames[j & UPDATE_MASK];
if( frame->number != j )
continue;
@@ -1453,8 +1454,9 @@ static void SV_PrepWorldFrame( void ) {
}
}
-#if USE_CLIENT
+// pause if there is only local client on the server
static inline qboolean check_paused( void ) {
+#if USE_CLIENT
if( dedicated->integer )
goto resume;
@@ -1484,10 +1486,10 @@ resume:
Cvar_Set( "sv_paused", "0" );
IN_Activate();
}
+#endif
return qfalse;
}
-#endif
/*
=================
@@ -1495,15 +1497,6 @@ SV_RunGameFrame
=================
*/
static void SV_RunGameFrame( void ) {
-#if USE_CLIENT
- // pause if there is only local client on the server
- if( check_paused() )
- return;
-#endif
-
- // bump framenum in sync with game
- sv.framenum++;
-
#if USE_MVD_SERVER
// save the entire world state if recording a serverdemo
SV_MvdBeginFrame();
@@ -1658,7 +1651,7 @@ unsigned SV_Frame( unsigned msec ) {
return SV_FRAMETIME - sv.frameresidual;
}
- if( svs.initialized ) {
+ if( svs.initialized && !check_paused() ) {
// check timeouts
SV_CheckTimeouts();
@@ -1679,6 +1672,9 @@ unsigned SV_Frame( unsigned msec ) {
// clear teleport flags, etc for next frame
SV_PrepWorldFrame();
+
+ // advance for next frame
+ sv.framenum++;
}
if( Com_IsDedicated() ) {
diff --git a/src/sv_send.c b/src/sv_send.c
index d1f3fd1..973ed79 100644
--- a/src/sv_send.c
+++ b/src/sv_send.c
@@ -801,14 +801,9 @@ void SV_SendClientMessages( void ) {
if( client->state != cs_spawned || client->download || client->nodata )
goto finish;
- if( SV_PAUSED )
- continue;
-
if( !SV_CLIENTSYNC( client ) )
continue;
- client->framenum++;
-
#if (defined _DEBUG) && USE_FPS
if( developer->integer )
check_key_sync( client );
@@ -839,6 +834,9 @@ void SV_SendClientMessages( void ) {
}
}
+ // advance for next frame
+ client->framenum++;
+
finish:
// clear all unreliable messages still left
finish_frame( client );
diff --git a/src/sv_user.c b/src/sv_user.c
index c19a919..4e25b9e 100644
--- a/src/sv_user.c
+++ b/src/sv_user.c
@@ -1018,13 +1018,13 @@ static void SV_SetLastFrame( int lastframe ) {
client_frame_t *frame;
if( lastframe > 0 ) {
- if( lastframe > sv_client->framenum )
+ if( lastframe >= sv_client->framenum )
return; // ignore invalid acks
if( lastframe <= sv_client->lastframe )
return; // ignore duplicate acks
- if( sv_client->framenum - lastframe < UPDATE_BACKUP ) {
+ if( sv_client->framenum - lastframe <= UPDATE_BACKUP ) {
frame = &sv_client->frames[lastframe & UPDATE_MASK];
if( frame->number == lastframe ) {
diff --git a/src/sv_world.c b/src/sv_world.c
index f5b12a2..9f7e767 100644
--- a/src/sv_world.c
+++ b/src/sv_world.c
@@ -250,7 +250,7 @@ void PF_LinkEdict (edict_t *ent) {
server_entity_t *sent;
int entnum;
#if USE_FPS
- int i, framenum;
+ int i;
#endif
if (ent->area.prev)
@@ -294,29 +294,21 @@ void PF_LinkEdict (edict_t *ent) {
SV_LinkEdict( &sv.cm, ent );
-#if USE_FPS
- // if sv_player is not NULL, we are called from ClientThink
- // sv.framenum hasn't been advanced for next frame yet, so do it here
- framenum = sv.framenum;
- if( sv_player )
- framenum++;
-#endif
-
// if first time, make sure old_origin is valid
if (!ent->linkcount) {
VectorCopy (ent->s.origin, ent->s.old_origin);
#if USE_FPS
VectorCopy( ent->s.origin, sent->create_origin );
- sent->create_framenum = framenum;
+ sent->create_framenum = sv.framenum;
#endif
}
ent->linkcount++;
#if USE_FPS
// save origin for later recovery
- i = framenum & ENT_HISTORY_MASK;
+ i = sv.framenum & ENT_HISTORY_MASK;
VectorCopy( ent->s.origin, sent->history[i].origin );
- sent->history[i].framenum = framenum;
+ sent->history[i].framenum = sv.framenum;
#endif
if (ent->solid == SOLID_NOT)