Merge branch 'reload-bans' into 'next'

Fix reloadbans clearing ban.txt and clearbans not actually saving the changes

See merge request STJr/SRB2!1215
This commit is contained in:
James R 2020-12-10 14:28:13 -05:00
commit a5d228773d
1 changed files with 21 additions and 13 deletions

View File

@ -2260,11 +2260,15 @@ void D_SaveBan(void)
size_t i;
banreason_t *reasonlist = reasonhead;
const char *address, *mask;
const char *path = va("%s"PATHSEP"%s", srb2home, "ban.txt");
if (!reasonhead)
{
remove(path);
return;
}
f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "w");
f = fopen(path, "w");
if (!f)
{
@ -2308,16 +2312,14 @@ static void Ban_Add(const char *reason)
reasontail = reasonlist;
}
static void Command_ClearBans(void)
static void Ban_Clear(void)
{
banreason_t *temp;
if (!I_ClearBans)
return;
I_ClearBans();
D_SaveBan();
reasontail = NULL;
while (reasonhead)
{
temp = reasonhead->next;
@ -2327,6 +2329,15 @@ static void Command_ClearBans(void)
}
}
static void Command_ClearBans(void)
{
if (!I_ClearBans)
return;
Ban_Clear();
D_SaveBan();
}
static void Ban_Load_File(boolean warning)
{
FILE *f;
@ -2334,6 +2345,9 @@ static void Ban_Load_File(boolean warning)
const char *address, *mask;
char buffer[MAX_WADPATH];
if (!I_ClearBans)
return;
f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r");
if (!f)
@ -2343,13 +2357,7 @@ static void Ban_Load_File(boolean warning)
return;
}
if (I_ClearBans)
Command_ClearBans();
else
{
fclose(f);
return;
}
Ban_Clear();
for (i=0; fgets(buffer, (int)sizeof(buffer), f); i++)
{