mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-10 15:17:52 +00:00
engine: server: restore log functionality from old engine. Thanks to @ValeTheVioletMote for initial patch.
This commit is contained in:
parent
57382c7cea
commit
d9fd6aa05c
@ -387,6 +387,8 @@ extern areanode_t sv_areanodes[]; // AABB dynamic tree
|
||||
|
||||
extern convar_t mp_logecho;
|
||||
extern convar_t mp_logfile;
|
||||
extern convar_t sv_log_onefile;
|
||||
extern convar_t sv_log_singleplayer;
|
||||
extern convar_t sv_unlag;
|
||||
extern convar_t sv_maxunlag;
|
||||
extern convar_t sv_unlagpush;
|
||||
@ -644,7 +646,8 @@ char *SV_Localinfo( void );
|
||||
void Log_Close( void );
|
||||
void Log_Open( void );
|
||||
void Log_PrintServerVars( void );
|
||||
qboolean SV_ServerLog_f( sv_client_t *cl );
|
||||
void SV_ServerLog_f( void );
|
||||
void SV_SetLogAddress_f( void );
|
||||
|
||||
//
|
||||
// sv_save.c
|
||||
|
@ -2101,7 +2101,6 @@ ucmd_t ucmds[] =
|
||||
{ "spawn", SV_Spawn_f },
|
||||
{ "pause", SV_Pause_f },
|
||||
{ "noclip", SV_Noclip_f },
|
||||
{ "log", SV_ServerLog_f },
|
||||
{ "setinfo", SV_SetInfo_f },
|
||||
{ "sendres", SV_SendRes_f },
|
||||
{ "notarget", SV_Notarget_f },
|
||||
|
@ -1041,6 +1041,8 @@ void SV_InitOperatorCommands( void )
|
||||
Cmd_AddCommand( "changelevel", SV_ChangeLevel_f, "change level" );
|
||||
Cmd_AddCommand( "changelevel2", SV_ChangeLevel2_f, "smooth change level" );
|
||||
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" );
|
||||
|
||||
if( host.type == HOST_NORMAL )
|
||||
{
|
||||
@ -1075,6 +1077,8 @@ void SV_KillOperatorCommands( void )
|
||||
Cmd_RemoveCommand( "shutdownserver" );
|
||||
Cmd_RemoveCommand( "changelevel" );
|
||||
Cmd_RemoveCommand( "changelevel2" );
|
||||
Cmd_RemoveCommand( "logaddress" );
|
||||
Cmd_RemoveCommand( "log" );
|
||||
|
||||
if( host.type == HOST_NORMAL )
|
||||
{
|
||||
|
@ -29,6 +29,9 @@ void Log_Open( void )
|
||||
if( !svs.log.active )
|
||||
return;
|
||||
|
||||
if( sv_log_onefile.value && svs.log.file )
|
||||
return;
|
||||
|
||||
if( !mp_logfile.value )
|
||||
{
|
||||
Con_Printf( "Server logging data to console.\n" );
|
||||
@ -121,7 +124,7 @@ void Log_Printf( const char *fmt, ... )
|
||||
if( svs.log.net_log )
|
||||
Netchan_OutOfBandPrint( NS_SERVER, svs.log.net_address, "log %s", string );
|
||||
|
||||
if( svs.log.active && svs.maxclients > 1 )
|
||||
if( svs.log.active && ( svs.maxclients > 1 || sv_log_singleplayer.value != 0.0f ))
|
||||
{
|
||||
// echo to server console
|
||||
if( mp_logecho.value )
|
||||
@ -154,25 +157,69 @@ void Log_PrintServerVars( void )
|
||||
Log_Printf( "Server cvars end\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
SV_SetLogAddress_f
|
||||
|
||||
====================
|
||||
*/
|
||||
void SV_SetLogAddress_f( void )
|
||||
{
|
||||
const char *s;
|
||||
int port;
|
||||
string addr;
|
||||
|
||||
if( Cmd_Argc() != 3 )
|
||||
{
|
||||
Con_Printf( "logaddress: usage\nlogaddress ip port\n" );
|
||||
|
||||
if( svs.log.active )
|
||||
Con_Printf( "current: %s\n", NET_AdrToString( svs.log.net_address ));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
port = Q_atoi( Cmd_Argv( 2 ));
|
||||
if( !port )
|
||||
{
|
||||
Con_Printf( "logaddress: must specify a valid port\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
s = Cmd_Argv( 1 );
|
||||
if( !COM_CheckString( s ))
|
||||
{
|
||||
Con_Printf( "logaddress: unparseable address\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
Q_snprintf( addr, sizeof( addr ), "%s:%i", s, port );
|
||||
if( !NET_StringToAdr( addr, &svs.log.net_address ))
|
||||
{
|
||||
Con_Printf( "logaddress: unable to resolve %s\n", addr );
|
||||
return;
|
||||
}
|
||||
|
||||
svs.log.net_log = true;
|
||||
Con_Printf( "logaddress: %s\n", NET_AdrToString( svs.log.net_address ));
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
SV_ServerLog_f
|
||||
|
||||
====================
|
||||
*/
|
||||
qboolean SV_ServerLog_f( sv_client_t *cl )
|
||||
void SV_ServerLog_f( void )
|
||||
{
|
||||
if( svs.maxclients <= 1 )
|
||||
return false;
|
||||
|
||||
if( Cmd_Argc() != 2 )
|
||||
{
|
||||
SV_ClientPrintf( cl, "usage: log < on|off >\n" );
|
||||
Con_Printf("usage: log < on|off >\n" );
|
||||
|
||||
if( svs.log.active )
|
||||
SV_ClientPrintf( cl, "currently logging\n" );
|
||||
else SV_ClientPrintf( cl, "not currently logging\n" );
|
||||
return true;
|
||||
Con_Printf( "currently logging\n" );
|
||||
else Con_Printf( "not currently logging\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if( !Q_stricmp( Cmd_Argv( 1 ), "off" ))
|
||||
@ -187,8 +234,8 @@ qboolean SV_ServerLog_f( sv_client_t *cl )
|
||||
}
|
||||
else
|
||||
{
|
||||
SV_ClientPrintf( cl, "log: unknown parameter %s\n", Cmd_Argv( 1 ));
|
||||
Con_Printf( "log: unknown parameter %s\n", Cmd_Argv( 1 ));
|
||||
}
|
||||
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
@ -53,6 +53,8 @@ CVAR_DEFINE_AUTO( sv_downloadurl, "", FCVAR_PROTECTED, "location from which clie
|
||||
CVAR_DEFINE( sv_consistency, "mp_consistency", "1", FCVAR_SERVER, "enbale consistency check in multiplayer" );
|
||||
CVAR_DEFINE_AUTO( mp_logecho, "1", 0, "log multiplayer frags to server logfile" );
|
||||
CVAR_DEFINE_AUTO( mp_logfile, "1", 0, "log multiplayer frags to console" );
|
||||
CVAR_DEFINE_AUTO( sv_log_singleplayer, "0", FCVAR_ARCHIVE, "allows logging in singleplayer games" );
|
||||
CVAR_DEFINE_AUTO( sv_log_onefile, "0", FCVAR_ARCHIVE, "logs server information to only one file" );
|
||||
|
||||
// game-related cvars
|
||||
CVAR_DEFINE_AUTO( mapcyclefile, "mapcycle.txt", 0, "name of multiplayer map cycle configuration file" );
|
||||
@ -932,6 +934,9 @@ void SV_Init( void )
|
||||
Cvar_RegisterVariable( &violence_hgibs );
|
||||
Cvar_RegisterVariable( &mp_logecho );
|
||||
Cvar_RegisterVariable( &mp_logfile );
|
||||
Cvar_RegisterVariable( &sv_log_onefile );
|
||||
Cvar_RegisterVariable( &sv_log_singleplayer );
|
||||
|
||||
Cvar_RegisterVariable( &sv_background_freeze );
|
||||
|
||||
Cvar_RegisterVariable( &mapcyclefile );
|
||||
|
Loading…
Reference in New Issue
Block a user