mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-25 05:41:42 +00:00
Fix banlist being cleared if server fails to start
This commit is contained in:
parent
908f096200
commit
74673b8e1b
1 changed files with 10 additions and 0 deletions
|
@ -41,6 +41,8 @@ typedef struct banreason_s
|
||||||
static banreason_t *reasontail = NULL; //last entry, use prev
|
static banreason_t *reasontail = NULL; //last entry, use prev
|
||||||
static banreason_t *reasonhead = NULL; //1st entry, use next
|
static banreason_t *reasonhead = NULL; //1st entry, use next
|
||||||
|
|
||||||
|
static boolean bans_loaded = false;
|
||||||
|
|
||||||
void Ban_Add(const char *reason)
|
void Ban_Add(const char *reason)
|
||||||
{
|
{
|
||||||
banreason_t *reasonlist = malloc(sizeof(*reasonlist));
|
banreason_t *reasonlist = malloc(sizeof(*reasonlist));
|
||||||
|
@ -85,6 +87,8 @@ void Ban_Load_File(boolean warning)
|
||||||
if (!I_ClearBans)
|
if (!I_ClearBans)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
bans_loaded = true;
|
||||||
|
|
||||||
f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r");
|
f = fopen(va("%s"PATHSEP"%s", srb2home, "ban.txt"), "r");
|
||||||
|
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -124,6 +128,12 @@ void D_SaveBan(void)
|
||||||
const char *address, *mask;
|
const char *address, *mask;
|
||||||
const char *path = va("%s"PATHSEP"%s", srb2home, "ban.txt");
|
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)
|
if (!reasonhead)
|
||||||
{
|
{
|
||||||
remove(path);
|
remove(path);
|
||||||
|
|
Loading…
Reference in a new issue