From f6d489e038d86dfa79ae7b99aaadea8ef9b9f7e3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 25 Mar 2024 05:49:34 +0300 Subject: [PATCH] engine: server: register str64stats command that prints string pool usage statistics --- engine/server/server.h | 2 -- engine/server/sv_cmds.c | 2 ++ engine/server/sv_game.c | 22 ++++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/engine/server/server.h b/engine/server/server.h index 1e78ea74..68bb5cb8 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -613,9 +613,7 @@ string_t SV_MakeString( const char *szValue ); const char *SV_GetString( string_t iString ); void SV_SetStringArrayMode( qboolean dynamic ); void SV_EmptyStringPool( void ); -#ifdef XASH_64BIT void SV_PrintStr64Stats_f( void ); -#endif sv_client_t *SV_ClientFromEdict( const edict_t *pEdict, qboolean spawned_only ); uint SV_MapIsValid( const char *filename, const char *spawn_entity, const char *landmark_name ); void SV_StartSound( edict_t *ent, int chan, const char *sample, float vol, float attn, int flags, int pitch ); diff --git a/engine/server/sv_cmds.c b/engine/server/sv_cmds.c index 57a0f9f2..323e9276 100644 --- a/engine/server/sv_cmds.c +++ b/engine/server/sv_cmds.c @@ -1017,6 +1017,7 @@ void SV_InitOperatorCommands( void ) Cmd_AddCommand( "redirect", Rcon_Redirect_f, "force enable rcon redirection" ); Cmd_AddCommand( "logaddress", SV_SetLogAddress_f, "sets address and port for remote logging host" ); Cmd_AddCommand( "log", SV_ServerLog_f, "enables logging to file" ); + Cmd_AddCommand( "str64stats", SV_PrintStr64Stats_f, "print engine pool string statistics" ); if( host.type == HOST_NORMAL ) { @@ -1055,6 +1056,7 @@ void SV_KillOperatorCommands( void ) Cmd_RemoveCommand( "redirect" ); Cmd_RemoveCommand( "logaddress" ); Cmd_RemoveCommand( "log" ); + Cmd_RemoveCommand( "str64stats" ); if( host.type == HOST_NORMAL ) { diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index d347d742..13e170de 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -3282,19 +3282,21 @@ string_t GAME_EXPORT SV_AllocString( const char *szValue ) #endif } -#ifdef XASH_64BIT void SV_PrintStr64Stats_f( void ) { - Msg( "====================\n" ); - Msg( "64 bit string pool statistics\n" ); - Msg( "====================\n" ); - Msg( "string array size: %lu\n", str64.maxstringarray ); - Msg( "total alloc %lu\n", str64.totalalloc ); - Msg( "maximum array usage: %lu\n", str64.maxalloc ); - Msg( "overflow counter: %lu\n", str64.numoverflows ); - Msg( "dup string counter: %lu\n", str64.numdups ); -} +#ifdef XASH_64BIT + Con_Printf( "====================\n" ); + Con_Printf( "64 bit string pool statistics\n" ); + Con_Printf( "====================\n" ); + Con_Printf( "string array size: %lu\n", str64.maxstringarray ); + Con_Printf( "total alloc %lu\n", str64.totalalloc ); + Con_Printf( "maximum array usage: %lu\n", str64.maxalloc ); + Con_Printf( "overflow counter: %lu\n", str64.numoverflows ); + Con_Printf( "dup string counter: %lu\n", str64.numdups ); +#else + Con_Printf( "Not implemented\n" ); #endif +} /* =============