get new ban and auth code innitialising right

This commit is contained in:
darkrose 2017-05-10 22:39:38 +10:00
parent 1b88f95b25
commit 62d033da29
2 changed files with 14 additions and 6 deletions

View File

@ -129,7 +129,7 @@ int auth_init(char* file)
return -1; return -1;
} }
path = path_get("game",file,0,NULL,0); path = path_get("world",file,0,NULL,0);
if (!path) if (!path)
return -1; return -1;
@ -158,17 +158,22 @@ int auth_init(char* file)
/* free auth memory, reset auth struct */ /* free auth memory, reset auth struct */
void auth_exit() void auth_exit()
{ {
if (!auth.mutex)
return;
if (auth.modified) if (auth.modified)
auth_save(); auth_save();
mutex_free(auth.mutex); if (auth.mutex)
mutex_free(auth.mutex);
auth.mutex = NULL; auth.mutex = NULL;
if (auth.file) if (auth.file)
free(auth.file); free(auth.file);
auth.file = NULL; auth.file = NULL;
nvp_free(&auth.data,1); if (auth.data)
nvp_free(&auth.data,1);
auth.data = NULL; auth.data = NULL;
auth.modified = 0; auth.modified = 0;
@ -193,7 +198,7 @@ void auth_load()
return; return;
} }
while (file_readline(f,line,512)) { while (file_readline(f,line,512) > 0) {
n = line; n = line;
p = strchr(n,':'); p = strchr(n,':');

View File

@ -51,7 +51,7 @@ int ban_init(char* file)
return -1; return -1;
} }
path = path_get("game",file,0,NULL,0); path = path_get("world",file,0,NULL,0);
if (!path) if (!path)
return -1; return -1;
@ -80,6 +80,9 @@ int ban_init(char* file)
/* free ban memory, reset ban struct */ /* free ban memory, reset ban struct */
void ban_exit() void ban_exit()
{ {
if (!ban.mutex)
return;
if (ban.modified) if (ban.modified)
ban_save(); ban_save();
@ -112,7 +115,7 @@ void ban_load()
return; return;
} }
while (file_readline(f,line,512)) { while (file_readline(f,line,512) > 0) {
p = line; p = line;
n = strchr(p,'|'); n = strchr(p,'|');