Fix crash on Windows when dumping admin cache to file.

This commit is contained in:
Nicholas Hastings
2014-10-08 17:31:02 -07:00
parent ac96bb177a
commit 512fae4c25
5 changed files with 16 additions and 12 deletions
+11 -1
View File
@@ -1762,7 +1762,7 @@ void iterator_group_grp_override(FILE *fp, const char *key, OverrideRule rule)
fprintf(fp, "\t\t\t\"@%s\"\t\t\"%s\"\n", key, str);
}
void AdminCache::DumpCache(FILE *fp)
bool AdminCache::DumpCache(const char *filename)
{
int *itable;
AdminId aid;
@@ -1771,6 +1771,12 @@ void AdminCache::DumpCache(FILE *fp)
unsigned int num;
AdminUser *pAdmin;
AdminGroup *pGroup;
FILE *fp;
if ((fp = fopen(filename, "wt")) == NULL)
{
return false;
}
fprintf(fp, "\"Groups\"\n{\n");
@@ -1901,6 +1907,10 @@ void AdminCache::DumpCache(FILE *fp)
for (FlagMap::iterator iter = m_CmdOverrides.iter(); !iter.empty(); iter.next())
iterator_glob_basic_override(fp, iter->key.chars(), iter->value);
fprintf(fp, "}\n");
fclose(fp);
return true;
}
AdminGroup *AdminCache::GetGroup(GroupId gid)
+1 -1
View File
@@ -183,7 +183,7 @@ public: //IAdminSystem
bool IsValidAdmin(AdminId id);
bool CheckClientCommandAccess(int client, const char *cmd, FlagBits cmdflags);
public:
void DumpCache(FILE *fp);
bool DumpCache(const char *filename);
AdminGroup *GetGroup(GroupId gid);
AdminUser *GetUser(AdminId id);
const char *GetString(int idx);
+2 -2
View File
@@ -108,9 +108,9 @@ static void DumpHandles(void (*dumpfn)(const char *fmt, ...))
g_HandleSys.Dump(dumpfn);
}
static void DumpAdminCache(FILE *f)
static bool DumpAdminCache(const char *filename)
{
g_Admins.DumpCache(f);
return g_Admins.DumpCache(filename);
}
static void RegisterProfiler(IProfilingTool *tool)
+1 -1
View File
@@ -350,7 +350,7 @@ struct sm_logic_t
void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...);
void (*AddNatives)(sp_nativeinfo_t *natives);
void (*DumpHandles)(void (*dumpfn)(const char *fmt, ...));
void (*DumpAdminCache)(FILE *);
bool (*DumpAdminCache)(const char *filename);
void (*RegisterProfiler)(IProfilingTool *tool);
IScriptManager *scripts;
IShareSys *sharesys;