diff --git a/code/server/server.h b/code/server/server.h index 3762c81d..e03609ee 100644 --- a/code/server/server.h +++ b/code/server/server.h @@ -401,7 +401,7 @@ void SV_SendMessageToClient( msg_t *msg, client_t *client ); void SV_SendClientMessages( void ); void SV_SendClientSnapshot( client_t *client ); #ifdef ELITEFORCE -void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ); +void SV_WriteDummySnapshotToClient( client_t *client, msg_t *msg ); #endif // diff --git a/code/server/sv_client.c b/code/server/sv_client.c index ed486837..0f403b01 100644 --- a/code/server/sv_client.c +++ b/code/server/sv_client.c @@ -1242,6 +1242,7 @@ int SV_SendDownloadMessages(void) { MSG_InitOOB(&msg, msgBuffer, sizeof(msgBuffer)); msg.compat = qtrue; + SV_WriteDummySnapshotToClient(cl, &msg); } else #endif @@ -1255,12 +1256,7 @@ int SV_SendDownloadMessages(void) if(retval) { #ifdef ELITEFORCE - if(msg.compat) - { - // compat clients need svc_snapshot to update reliableAcknowledge - SV_WriteSnapshotToClient(cl, &msg); - } - else + if(!msg.compat) #endif MSG_WriteByte(&msg, svc_EOF); SV_Netchan_Transmit(cl, &msg); diff --git a/code/server/sv_snapshot.c b/code/server/sv_snapshot.c index f0335373..4e073ac2 100644 --- a/code/server/sv_snapshot.c +++ b/code/server/sv_snapshot.c @@ -119,10 +119,7 @@ static void SV_EmitPacketEntities( clientSnapshot_t *from, clientSnapshot_t *to, SV_WriteSnapshotToClient ================== */ -#ifndef ELITEFORCE -static -#endif -void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ) { +static void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ) { clientSnapshot_t *frame, *oldframe; int lastframe; int i; @@ -216,6 +213,66 @@ void SV_WriteSnapshotToClient( client_t *client, msg_t *msg ) { } +#ifdef ELITEFORCE +/* +================== +SV_WriteDummySnapshotToClient + +While a client downloads a pk3 using the legacy protocol they need +a snapshot to update the reliableAcknowledge. This dummy snapshot +does not include areabits, entities, or player state updates. +================== +*/ +void SV_WriteDummySnapshotToClient( client_t *client, msg_t *msg ) { + int snapFlags; + playerState_t ps; + + MSG_WriteByte (msg, svc_snapshot); + + // NOTE, MRE: now sent at the start of every message from server to client + // let the client know which reliable clientCommands we have received + #ifdef ELITEFORCE + if(msg->compat) + MSG_WriteLong( msg, client->lastClientCommand ); + #else + //MSG_WriteLong( msg, client->lastClientCommand ); + #endif + + // send over the current server time so the client can drift + // its view of time to try to match + if( client->oldServerTime ) { + MSG_WriteLong (msg, sv.time + client->oldServerTime); + } else { + MSG_WriteLong (msg, sv.time); + } + + // what we are delta'ing from + MSG_WriteByte (msg, 0); + + snapFlags = svs.snapFlagServerBit; + if ( client->rateDelayed ) { + snapFlags |= SNAPFLAG_RATE_DELAYED; + } + if ( client->state != CS_ACTIVE ) { + snapFlags |= SNAPFLAG_NOT_ACTIVE; + } + + MSG_WriteByte (msg, snapFlags); + + // send over the areabits + MSG_WriteByte (msg, 0); + MSG_WriteData (msg, NULL, 0); + + // delta encode the playerstate + Com_Memset (&ps, 0, sizeof(ps)); + MSG_WriteDeltaPlayerstate( msg, &ps, &ps ); + + // delta encode the entities + MSG_WriteBits( msg, (MAX_GENTITIES-1), GENTITYNUM_BITS ); +} +#endif + + /* ================== SV_UpdateServerCommandsToClient