Browse Source

engine: server: use generic SV_RejectConnection instead of directly sending errormsg

pull/2/head
Alibek Omarov 5 years ago
parent
commit
a0cbac4fc7
  1. 2
      engine/server/server.h
  2. 3
      engine/server/sv_client.c
  3. 12
      engine/server/sv_main.c

2
engine/server/server.h

@ -513,7 +513,6 @@ void SV_BroadcastCommand( const char *fmt, ... ) _format( 1 ); @@ -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 ); @@ -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

3
engine/server/sv_client.c

@ -137,7 +137,6 @@ SV_RejectConnection @@ -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, ... ) @@ -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 ) @@ -305,7 +305,6 @@ void SV_ConnectClient( netadr_t from )
if( !SV_ProcessUserAgent( from, protinfo ) )
{
Netchan_OutOfBandPrint( NS_SERVER, from, "disconnect\n" );
return;
}

12
engine/server/sv_main.c

@ -785,7 +785,7 @@ qboolean SV_ProcessUserAgent( netadr_t from, const char *useragent ) @@ -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 ) @@ -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 ) @@ -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;
}
}

Loading…
Cancel
Save