summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/g_client.c2
-rw-r--r--src/game/g_local.h2
-rw-r--r--src/game/g_main.c2
-rw-r--r--src/game/g_svcmds.c347
-rw-r--r--src/ui/ui_main.c16
5 files changed, 10 insertions, 359 deletions
diff --git a/src/game/g_client.c b/src/game/g_client.c
index e69581da..8b9beb5d 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1216,8 +1216,6 @@ char *ClientConnect( int clientNum, qboolean firstTime )
// check to see if they are on the banned IP list
value = Info_ValueForKey( userinfo, "ip" );
Q_strncpyz( client->pers.ip, value, sizeof( client->pers.ip ) );
- if( G_FilterPacket( value ) )
- return "You are banned from this server.";
// check for a password
value = Info_ValueForKey( userinfo, "password" );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 2c43a6ca..8720c91c 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -912,8 +912,6 @@ qboolean SpotWouldTelefrag( gentity_t *spot );
// g_svcmds.c
//
qboolean ConsoleCommand( void );
-void G_ProcessIPBans( void );
-qboolean G_FilterPacket( char *from );
//
// g_weapon.c
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 4eebc5a9..6928973b 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -533,8 +533,6 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
G_Printf( "gamename: %s\n", GAME_VERSION );
G_Printf( "gamedate: %s\n", __DATE__ );
- G_ProcessIPBans( );
-
BG_InitMemory( );
// set some level globals
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index 24fd5388..40dd6eb3 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -25,315 +25,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "g_local.h"
-
-/*
-==============================================================================
-
-PACKET FILTERING
-
-
-You can add or remove addresses from the filter list with:
-
-addip <ip>
-removeip <ip>
-
-The ip address is specified in dot format, and you can use '*' to match any value
-so you can specify an entire class C network with "addip 192.246.40.*"
-
-Removeip will only remove an address specified exactly the same way. You cannot addip a subnet, then removeip a single host.
-
-listip
-Prints the current list of filters.
-
-g_filterban <0 or 1>
-
-If 1 (the default), then ip addresses matching the current list will be prohibited from entering the game. This is the default setting.
-
-If 0, then only addresses matching the list will be allowed. This lets you easily set up a private game, or a game that only allows players from your local network.
-
-For persistence, bans are stored in g_banIPs cvar MAX_CVAR_VALUE_STRING
-The size of the cvar string buffer is limiting the banning to around 20 masks
-this could be improved by putting some g_banIPs2 g_banIps3 etc. maybe
-still, you should rely on PB for banning instead
-
-==============================================================================
-*/
-
-// extern vmCvar_t g_banIPs;
-// extern vmCvar_t g_filterBan;
-
-
-typedef struct ipFilter_s
-{
- unsigned mask;
- unsigned compare;
-} ipFilter_t;
-
-#define MAX_IPFILTERS 1024
-
-static ipFilter_t ipFilters[ MAX_IPFILTERS ];
-static int numIPFilters;
-
-/*
-=================
-StringToFilter
-=================
-*/
-static qboolean StringToFilter( char *s, ipFilter_t *f )
-{
- char num[ 128 ];
- int i, j;
- byte b[ 4 ];
- byte m[ 4 ];
-
- for( i = 0; i < 4; i++ )
- {
- b[ i ] = 0;
- m[ i ] = 0;
- }
-
- for( i = 0; i < 4; i++ )
- {
- if( *s < '0' || *s > '9' )
- {
- if( *s == '*' ) // 'match any'
- {
- //b[ i ] and m[ i ] to 0
- s++;
- if ( !*s )
- break;
-
- s++;
- continue;
- }
-
- G_Printf( "Bad filter address: %s\n", s );
- return qfalse;
- }
-
- j = 0;
- while( *s >= '0' && *s <= '9' )
- num[ j++ ] = *s++;
-
- num[ j ] = 0;
- b[ i ] = atoi( num );
-
- m[ i ] = 255;
-
- if( !*s )
- break;
-
- s++;
- }
-
- f->mask = *(unsigned *)m;
- f->compare = *(unsigned *)b;
-
- return qtrue;
-}
-
-/*
-=================
-UpdateIPBans
-=================
-*/
-static void UpdateIPBans( void )
-{
- byte b[ 4 ];
- byte m[ 4 ];
- int i, j;
- char iplist_final[ MAX_CVAR_VALUE_STRING ];
- char ip[ 64 ];
-
- *iplist_final = 0;
-
- for( i = 0 ; i < numIPFilters ; i++ )
- {
- if( ipFilters[ i ].compare == 0xffffffff )
- continue;
-
- *(unsigned *)b = ipFilters[ i ].compare;
- *(unsigned *)m = ipFilters[ i ].mask;
- *ip = 0;
-
- for( j = 0 ; j < 4 ; j++ )
- {
- if( m[ j ] != 255 )
- Q_strcat( ip, sizeof( ip ), "*" );
- else
- Q_strcat( ip, sizeof( ip ), va( "%i", b[ j ] ) );
-
- Q_strcat( ip, sizeof( ip ), ( j < 3 ) ? "." : " " );
- }
-
- if( strlen( iplist_final ) + strlen( ip ) < MAX_CVAR_VALUE_STRING )
- Q_strcat( iplist_final, sizeof( iplist_final ), ip );
- else
- {
- Com_Printf( "g_banIPs overflowed at MAX_CVAR_VALUE_STRING\n" );
- break;
- }
- }
-
- trap_Cvar_Set( "g_banIPs", iplist_final );
-}
-
-/*
-=================
-G_FilterPacket
-=================
-*/
-qboolean G_FilterPacket( char *from )
-{
- int i;
- unsigned in;
- byte m[ 4 ];
- char *p;
-
- i = 0;
- p = from;
- while( *p && i < 4 )
- {
- m[ i ] = 0;
- while( *p >= '0' && *p <= '9' )
- {
- m[ i ] = m[ i ] * 10 + ( *p - '0' );
- p++;
- }
-
- if( !*p || *p == ':' )
- break;
-
- i++, p++;
- }
-
- in = *(unsigned *)m;
-
- for( i = 0; i < numIPFilters; i++ )
- if( ( in & ipFilters[ i ].mask ) == ipFilters[ i ].compare )
- return g_filterBan.integer != 0;
-
- return g_filterBan.integer == 0;
-}
-
-/*
-=================
-AddIP
-=================
-*/
-static void AddIP( char *str )
-{
- int i;
-
- for( i = 0 ; i < numIPFilters ; i++ )
- if( ipFilters[ i ].compare == 0xffffffff )
- break; // free spot
-
- if( i == numIPFilters )
- {
- if( numIPFilters == MAX_IPFILTERS )
- {
- G_Printf( "IP filter list is full\n" );
- return;
- }
-
- numIPFilters++;
- }
-
- if( !StringToFilter( str, &ipFilters[ i ] ) )
- ipFilters[ i ].compare = 0xffffffffu;
-
- UpdateIPBans( );
-}
-
-/*
-=================
-G_ProcessIPBans
-=================
-*/
-void G_ProcessIPBans( void )
-{
- char *s, *t;
- char str[ MAX_CVAR_VALUE_STRING ];
-
- Q_strncpyz( str, g_banIPs.string, sizeof( str ) );
-
- for( t = s = g_banIPs.string; *t; /* */ )
- {
- s = strchr( s, ' ' );
-
- if( !s )
- break;
-
- while( *s == ' ' )
- *s++ = 0;
-
- if( *t )
- AddIP( t );
-
- t = s;
- }
-}
-
-
-/*
-=================
-Svcmd_AddIP_f
-=================
-*/
-void Svcmd_AddIP_f( void )
-{
- char str[ MAX_TOKEN_CHARS ];
-
- if( trap_Argc( ) < 2 )
- {
- G_Printf( "Usage: addip <ip-mask>\n" );
- return;
- }
-
- trap_Argv( 1, str, sizeof( str ) );
-
- AddIP( str );
-}
-
-/*
-=================
-Svcmd_RemoveIP_f
-=================
-*/
-void Svcmd_RemoveIP_f( void )
-{
- ipFilter_t f;
- int i;
- char str[ MAX_TOKEN_CHARS ];
-
- if( trap_Argc( ) < 2 )
- {
- G_Printf( "Usage: sv removeip <ip-mask>\n" );
- return;
- }
-
- trap_Argv( 1, str, sizeof( str ) );
-
- if( !StringToFilter( str, &f ) )
- return;
-
- for( i = 0; i < numIPFilters; i++ )
- {
- if( ipFilters[ i ].mask == f.mask &&
- ipFilters[ i ].compare == f.compare)
- {
- ipFilters[ i ].compare = 0xffffffffu;
- G_Printf ( "Removed.\n" );
-
- UpdateIPBans( );
- return;
- }
- }
-
- G_Printf ( "Didn't find %s.\n", str );
-}
-
/*
===================
Svcmd_EntityList_f
@@ -600,24 +291,6 @@ qboolean ConsoleCommand( void )
return qtrue;
}
- if( Q_stricmp( cmd, "addip" ) == 0 )
- {
- Svcmd_AddIP_f( );
- return qtrue;
- }
-
- if( Q_stricmp( cmd, "removeip" ) == 0 )
- {
- Svcmd_RemoveIP_f( );
- return qtrue;
- }
-
- if( Q_stricmp( cmd, "listip" ) == 0 )
- {
- trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
- return qtrue;
- }
-
if( Q_stricmp( cmd, "mapRotation" ) == 0 )
{
char *rotationName = ConcatArgs( 1 );
@@ -644,29 +317,13 @@ qboolean ConsoleCommand( void )
if( Q_stricmp( cmd, "alienWin" ) == 0 )
{
- int i;
- gentity_t *e;
-
- for( i = 1, e = g_entities + i; i < level.num_entities; i++, e++ )
- {
- if( e->s.modelindex == BA_H_SPAWN )
- G_Damage( e, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE );
- }
-
+ G_BaseSelfDestruct( TEAM_HUMANS );
return qtrue;
}
if( Q_stricmp( cmd, "humanWin" ) == 0 )
{
- int i;
- gentity_t *e;
-
- for( i = 1, e = g_entities + i; i < level.num_entities; i++, e++ )
- {
- if( e->s.modelindex == BA_A_SPAWN )
- G_Damage( e, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE );
- }
-
+ G_BaseSelfDestruct( TEAM_ALIENS );
return qtrue;
}
diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c
index dc483add..a741bf8c 100644
--- a/src/ui/ui_main.c
+++ b/src/ui/ui_main.c
@@ -1051,7 +1051,7 @@ static void UI_StartServerRefresh( qboolean full )
if( ui_netSource.integer == AS_LOCAL )
{
- trap_Cmd_ExecuteText( EXEC_NOW, "localservers\n" );
+ trap_Cmd_ExecuteText( EXEC_APPEND, "localservers\n" );
uiInfo.serverStatus.refreshtime = uiInfo.uiDC.realTime + 1000;
return;
}
@@ -1068,10 +1068,10 @@ static void UI_StartServerRefresh( qboolean full )
ptr = UI_Cvar_VariableString( "debug_protocol" );
if( strlen( ptr ) )
- trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %s full empty\n", i, ptr ) );
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %s full empty\n", i, ptr ) );
else
{
- trap_Cmd_ExecuteText( EXEC_NOW, va( "globalservers %d %d full empty\n", i,
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "globalservers %d %d full empty\n", i,
(int)trap_Cvar_VariableValue( "protocol" ) ) );
}
}
@@ -3087,7 +3087,7 @@ static void UI_RunMenuScript( char **args )
}
}
else if( Q_stricmp( name, "Quit" ) == 0 )
- trap_Cmd_ExecuteText( EXEC_NOW, "quit" );
+ trap_Cmd_ExecuteText( EXEC_APPEND, "quit" );
else if( Q_stricmp( name, "Leave" ) == 0 )
{
trap_Cmd_ExecuteText( EXEC_APPEND, "disconnect\n" );
@@ -3279,14 +3279,14 @@ static void UI_RunMenuScript( char **args )
{
BG_ClientListRemove( &uiInfo.ignoreList[ uiInfo.myPlayerIndex ],
uiInfo.clientNums[ uiInfo.ignoreIndex ] );
- trap_Cmd_ExecuteText( EXEC_NOW, va( "unignore %i\n",
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "unignore %i\n",
uiInfo.clientNums[ uiInfo.ignoreIndex ] ) );
}
else
{
BG_ClientListAdd( &uiInfo.ignoreList[ uiInfo.myPlayerIndex ],
uiInfo.clientNums[ uiInfo.ignoreIndex ] );
- trap_Cmd_ExecuteText( EXEC_NOW, va( "ignore %i\n",
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "ignore %i\n",
uiInfo.clientNums[ uiInfo.ignoreIndex ] ) );
}
}
@@ -3300,7 +3300,7 @@ static void UI_RunMenuScript( char **args )
{
BG_ClientListAdd( &uiInfo.ignoreList[ uiInfo.myPlayerIndex ],
uiInfo.clientNums[ uiInfo.ignoreIndex ] );
- trap_Cmd_ExecuteText( EXEC_NOW, va( "ignore %i\n",
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "ignore %i\n",
uiInfo.clientNums[ uiInfo.ignoreIndex ] ) );
}
}
@@ -3314,7 +3314,7 @@ static void UI_RunMenuScript( char **args )
{
BG_ClientListRemove( &uiInfo.ignoreList[ uiInfo.myPlayerIndex ],
uiInfo.clientNums[ uiInfo.ignoreIndex ] );
- trap_Cmd_ExecuteText( EXEC_NOW, va( "unignore %i\n",
+ trap_Cmd_ExecuteText( EXEC_APPEND, va( "unignore %i\n",
uiInfo.clientNums[ uiInfo.ignoreIndex ] ) );
}
}