If anyone is interested i figured out how to completely not have a need for g_banIPs cvar.
just give a shout and ill post it.
Banning
-
- Posts: 304
- Joined: Fri Aug 08, 2003 7:00 am
In g_svcmds.c add the following above the entitylist function:
now still in g_svcmds.c replace the of the following:
with:
void G_ProcessBanList( void ); // store new values in file; reload it for security
okay now, open up g_local.h and add this in the area where there are some defines for g_svcmds.c:
now open up g_main.c and get to G_InitGame.
it should now look something like this:
in that function comment or delete this:
and add:
now, scroll down to G_ShutdownGame.
it should now look something like this:
below that add:
thats pretty much it except go back to g_svcmds.c and we need to change how the listip command works and add a reloadbans function (optional if u want).
/me sighs at how long that took.
if u need any assistance, like line numbers etc, feel free to ask.
Code: Select all
/*
=================
Svcmd_ListIPs_f
=================
*/
void Svcmd_ListIPs_f( void )
{
int i;
char *str;
byte b[4];
G_Printf ( "%d IP slots used.\n", numIPFilters );
for ( i = 0 ; i < numIPFilters ; i++ )
{
G_Printf ( "%d: ", i );
if (ipFilters[i].compare == 0xffffffff)
{
G_Printf ( "unused\n" );
}
else
{
*(unsigned *)b = ipFilters[i].compare;
str = va("%i.%i.%i.%i \n", b[0], b[1], b[2], b[3]);
G_Printf ( "%s\n", str );
}
}
}
/*
=================
G_SaveBanIP
=================
*/
void G_SaveBanIP( void )
{//save out all the banned IPs
int i;
char *str;
fileHandle_t fh;
byte b[4];
trap_FS_FOpenFile("banlist.dat", &fh, FS_WRITE);
if ( !fh )
{
G_Printf ( "G_SaveBanIP - ERROR: can't open banlist.dat\n" );
return;
}
str = va("%d \n", numIPFilters);
trap_FS_Write(str, strlen(str), fh);
for ( i = 0 ; i < numIPFilters ; i++ )
{
if (ipFilters[i].compare == 0xffffffff)
{
str = "unused \n";
trap_FS_Write(str, strlen(str), fh);
}
else
{
*(unsigned *)b = ipFilters[i].compare;
str = va("%i.%i.%i.%i \n", b[0], b[1], b[2], b[3]);
trap_FS_Write(str, strlen(str), fh);
}
}
trap_FS_FCloseFile(fh);
G_Printf ( "G_SaveBanIP - banlist.dat ^3SAVED SUCCESSFULLY^7:\n" ); // comment this out if u dont need a successful message
}
/*
=================
G_LoadIPBans
=================
*/
void G_LoadIPBans( void )
{//load in all the banned IPs
int i, len;
char *p, *token;
fileHandle_t fh;
char banIPBuffer[MAX_IPFILTERS*32]; // The list of file names read in
char banIPFile[MAX_QPATH];
len = trap_FS_FOpenFile("banlist.dat", &fh, FS_READ);
if ( !fh )
{
G_Printf ( "G_LoadBanIP - ERROR: can't open banlist.dat\n" );
return;
}
trap_FS_Read(banIPBuffer, len, fh);
banIPBuffer[len] = 0;
trap_FS_FCloseFile(fh);
p = banIPBuffer;
COM_BeginParseSession(banIPFile);
token = COM_ParseExt( &p, qtrue );
if ( token )
{
numIPFilters = atoi(token);
for ( i = 0 ; i < numIPFilters ; i++ )
{
token = COM_ParseExt( &p, qtrue );
if ( token )
{//have an ip
if ( !Q_stricmp("unused",token) )
{
ipFilters[i].compare = 0xffffffffu;
}
else
{
StringToFilter(token,&ipFilters[i]);
}
}
else
{
break;
}
}
}
G_Printf ( "G_LoadBanIP - banlist.dat ^3LOADED SUCCESSFULLY^7:\n" ); // comment this out if u dont need a successful message
}
/*
=================
G_ProcessBanList
=================
*/
void G_ProcessBanList( void )
{
G_SaveBanIP(); // add new stuff to the list
G_LoadIPBans(); // reload the list
}
Code: Select all
UpdateIPBans();
Code: Select all
G_ProcessBanList();
okay now, open up g_local.h and add this in the area where there are some defines for g_svcmds.c:
Code: Select all
void G_ProcessBanList( void ); // store new values in file; reload it for security
it should now look something like this:
Code: Select all
/*
============
G_InitGame
============
*/
extern void G_LoadIPBans(void); // ensiform
void G_InitGame( int levelTime, int randomSeed, int restart ) { ...
in that function comment or delete this:
Code: Select all
G_ProcessIPBans();
Code: Select all
G_LoadIPBans();
it should now look something like this:
Code: Select all
/*
=================
G_ShutdownGame
=================
*/
extern void G_SaveBanIP( void ); // ensiform
void G_ShutdownGame( int restart ) {
G_Printf ("==== ShutdownGame ====\n");
Code: Select all
G_SaveBanIP();
Code: Select all
if (Q_stricmp (cmd, "listip") == 0) {
Svcmd_ListIPs_f();
//trap_SendConsoleCommand( EXEC_NOW, "g_banIPs\n" );
return qtrue;
}
if (Q_stricmp (cmd, "reloadBans") == 0) {
G_LoadIPBans();
return qtrue;
}
if u need any assistance, like line numbers etc, feel free to ask.
Last edited by ensiform on Sat Sep 17, 2005 11:55 pm, edited 1 time in total.
Code: Select all
char banIPBuffer[MAX_IPFILTERS*32]; // The list of file names read in
-
- Posts: 304
- Joined: Fri Aug 08, 2003 7:00 am
Details
Can you PM me with more details? thanks.ensiform wrote:c add the following above the entitylist function:.

[url=http://www.play-casinos.d-4u.com]Play Casinos[/url] [url=http://virtual-online-gambling-10.9a7.net]gambling no download[/url]