engine: server: reset str64 statistics on server deactivate

This commit is contained in:
Alibek Omarov 2024-11-13 23:32:05 +03:00
parent 723cd8e26c
commit a749bb8ef1
3 changed files with 14 additions and 4 deletions

View file

@ -609,7 +609,7 @@ string_t SV_AllocString( const char *szValue );
string_t SV_MakeString( const char *szValue ); string_t SV_MakeString( const char *szValue );
const char *SV_GetString( string_t iString ); const char *SV_GetString( string_t iString );
void SV_SetStringArrayMode( qboolean dynamic ); void SV_SetStringArrayMode( qboolean dynamic );
void SV_EmptyStringPool( void ); void SV_EmptyStringPool( qboolean clear_stats );
void SV_PrintStr64Stats_f( void ); void SV_PrintStr64Stats_f( void );
sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only ); sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only );
uint SV_MapIsValid( const char *filename, const char *landmark_name ); uint SV_MapIsValid( const char *filename, const char *landmark_name );

View file

@ -3009,16 +3009,26 @@ SV_EmptyStringPool
Free strings on server stop. Reset string pointer on 64 bits Free strings on server stop. Reset string pointer on 64 bits
================== ==================
*/ */
void SV_EmptyStringPool( void ) void SV_EmptyStringPool( qboolean clear_stats )
{ {
#if XASH_64BIT #if XASH_64BIT
if( str64.dynamic ) // switch only after array fill (more space for multiplayer games) if( str64.dynamic ) // switch only after array fill (more space for multiplayer games)
{
str64.pstringbase = str64.pstringarray; str64.pstringbase = str64.pstringarray;
}
else else
{ {
str64.pstringbase = str64.poldstringbase = str64.pstringarraystatic; str64.pstringbase = str64.poldstringbase = str64.pstringarraystatic;
str64.plast = str64.pstringbase + 1; str64.plast = str64.pstringbase + 1;
} }
if( clear_stats )
{
str64.maxalloc = 0;
str64.totalalloc = 0;
str64.numdups = 0;
str64.numoverflows = 0;
}
#else // !XASH_64BIT #else // !XASH_64BIT
Mem_EmptyPool( svgame.stringspool ); Mem_EmptyPool( svgame.stringspool );
#endif // !XASH_64BIT #endif // !XASH_64BIT
@ -3043,7 +3053,7 @@ void SV_SetStringArrayMode( qboolean dynamic )
str64.dynamic = dynamic; str64.dynamic = dynamic;
SV_EmptyStringPool(); SV_EmptyStringPool( false );
#endif // !XASH_64BIT #endif // !XASH_64BIT
} }

View file

@ -715,7 +715,7 @@ void SV_DeactivateServer( void )
PM_ClearPhysEnts( svgame.pmove ); PM_ClearPhysEnts( svgame.pmove );
SV_EmptyStringPool(); SV_EmptyStringPool( true );
for( i = 0; i < svs.maxclients; i++ ) for( i = 0; i < svs.maxclients; i++ )
{ {