mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
server: implement rcon redirection, add redirect command from old engine
This commit is contained in:
parent
9c9953bb60
commit
c62db950f1
@ -325,11 +325,12 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct host_redirect_s
|
typedef struct host_redirect_s
|
||||||
{
|
{
|
||||||
rdtype_t target;
|
rdtype_t target;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int buffersize;
|
size_t buffersize;
|
||||||
netadr_t address;
|
netadr_t address;
|
||||||
void (*flush)( netadr_t adr, rdtype_t target, char *buffer );
|
void (*flush)( netadr_t adr, rdtype_t target, char *buffer );
|
||||||
|
int lines;
|
||||||
} host_redirect_t;
|
} host_redirect_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -947,6 +948,7 @@ void VID_Init( void );
|
|||||||
void UI_SetActiveMenu( qboolean fActive );
|
void UI_SetActiveMenu( qboolean fActive );
|
||||||
void UI_ShowConnectionWarning( void );
|
void UI_ShowConnectionWarning( void );
|
||||||
void Cmd_Null_f( void );
|
void Cmd_Null_f( void );
|
||||||
|
void Rcon_Print( const char *pMsg );
|
||||||
|
|
||||||
// soundlib shared exports
|
// soundlib shared exports
|
||||||
qboolean S_Init( void );
|
qboolean S_Init( void );
|
||||||
|
@ -553,5 +553,5 @@ void Sys_Print( const char *pMsg )
|
|||||||
|
|
||||||
Sys_PrintLog( pMsg );
|
Sys_PrintLog( pMsg );
|
||||||
|
|
||||||
// Rcon_Print( pMsg );
|
Rcon_Print( pMsg );
|
||||||
}
|
}
|
||||||
|
@ -608,7 +608,7 @@ SVC COMMAND REDIRECT
|
|||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
*/
|
*/
|
||||||
void SV_BeginRedirect( netadr_t adr, int target, char *buffer, int buffersize, void (*flush))
|
void SV_BeginRedirect( netadr_t adr, rdtype_t target, char *buffer, size_t buffersize, void (*flush))
|
||||||
{
|
{
|
||||||
if( !target || !buffer || !buffersize || !flush )
|
if( !target || !buffer || !buffersize || !flush )
|
||||||
return;
|
return;
|
||||||
@ -619,6 +619,8 @@ void SV_BeginRedirect( netadr_t adr, int target, char *buffer, int buffersize, v
|
|||||||
host.rd.flush = flush;
|
host.rd.flush = flush;
|
||||||
host.rd.address = adr;
|
host.rd.address = adr;
|
||||||
host.rd.buffer[0] = 0;
|
host.rd.buffer[0] = 0;
|
||||||
|
if( host.rd.lines == 0 )
|
||||||
|
host.rd.lines = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
|
void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
|
||||||
@ -644,6 +646,9 @@ void SV_FlushRedirect( netadr_t adr, int dest, char *buf )
|
|||||||
|
|
||||||
void SV_EndRedirect( void )
|
void SV_EndRedirect( void )
|
||||||
{
|
{
|
||||||
|
if( host.rd.lines > 0 )
|
||||||
|
return;
|
||||||
|
|
||||||
if( host.rd.flush )
|
if( host.rd.flush )
|
||||||
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
|
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
|
||||||
|
|
||||||
@ -653,6 +658,34 @@ void SV_EndRedirect( void )
|
|||||||
host.rd.flush = NULL;
|
host.rd.flush = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
Rcon_Print
|
||||||
|
|
||||||
|
Print message to rcon buffer and send to rcon redirect target
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
void Rcon_Print( const char *pMsg )
|
||||||
|
{
|
||||||
|
if( host.rd.target && host.rd.lines && host.rd.flush && host.rd.buffer )
|
||||||
|
{
|
||||||
|
size_t len = Q_strncat( host.rd.buffer, pMsg, host.rd.buffersize );
|
||||||
|
|
||||||
|
if( len && host.rd.buffer[len-1] == '\n' )
|
||||||
|
{
|
||||||
|
host.rd.flush( host.rd.address, host.rd.target, host.rd.buffer );
|
||||||
|
|
||||||
|
if( host.rd.lines > 0 )
|
||||||
|
host.rd.lines--;
|
||||||
|
|
||||||
|
host.rd.buffer[0] = 0;
|
||||||
|
|
||||||
|
if( !host.rd.lines )
|
||||||
|
Msg( "End of redirection!\n" );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
SV_GetClientIDString
|
SV_GetClientIDString
|
||||||
|
@ -931,6 +931,30 @@ void SV_EntityInfo_f( void )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
================
|
||||||
|
Rcon_Redirect_f
|
||||||
|
|
||||||
|
Force redirect N lines of console output to client
|
||||||
|
================
|
||||||
|
*/
|
||||||
|
void Rcon_Redirect_f( void )
|
||||||
|
{
|
||||||
|
int lines = 2000;
|
||||||
|
|
||||||
|
if( !host.rd.target )
|
||||||
|
{
|
||||||
|
Msg( "redirect is only valid from rcon\n" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( Cmd_Argc() == 2 )
|
||||||
|
lines = Q_atoi( Cmd_Argv( 1 ) );
|
||||||
|
|
||||||
|
host.rd.lines = lines;
|
||||||
|
Msg( "Redirection enabled for next %d lines\n", lines );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
==================
|
==================
|
||||||
SV_InitHostCommands
|
SV_InitHostCommands
|
||||||
@ -978,6 +1002,7 @@ void SV_InitOperatorCommands( void )
|
|||||||
Cmd_AddCommand( "shutdownserver", SV_KillServer_f, "shutdown current server" );
|
Cmd_AddCommand( "shutdownserver", SV_KillServer_f, "shutdown current server" );
|
||||||
Cmd_AddCommand( "changelevel", SV_ChangeLevel_f, "change level" );
|
Cmd_AddCommand( "changelevel", SV_ChangeLevel_f, "change level" );
|
||||||
Cmd_AddCommand( "changelevel2", SV_ChangeLevel2_f, "smooth change level" );
|
Cmd_AddCommand( "changelevel2", SV_ChangeLevel2_f, "smooth change level" );
|
||||||
|
Cmd_AddCommand( "redirect", Rcon_Redirect_f, "force enable rcon redirection" );
|
||||||
|
|
||||||
if( host.type == HOST_NORMAL )
|
if( host.type == HOST_NORMAL )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user