engine: client: make it more obvious that CL_InitEdicts depends on maxclients value

This commit is contained in:
Alibek Omarov 2023-06-30 02:51:47 +03:00
parent 00765f1ff2
commit ca134a85ee
6 changed files with 18 additions and 15 deletions

View file

@ -648,11 +648,13 @@ void CL_DemoStartPlayback( int mode )
{ {
if( cls.changedemo ) if( cls.changedemo )
{ {
int maxclients = cl.maxclients;
S_StopAllSounds( true ); S_StopAllSounds( true );
SCR_BeginLoadingPlaque( false ); SCR_BeginLoadingPlaque( false );
CL_ClearState( ); CL_ClearState( );
CL_InitEdicts (); // re-arrange edicts CL_InitEdicts( maxclients ); // re-arrange edicts
} }
else else
{ {

View file

@ -1088,13 +1088,13 @@ void CL_ClearWorld( void )
clgame.numStatics = 0; clgame.numStatics = 0;
} }
void CL_InitEdicts( void ) void CL_InitEdicts( int maxclients )
{ {
Assert( clgame.entities == NULL ); Assert( clgame.entities == NULL );
if( !clgame.mempool ) return; // Host_Error without client if( !clgame.mempool ) return; // Host_Error without client
#if XASH_LOW_MEMORY != 2 #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 #endif
cls.num_client_entities = CL_UPDATE_BACKUP * NUM_PACKET_ENTITIES; 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 ); 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 // in case we stopped with error
clgame.maxEntities = 2; 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 if( !Mobile_Init() ) // Xash3D FWGS extension: mobile interface
Con_Reportf( S_WARN "CL_LoadProgs: couldn't get mobility API\n" ); 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 CL_InitClientMove(); // initialize pm_shared
// initialize game // initialize game

View file

@ -966,7 +966,7 @@ void CL_ParseServerData( sizebuf_t *msg, qboolean legacy )
Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle )); Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle ));
if( !cls.changelevel && !cls.changedemo ) if( !cls.changelevel && !cls.changedemo )
CL_InitEdicts (); // re-arrange edicts CL_InitEdicts( cl.maxclients ); // re-arrange edicts
// get splash name // get splash name
if( cls.demoplayback && ( cls.demonum != -1 )) if( cls.demoplayback && ( cls.demonum != -1 ))
@ -2260,6 +2260,8 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
old_background = cl.background; old_background = cl.background;
if( MSG_ReadOneBit( msg )) if( MSG_ReadOneBit( msg ))
{ {
int maxclients = cl.maxclients;
cls.changelevel = true; cls.changelevel = true;
S_StopAllSounds( true ); S_StopAllSounds( true );
@ -2272,7 +2274,7 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
} }
CL_ClearState(); CL_ClearState();
CL_InitEdicts (); // re-arrange edicts CL_InitEdicts( maxclients ); // re-arrange edicts
} }
else Con_Printf( "Server disconnected, reconnecting\n" ); else Con_Printf( "Server disconnected, reconnecting\n" );

View file

@ -373,7 +373,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
old_background = cl.background; old_background = cl.background;
if( MSG_ReadOneBit( msg )) if( MSG_ReadOneBit( msg ))
{ {
int old_maxplayers = cl.maxclients; int maxclients = cl.maxclients;
cls.changelevel = true; cls.changelevel = true;
S_StopAllSounds( true ); S_StopAllSounds( true );
@ -393,8 +393,7 @@ void CL_ParseLegacyServerMessage( sizebuf_t *msg, qboolean normal_message )
// In general, it's incorrect to call CL_InitEdicts right after // In general, it's incorrect to call CL_InitEdicts right after
// CL_ClearState because of this bug. Some time later this logic // CL_ClearState because of this bug. Some time later this logic
// should be re-done. // should be re-done.
cl.maxclients = old_maxplayers; CL_InitEdicts( maxclients ); // re-arrange edicts
CL_InitEdicts (); // re-arrange edicts
} }
else Con_Printf( "Server disconnected, reconnecting\n" ); else Con_Printf( "Server disconnected, reconnecting\n" );

View file

@ -258,7 +258,7 @@ static void CL_ParseQuakeServerInfo( sizebuf_t *msg )
Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle )); Q_strncpy( gameui.globals->maptitle, clgame.maptitle, sizeof( gameui.globals->maptitle ));
if( !cls.changelevel && !cls.changedemo ) 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 // Quake just have a large packet of initialization data
for( i = 1; i < MAX_MODELS; i++ ) for( i = 1; i < MAX_MODELS; i++ )

View file

@ -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_ParseFinaleCutscene( sizebuf_t *msg, int level );
void CL_ParseTextMessage( sizebuf_t *msg ); void CL_ParseTextMessage( sizebuf_t *msg );
void CL_DrawHUD( int state ); void CL_DrawHUD( int state );
void CL_InitEdicts( void ); void CL_InitEdicts( int maxclients );
void CL_FreeEdicts( void ); void CL_FreeEdicts( void );
void CL_ClearWorld( void ); void CL_ClearWorld( void );
void CL_DrawCenterPrint( void ); void CL_DrawCenterPrint( void );