Skip to content

Commit

Permalink
server: optimize certain gamestate acknowledge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ec- committed Aug 27, 2024
1 parent f5122f4 commit e4d7d3a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 13 deletions.
6 changes: 3 additions & 3 deletions code/client/cl_curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -748,8 +748,8 @@ static int Com_DL_CallbackProgress( void *data, double dltotal, double dlnow, do
Com_Printf( "%s: aborted\n", dl->Name );
return -1;
}
Cvar_Set( "cl_downloadSize", va( "%i", dl->Size ) );
Cvar_Set( "cl_downloadCount", va( "%i", dl->Count ) );
Cvar_SetIntegerValue( "cl_downloadSize", dl->Size );
Cvar_SetIntegerValue( "cl_downloadCount", dl->Count );
}

if ( dl->Size ) {
Expand Down Expand Up @@ -1043,7 +1043,7 @@ qboolean Com_DL_Begin( download_t *dl, const char *localName, const char *remote
Cvar_Set( "cl_downloadName", dl->Name );
Cvar_Set( "cl_downloadSize", "0" );
Cvar_Set( "cl_downloadCount", "0" );
Cvar_Set( "cl_downloadTime", va( "%i", cls.realtime ) );
Cvar_SetIntegerValue( "cl_downloadTime", cls.realtime );
}

return qtrue;
Expand Down
2 changes: 1 addition & 1 deletion code/qcommon/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ void NORETURN FORMAT_PRINTF(2, 3) QDECL Com_Error( errorParm_t code, const char

com_errorEntered = qtrue;

Cvar_Set( "com_errorCode", va( "%i", code ) );
Cvar_SetIntegerValue( "com_errorCode", code );

// when we are running automated scripts, make sure we
// know if anything failed
Expand Down
2 changes: 1 addition & 1 deletion code/qcommon/qcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ qboolean NET_IsLocalAddress( const netadr_t *adr );
const char *NET_AdrToString( const netadr_t *a );
const char *NET_AdrToStringwPort( const netadr_t *a );
int NET_StringToAdr( const char *s, netadr_t *a, netadrtype_t family );
#ifndef DEDICATED
#ifndef DEDICATED
qboolean NET_GetLoopPacket( netsrc_t sock, netadr_t *net_from, msg_t *net_message );
#endif
#ifdef USE_IPV6
Expand Down
30 changes: 22 additions & 8 deletions code/server/sv_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,19 +1021,14 @@ static void SV_SendClientGameState( client_t *client ) {
const svEntity_t *svEnt;
msg_t msg;
byte msgBuffer[ MAX_MSGLEN_BUF ];
qboolean csUpdated;

Com_DPrintf( "SV_SendClientGameState() for %s\n", client->name );

SV_PrintClientStateChange( client, CS_PRIMED );

client->state = CS_PRIMED;

if ( client->gamestateAck == GSA_INIT ) {
client->gamestateAck = GSA_SENT_ONCE;
} else {
client->gamestateAck = GSA_SENT_MANY;
}

client->downloading = qfalse;

client->pureAuthentic = qfalse;
Expand Down Expand Up @@ -1068,6 +1063,7 @@ static void SV_SendClientGameState( client_t *client ) {
MSG_WriteLong( &msg, client->reliableSequence );

// write the configstrings
csUpdated = qfalse;
for ( start = 0 ; start < MAX_CONFIGSTRINGS ; start++ ) {
if ( *sv.configstrings[ start ] != '\0' ) {
MSG_WriteByte( &msg, svc_configstring );
Expand All @@ -1082,7 +1078,22 @@ static void SV_SendClientGameState( client_t *client ) {
MSG_WriteBigString( &msg, sv.configstrings[start] );
}
}
client->csUpdated[ start ] = qfalse;
if ( client->csUpdated[start] ) {
csUpdated = qtrue;
}
client->csUpdated[start] = qfalse;
}

if ( client->gamestateAck == GSA_INIT ) {
// inital submission, accept any messageAcknowledge with matching serverId
client->gamestateAck = GSA_SENT_ONCE;
} else {
if ( client->gamestateAck == GSA_SENT_ONCE && !csUpdated ) {
// if no configstrings being updated since last submission then assume that we're (re)sending identical gamestate
} else {
// expect exact messageAcknowledge
client->gamestateAck = GSA_SENT_MANY;
}
}

// write the baselines
Expand Down Expand Up @@ -1286,7 +1297,10 @@ static void SV_BeginDownload_f( client_t *cl ) {
cl->gentity = NULL;

cl->downloading = qtrue;
cl->gamestateAck = GSA_SENT_MANY; // expect exact messageAcknowledge next time

if ( cl->gamestateAck = GSA_ACKED ) {
cl->gamestateAck = GSA_SENT_ONCE;
}
}


Expand Down

0 comments on commit e4d7d3a

Please sign in to comment.