Skip to content
Snippets Groups Projects
Commit afe85ced authored by sphere's avatar sphere
Browse files

Merge branch 'fix-banlist-cleared-startup-error' into 'next'

Fix banlist being cleared if server fails to start

See merge request STJr/SRB2!2379
parents 908f0962 74673b8e
No related branches found
No related tags found
No related merge requests found
......@@ -41,6 +41,8 @@ typedef struct banreason_s
static banreason_t *reasontail = NULL; //last entry, use prev
static banreason_t *reasonhead = NULL; //1st entry, use next
static boolean bans_loaded = false;
void Ban_Add(const char *reason)
{
banreason_t *reasonlist = malloc(sizeof(*reasonlist));
......@@ -85,6 +87,8 @@ void Ban_Load_File(boolean warning)
if (!I_ClearBans)
return;
bans_loaded = true;
f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r");
if (!f)
......@@ -124,6 +128,12 @@ void D_SaveBan(void)
const char *address, *mask;
const char *path = va("%s"PATHSEP"%s", srb2home, "ban.txt");
if (!bans_loaded)
{
// don't save bans if they were never loaded.
return;
}
if (!reasonhead)
{
remove(path);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment