diff --git a/engine/client/cl_demo.c b/engine/client/cl_demo.c index e1c43faa..14b066c7 100644 --- a/engine/client/cl_demo.c +++ b/engine/client/cl_demo.c @@ -648,11 +648,13 @@ void CL_DemoStartPlayback( int mode ) { if( cls.changedemo ) { + int maxclients = cl.maxclients; + S_StopAllSounds( true ); SCR_BeginLoadingPlaque( false ); - CL_ClearState (); - CL_InitEdicts (); // re-arrange edicts + CL_ClearState( ); + CL_InitEdicts( maxclients ); // re-arrange edicts } else { diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index 3c0edbc2..afc229b7 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -1088,13 +1088,13 @@ void CL_ClearWorld( void ) clgame.numStatics = 0; } -void CL_InitEdicts( void ) +void CL_InitEdicts( int maxclients ) { Assert( clgame.entities == NULL ); if( !clgame.mempool ) return; // Host_Error without client #if XASH_LOW_MEMORY != 2 - CL_UPDATE_BACKUP = ( cl.maxclients <= 1 ) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP; + CL_UPDATE_BACKUP = ( maxclients <= 1 ) ? SINGLEPLAYER_BACKUP : MULTIPLAYER_BACKUP; #endif cls.num_client_entities = CL_UPDATE_BACKUP * NUM_PACKET_ENTITIES; cls.packet_entities = Mem_Realloc( clgame.mempool, cls.packet_entities, sizeof( entity_state_t ) * cls.num_client_entities ); @@ -1140,7 +1140,7 @@ void CL_ClearEdicts( void ) // in case we stopped with error clgame.maxEntities = 2; - CL_InitEdicts(); + CL_InitEdicts( cl.maxclients ); } /* @@ -4054,7 +4054,7 @@ qboolean CL_LoadProgs( const char *name ) if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" ); - CL_InitEdicts (); // initailize local player and world + CL_InitEdicts( cl.maxclients ); // initailize local player and world CL_InitClientMove(); // initialize pm_shared // initialize game diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index b1b304a6..c1a55742 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -966,7 +966,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy ) Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle )); if( !cls.changelevel && !cls.changedemo ) - CL_InitEdicts (); // re-arrange edicts + CL_InitEdicts( cl.maxclients ); // re-arrange edicts // get splash name if( cls.demoplayback && ( cls.demonum != -1 )) @@ -2260,6 +2260,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) old_background = cl.background; if( MSG_ReadOneBit( msg )) { + int maxclients = cl.maxclients; + cls.changelevel = true; S_StopAllSounds( true ); @@ -2271,8 +2273,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message ) cls.changedemo = true; } - CL_ClearState (); - CL_InitEdicts (); // re-arrange edicts + CL_ClearState(); + CL_InitEdicts( maxclients ); // re-arrange edicts } else Con_Printf( "Server disconnected, reconnecting\n" ); diff --git a/engine/client/cl_parse_48.c b/engine/client/cl_parse_48.c index ed8a2d7d..cd30a123 100644 --- a/engine/client/cl_parse_48.c +++ b/engine/client/cl_parse_48.c @@ -373,7 +373,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message ) old_background = cl.background; if( MSG_ReadOneBit( msg )) { - int old_maxplayers = cl.maxclients; + int maxclients = cl.maxclients; cls.changelevel = true; S_StopAllSounds( true ); @@ -386,15 +386,14 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message ) cls.changedemo = true; } - CL_ClearState (); + CL_ClearState( ); // a1ba: need to restore cl.maxclients because engine chooses // frame backups count depending on this value // In general, it's incorrect to call CL_InitEdicts right after // CL_ClearState because of this bug. Some time later this logic // should be re-done. - cl.maxclients = old_maxplayers; - CL_InitEdicts (); // re-arrange edicts + CL_InitEdicts( maxclients ); // re-arrange edicts } else Con_Printf( "Server disconnected, reconnecting\n" ); diff --git a/engine/client/cl_qparse.c b/engine/client/cl_qparse.c index bc6b3b36..25cb5392 100644 --- a/engine/client/cl_qparse.c +++ b/engine/client/cl_qparse.c @@ -258,7 +258,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg ) Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle )); if( !cls.changelevel && !cls.changedemo ) - CL_InitEdicts (); // re-arrange edicts + CL_InitEdicts( cl.maxclients ); // re-arrange edicts // Quake just have a large packet of initialization data for( i = 1; i < MAX_MODELS; i++ ) diff --git a/engine/client/client.h b/engine/client/client.h index 4ed56871..861ec7e3 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -830,7 +830,7 @@ void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize ); void CL_ParseFinaleCutscene( sizebuf_t *msg, int level ); void CL_ParseTextMessage( sizebuf_t *msg ); void CL_DrawHUD( int state ); -void CL_InitEdicts( void ); +void CL_InitEdicts( int maxclients ); void CL_FreeEdicts( void ); void CL_ClearWorld( void ); void CL_DrawCenterPrint( void );