From e984293788358a72dcb57ad5d74402a3f10f0d97 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Thu, 6 Apr 2017 20:39:29 +0200 Subject: implement Schachtmeister v2 basics --- src/server/sv_ccmds.c | 28 ++++++++++++++++++++++++++++ src/server/sv_main.c | 12 ++++++++++++ 2 files changed, 40 insertions(+) (limited to 'src/server') diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index 56c73aa8..65585308 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -284,6 +284,33 @@ static void SV_KillServer_f( void ) { SV_Shutdown( "killserver" ); } +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 ); + } + + 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 ); +} + //=========================================================== /* @@ -320,6 +347,7 @@ void SV_AddOperatorCommands( void ) { Cmd_AddCommand ("devmap", SV_Map_f); Cmd_SetCommandCompletionFunc( "devmap", SV_CompleteMapName ); Cmd_AddCommand ("killserver", SV_KillServer_f); + Cmd_AddCommand ("smq", SV_SMQ_f); } /* diff --git a/src/server/sv_main.c b/src/server/sv_main.c index e5e7e5f1..41c51508 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -752,6 +752,16 @@ static void SVC_RemoteCommand( netadr_t from, msg_t *msg ) { Com_EndRedirect (); } +static void SVC_SchachtmeisterResponse( netadr_t from ) { + if ( !( from.type == NA_IP && from.ip[0] == 127 ) ) { + return; + } + + strcpy( Cmd_Argv( 0 ), "smr" ); + + SV_GameCommand(); +} + /* ================= SV_ConnectionlessPacket @@ -793,6 +803,8 @@ static void SV_ConnectionlessPacket( netadr_t from, msg_t *msg ) { // if a client starts up a local server, we may see some spurious // server disconnect messages when their new server sees our final // sequenced messages to the old client + } else if (!Q_stricmp(c, "sm2reply")) { + SVC_SchachtmeisterResponse( from ); } else { Com_DPrintf ("bad connectionless packet from %s:\n%s\n", NET_AdrToString (from), s); -- cgit