Skip to content

Commit 29ccc4e

Browse files
committed
cmod: Prevent vanilla clients loading map twice when downloads complete
1 parent 1d8aff6 commit 29ccc4e

2 files changed

Lines changed: 38 additions & 0 deletions

File tree

code/eliteforce/stef_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@
125125
// Significantly simplifies code and fixes some potential issues involving UDP downloads.
126126
#define STEF_REWORK_GAMESTATE_RETRANSMIT
127127

128+
// [TWEAK] Avoid 1.20 clients loading the map twice when downloads complete.
129+
#if defined( STEF_REWORK_GAMESTATE_RETRANSMIT )
130+
#define STEF_UDP_DOWNLOAD_NO_DOUBLE_LOAD
131+
#endif
132+
128133
// [BUGFIX] Workaround to allow certain older ioEF versions (e.g. 1.37) to successfully
129134
// negotiate protocol version and connect to the server.
130135
#define STEF_PROTOCOL_MSG_FIX

code/server/sv_client.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,13 @@ static void SV_SendClientGameState( client_t *client ) {
10791079

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

1082+
#ifdef STEF_UDP_DOWNLOAD_NO_DOUBLE_LOAD
1083+
if ( client->state < CS_PRIMED ) {
1084+
// clear old cs change log to avoid unnecessary retransmits
1085+
Com_Memset( client->csUpdated, 0, sizeof( client->csUpdated ) );
1086+
}
1087+
#endif
1088+
10821089
SV_PrintClientStateChange( client, CS_PRIMED );
10831090

10841091
client->state = CS_PRIMED;
@@ -1340,6 +1347,20 @@ static void SV_DoneDownload_f( client_t *cl ) {
13401347

13411348
Com_DPrintf( "clientDownload: %s Done\n", cl->name );
13421349

1350+
#ifdef STEF_UDP_DOWNLOAD_NO_DOUBLE_LOAD
1351+
if ( cl->compat && cl->state == CS_PRIMED ) {
1352+
// Vanilla client will load map based on the pre-download gamestate, so a new one is
1353+
// unnecessary and would cause double loading. Note that it's also possible for ioEF
1354+
// clients to use protocol 24 and get cl->compat, but in this case the drop check
1355+
// should should handle sending the gamestate after a short delay.
1356+
cl->downloading = qfalse;
1357+
1358+
// Don't immediately trip dropped download gamestate checks in SV_ExecuteClientMessage
1359+
cl->gamestateMessageNum = cl->messageAcknowledge - 1;
1360+
return;
1361+
}
1362+
#endif
1363+
13431364
// resend the game state to update any clients that entered during the download
13441365
SV_SendClientGameState( cl );
13451366
}
@@ -1394,8 +1415,20 @@ static void SV_BeginDownload_f( client_t *cl ) {
13941415
// the file itself
13951416
Q_strncpyz( cl->downloadName, Cmd_Argv(1), sizeof(cl->downloadName) );
13961417

1418+
#ifdef STEF_UDP_DOWNLOAD_NO_DOUBLE_LOAD
1419+
if ( cl->compat ) {
1420+
// Vanilla clients will try to load map based on the pre-download gamestate,
1421+
// so we need to track configstring updates during the download
1422+
SV_PrintClientStateChange( cl, CS_PRIMED );
1423+
cl->state = CS_PRIMED;
1424+
} else {
1425+
SV_PrintClientStateChange( cl, CS_CONNECTED );
1426+
cl->state = CS_CONNECTED;
1427+
}
1428+
#else
13971429
SV_PrintClientStateChange( cl, CS_CONNECTED );
13981430
cl->state = CS_CONNECTED;
1431+
#endif
13991432
cl->gentity = NULL;
14001433

14011434
cl->downloading = qtrue;

0 commit comments

Comments
 (0)