- build fix for without curses (untested, but should fix the problem I

had when I last tried)
- fix sv_filter_automask so it's not inverted (doh, again!)
- cleanups of ip filter prints
This commit is contained in:
Adam Olsen 2001-09-20 06:51:25 +00:00
parent fc1ab9640e
commit 0977b555f3
2 changed files with 16 additions and 9 deletions

View file

@ -112,8 +112,8 @@ C_Init (void)
{ {
cvar_t *curses = Cvar_Get ("sv_use_curses", "1", CVAR_ROM, NULL, cvar_t *curses = Cvar_Get ("sv_use_curses", "1", CVAR_ROM, NULL,
"set to 0 to disable curses server console"); "set to 0 to disable curses server console");
use_curses = curses->int_val;
#ifdef HAVE_CURSES_H #ifdef HAVE_CURSES_H
use_curses = curses->int_val;
if (use_curses) { if (use_curses) {
initscr (); initscr ();
start_color (); start_color ();

View file

@ -1247,14 +1247,15 @@ SV_StringToFilter (const char *address, ipfilter_t *f)
// change trailing 0 segments to be a mask, eg 1.2.0.0 gives a /16 mask // change trailing 0 segments to be a mask, eg 1.2.0.0 gives a /16 mask
if (mask == -1) { if (mask == -1) {
mask = 0;
if (sv_filter_automask->int_val) { if (sv_filter_automask->int_val) {
mask = sizeof (b) * 8;
i = sizeof (b) - 1; i = sizeof (b) - 1;
while (i >= 0 && !b[i]) { while (i >= 0 && !b[i]) {
mask += 8; mask -= 8;
i--; i--;
} }
} } else
mask = 0;
} }
#ifdef HAVE_IPV6 #ifdef HAVE_IPV6
} }
@ -1300,7 +1301,7 @@ SV_CleanIPList (void)
char *type; char *type;
for (i = 0; i < numipfilters;) { for (i = 0; i < numipfilters;) {
if (ipfilters[i].time && (ipfilters[i].time < realtime)) { if (ipfilters[i].time && (ipfilters[i].time <= realtime)) {
switch (ipfilters[i].type) { switch (ipfilters[i].type) {
case ft_ban: type = "Ban"; break; case ft_ban: type = "Ban"; break;
case ft_mute: type = "Mute"; break; case ft_mute: type = "Mute"; break;
@ -1396,6 +1397,9 @@ SV_AddIP_f (void)
// FIXME: print on the console too // FIXME: print on the console too
} }
} }
SV_Printf ("Added IP Filter for %s/%u\n",
SV_PrintIP (ipfilters[numipfilters].ip),
ipfilters[numipfilters].mask);
numipfilters++; numipfilters++;
} }
} }
@ -1411,10 +1415,11 @@ SV_RemoveIP_f (void)
for (i = 0; i < numipfilters; i++) for (i = 0; i < numipfilters; i++)
if (ipfilters[i].mask == f.mask && SV_IPCompare (ipfilters[i].ip, f.ip)) { if (ipfilters[i].mask == f.mask && SV_IPCompare (ipfilters[i].ip, f.ip)) {
SV_RemoveIPFilter (i); SV_RemoveIPFilter (i);
SV_Printf ("Removed.\n"); SV_Printf ("Removed IP Filter for %s/%u.\n",
SV_PrintIP (f.ip), f.mask);
return; return;
} }
SV_Printf ("Didn't find %s.\n", Cmd_Argv (1)); SV_Printf ("Didn't find %s/%u.\n", SV_PrintIP (f.ip), f.mask);
} }
void void
@ -1424,7 +1429,7 @@ SV_ListIP_f (void)
char *type; char *type;
char timestr[30]; char timestr[30];
SV_Printf ("Filter list:\n"); SV_Printf ("IP Filter list:\n");
for (i = 0; i < numipfilters; i++) { for (i = 0; i < numipfilters; i++) {
switch (ipfilters[i].type) { switch (ipfilters[i].type) {
case ft_ban: type = "Ban:"; break; case ft_ban: type = "Ban:"; break;
@ -1442,6 +1447,8 @@ SV_ListIP_f (void)
SV_Printf ("%-5s %-10s %s/%u\n", type, timestr, SV_Printf ("%-5s %-10s %s/%u\n", type, timestr,
SV_PrintIP (ipfilters[i].ip), ipfilters[i].mask); SV_PrintIP (ipfilters[i].ip), ipfilters[i].mask);
} }
SV_Printf ("%d IP Filter%s\n", numipfilters,
numipfilters == 1 ? "" : "s");
} }
void void
@ -1454,7 +1461,7 @@ SV_WriteIP_f (void)
snprintf (name, sizeof (name), "%s/listip.cfg", com_gamedir); snprintf (name, sizeof (name), "%s/listip.cfg", com_gamedir);
SV_Printf ("Writing %s.\n", name); SV_Printf ("Writing IP Filters to %s.\n", name);
f = Qopen (name, "wb"); f = Qopen (name, "wb");
if (!f) { if (!f) {