From a0cbac4fc7463b53547a4a3ebc2a89bcc3a24126 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 13 Jul 2019 20:59:43 +0300 Subject: [PATCH] engine: server: use generic SV_RejectConnection instead of directly sending errormsg --- engine/server/server.h | 2 +- engine/server/sv_client.c | 3 +-- engine/server/sv_main.c | 12 ++++++------ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/engine/server/server.h b/engine/server/server.h index fdf488d1..525ac9ab 100644 --- a/engine/server/server.h +++ b/engine/server/server.h @@ -513,7 +513,6 @@ void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 ); char *SV_StatusString( void ); void SV_RefreshUserinfo( void ); void SV_GetChallenge( netadr_t from ); -void SV_DirectConnect( netadr_t from ); void SV_TogglePause( const char *msg ); qboolean SV_ShouldUpdatePing( sv_client_t *cl ); const char *SV_GetClientIDString( sv_client_t *cl ); @@ -535,6 +534,7 @@ int SV_CalcPing( sv_client_t *cl ); void SV_InitClientMove( void ); void SV_UpdateServerInfo( void ); void SV_EndRedirect( void ); +void SV_RejectConnection( netadr_t from, char *fmt, ... ) _format( 2 ); // // sv_cmds.c diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 89755715..89810075 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -137,7 +137,6 @@ SV_RejectConnection Rejects connection request and sends back a message ================ */ -void SV_RejectConnection( netadr_t from, char *fmt, ... ) _format( 2 ); void SV_RejectConnection( netadr_t from, char *fmt, ... ) { char text[1024]; @@ -148,6 +147,7 @@ void SV_RejectConnection( netadr_t from, char *fmt, ... ) va_end( argptr ); Con_Reportf( "%s connection refused. Reason: %s\n", NET_AdrToString( from ), text ); + Netchan_OutOfBandPrint( NS_SERVER, from, "errormsg\n^1Server was reject the connection:^7 %s", text ); Netchan_OutOfBandPrint( NS_SERVER, from, "print\n^1Server was reject the connection:^7 %s", text ); Netchan_OutOfBandPrint( NS_SERVER, from, "disconnect\n" ); } @@ -305,7 +305,6 @@ void SV_ConnectClient( netadr_t from ) if( !SV_ProcessUserAgent( from, protinfo ) ) { - Netchan_OutOfBandPrint( NS_SERVER, from, "disconnect\n" ); return; } diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 69717b0d..996f76a6 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -785,7 +785,7 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent ) if( !sv_allow_noinputdevices->value && ( !input_devices_str || !input_devices_str[0] ) ) { - Netchan_OutOfBandPrint( NS_SERVER, from, "print\nThis server does not allow\nconnect without input devices list.\nPlease update your engine.\n" ); + SV_RejectConnection( from, "This server does not allow\nconnect without input devices list.\nPlease update your engine.\n" ); return false; } @@ -795,22 +795,22 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent ) if( !sv_allow_touch->value && ( input_devices & INPUT_DEVICE_TOUCH ) ) { - Netchan_OutOfBandPrint( NS_SERVER, from, "errormsg\nThis server does not allow touch\nDisable it (touch_enable 0)\nto play on this server\n" ); + SV_RejectConnection( from, "This server does not allow touch\nDisable it (touch_enable 0)\nto play on this server\n" ); return false; } if( !sv_allow_mouse->value && ( input_devices & INPUT_DEVICE_MOUSE) ) { - Netchan_OutOfBandPrint( NS_SERVER, from, "errormsg\nThis server does not allow mouse\nDisable it(m_ignore 1)\nto play on this server\n" ); + SV_RejectConnection( from, "This server does not allow mouse\nDisable it(m_ignore 1)\nto play on this server\n" ); return false; } if( !sv_allow_joystick->value && ( input_devices & INPUT_DEVICE_JOYSTICK) ) { - Netchan_OutOfBandPrint( NS_SERVER, from, "errormsg\nThis server does not allow joystick\nDisable it(joy_enable 0)\nto play on this server\n" ); + SV_RejectConnection( from, "This server does not allow joystick\nDisable it(joy_enable 0)\nto play on this server\n" ); return false; } if( !sv_allow_vr->value && ( input_devices & INPUT_DEVICE_VR) ) { - Netchan_OutOfBandPrint( NS_SERVER, from, "errormsg\nThis server does not allow VR\n" ); + SV_RejectConnection( from, "This server does not allow VR\n" ); return false; } } @@ -821,7 +821,7 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent ) if( banned ) { - Netchan_OutOfBandPrint( NS_SERVER, from, "errormsg\nYou are banned!\n" ); + SV_RejectConnection( from, "You are banned!\n" ); return false; } }