From cde6ddad7abe2452301bd9bc3ef06070b19371ee Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Thu, 6 Apr 2017 23:33:56 +0200 Subject: implement sv_schachtmeisterPort; add compat shit for crapware from the future --- src/server/server.h | 2 ++ src/server/sv_ccmds.c | 41 +++++++++++++++++++++++++++-------------- src/server/sv_init.c | 2 ++ src/server/sv_main.c | 2 ++ 4 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/server/server.h b/src/server/server.h index 591af854..0e676e94 100644 --- a/src/server/server.h +++ b/src/server/server.h @@ -276,6 +276,8 @@ extern cvar_t *sv_pure; extern cvar_t *sv_lanForceRate; extern cvar_t *sv_banFile; +extern cvar_t *sv_schachtmeisterPort; + #ifdef USE_VOIP extern cvar_t *sv_voip; extern cvar_t *sv_voipProtocol; diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index 65585308..acbd01fe 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -287,28 +287,41 @@ static void SV_KillServer_f( void ) { static void SV_SMQ_f( void ) { static qboolean schmResolved = qfalse; static netadr_t schmAddress; - char args[ MAX_STRING_CHARS ]; - char *p; - int s, i; if ( !schmResolved ) { schmResolved = qtrue; - NET_StringToAdr( "127.0.0.1:1337", &schmAddress, NA_IP ); + NET_StringToAdr( "127.0.0.1", &schmAddress, NA_IP ); + schmAddress.port = 1337; } - p = args; - s = sizeof( args ); - - for ( i = 1; i < Cmd_Argc(); ++i ) + if ( sv_schachtmeisterPort->modified && + sv_schachtmeisterPort->integer >= 1 && sv_schachtmeisterPort->integer <= 65535 ) { - int l; - Com_sprintf( p, s, " \"%s\"", Cmd_Argv( i ) ); - l = strlen( p ); - s -= l; - p += l; + schmAddress.port = sv_schachtmeisterPort->integer; } - NET_OutOfBandPrint( NS_SERVER, schmAddress, "sm2query%s", args ); + if ( Cmd_Argc() >= 3 && !Q_stricmp( Cmd_Argv( 1 ), "ipa" ) ) // compatibility with out-of-date crapware conceived in the future + NET_OutOfBandPrint( NS_SERVER, schmAddress, "sm2query %s", Cmd_ArgsFrom( 2 ) ); + else + { + char args[ MAX_STRING_CHARS ]; + char *p; + int s, i; + + p = args; + s = sizeof( args ); + + for ( i = 1; i < Cmd_Argc(); ++i ) + { + int l; + Com_sprintf( p, s, " \"%s\"", Cmd_Argv( i ) ); + l = strlen( p ); + s -= l; + p += l; + } + + NET_OutOfBandPrint( NS_SERVER, schmAddress, "sm2query%s", args ); + } } //=========================================================== diff --git a/src/server/sv_init.c b/src/server/sv_init.c index dbb12681..236c3d98 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -764,6 +764,8 @@ void SV_Init (void) sv_killserver = Cvar_Get ("sv_killserver", "0", 0); sv_mapChecksum = Cvar_Get ("sv_mapChecksum", "", CVAR_ROM); sv_lanForceRate = Cvar_Get ("sv_lanForceRate", "1", CVAR_ARCHIVE ); + + sv_schachtmeisterPort = Cvar_Get ("sv_schachtmeisterPort", "1337", CVAR_ARCHIVE); } diff --git a/src/server/sv_main.c b/src/server/sv_main.c index 41c51508..6eab835a 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -59,6 +59,8 @@ cvar_t *sv_pure; cvar_t *sv_lanForceRate; // dedicated 1 (LAN) server forces local client rates to 99999 (bug #491) cvar_t *sv_banFile; +cvar_t *sv_schachtmeisterPort; + /* ============================================================================= -- cgit