Convert admin SQL plugins to use AdminId/GroupId methodmaps, newdecls.

This commit is contained in:
Nicholas Hastings 2015-02-17 09:13:40 -08:00
parent 63d1fa2d8e
commit a541acb2bc
2 changed files with 90 additions and 90 deletions

View File

@ -36,7 +36,7 @@
#include <sourcemod> #include <sourcemod>
public Plugin:myinfo = public Plugin myinfo =
{ {
name = "SQL Admins (Prefetch)", name = "SQL Admins (Prefetch)",
author = "AlliedModders LLC", author = "AlliedModders LLC",
@ -45,7 +45,7 @@ public Plugin:myinfo =
url = "http://www.sourcemod.net/" url = "http://www.sourcemod.net/"
}; };
public OnRebuildAdminCache(AdminCachePart:part) public void OnRebuildAdminCache(AdminCachePart part)
{ {
/* First try to get a database connection */ /* First try to get a database connection */
char error[255]; char error[255];
@ -97,7 +97,7 @@ void FetchUsers(Database db)
char name[80]; char name[80];
int immunity; int immunity;
AdminId adm; AdminId adm;
GroupId gid; GroupId grp;
int id; int id;
/* Keep track of a mapping from admin DB IDs to internal AdminIds to /* Keep track of a mapping from admin DB IDs to internal AdminIds to
@ -120,7 +120,7 @@ void FetchUsers(Database db)
if ((adm = FindAdminByIdentity(authtype, identity)) == INVALID_ADMIN_ID) if ((adm = FindAdminByIdentity(authtype, identity)) == INVALID_ADMIN_ID)
{ {
adm = CreateAdmin(name); adm = CreateAdmin(name);
if (!BindAdminIdentity(adm, authtype, identity)) if (!adm.BindIdentity(authtype, identity))
{ {
LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity); LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity);
continue; continue;
@ -136,22 +136,22 @@ void FetchUsers(Database db)
/* See if this admin wants a password */ /* See if this admin wants a password */
if (password[0] != '\0') if (password[0] != '\0')
{ {
SetAdminPassword(adm, password); adm.SetPassword(password);
} }
/* Apply each flag */ /* Apply each flag */
int len = strlen(flags); int len = strlen(flags);
AdminFlag flag; AdminFlag flag;
for (new i=0; i<len; i++) for (int i=0; i<len; i++)
{ {
if (!FindFlagByChar(flags[i], flag)) if (!FindFlagByChar(flags[i], flag))
{ {
continue; continue;
} }
SetAdminFlag(adm, flag, true); adm.SetFlag(flag, true);
} }
SetAdminImmunityLevel(adm, immunity); adm.ImmunityLevel = immunity;
} }
delete rs; delete rs;
@ -173,13 +173,13 @@ void FetchUsers(Database db)
if (htAdmins.GetValue(key, adm)) if (htAdmins.GetValue(key, adm))
{ {
if ((gid = FindAdmGroup(group)) == INVALID_GROUP_ID) if ((grp = FindAdmGroup(group)) == INVALID_GROUP_ID)
{ {
/* Group wasn't found, don't bother with it. */ /* Group wasn't found, don't bother with it. */
continue; continue;
} }
AdminInheritGroup(adm, gid); adm.InheritGroup(grp);
} }
} }
@ -187,7 +187,7 @@ void FetchUsers(Database db)
delete htAdmins; delete htAdmins;
} }
FetchGroups(Database db) void FetchGroups(Database db)
{ {
char query[255]; char query[255];
DBResultSet rs; DBResultSet rs;
@ -218,26 +218,26 @@ FetchGroups(Database db)
#endif #endif
/* Find or create the group */ /* Find or create the group */
GroupId gid; GroupId grp;
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
{ {
gid = CreateAdmGroup(name); grp = CreateAdmGroup(name);
} }
/* Add flags from the database to the group */ /* Add flags from the database to the group */
int num_flag_chars = strlen(flags); int num_flag_chars = strlen(flags);
for (new i=0; i<num_flag_chars; i++) for (int i=0; i<num_flag_chars; i++)
{ {
decl AdminFlag:flag; AdminFlag flag;
if (!FindFlagByChar(flags[i], flag)) if (!FindFlagByChar(flags[i], flag))
{ {
continue; continue;
} }
SetAdmGroupAddFlag(gid, flag, true); grp.SetFlag(flag, true);
} }
/* Set the immunity level this group has */ /* Set the immunity level this group has */
SetAdmGroupImmunityLevel(gid, immunity); grp.ImmunityLevel = immunity;
} }
delete rs; delete rs;
@ -245,7 +245,7 @@ FetchGroups(Database db)
/** /**
* Get immunity in a big lump. This is a nasty query but it gets the job done. * Get immunity in a big lump. This is a nasty query but it gets the job done.
*/ */
new len = 0; int len = 0;
len += Format(query[len], sizeof(query)-len, "SELECT g1.name, g2.name FROM sm_group_immunity gi"); len += Format(query[len], sizeof(query)-len, "SELECT g1.name, g2.name FROM sm_group_immunity gi");
len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g1 ON g1.id = gi.group_id "); len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g1 ON g1.id = gi.group_id ");
len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g2 ON g2.id = gi.other_id"); len += Format(query[len], sizeof(query)-len, " LEFT JOIN sm_groups g2 ON g2.id = gi.other_id");
@ -263,20 +263,20 @@ FetchGroups(Database db)
{ {
char group1[80]; char group1[80];
char group2[80]; char group2[80];
GroupId gid1, gid2; GroupId grp, other;
rs.FetchString(0, group1, sizeof(group1)); rs.FetchString(0, group1, sizeof(group1));
rs.FetchString(1, group2, sizeof(group2)); rs.FetchString(1, group2, sizeof(group2));
if (((gid1 = FindAdmGroup(group1)) == INVALID_GROUP_ID) if (((grp = FindAdmGroup(group1)) == INVALID_GROUP_ID)
|| (gid2 = FindAdmGroup(group2)) == INVALID_GROUP_ID) || (other = FindAdmGroup(group2)) == INVALID_GROUP_ID)
{ {
continue; continue;
} }
SetAdmGroupImmuneFrom(gid1, gid2); grp.AddGroupImmunity(other);
#if defined _DEBUG #if defined _DEBUG
PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", gid1, gid2); PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", grp, other);
#endif #endif
} }
@ -306,8 +306,8 @@ FetchGroups(Database db)
rs.FetchString(2, cmd, sizeof(cmd)); rs.FetchString(2, cmd, sizeof(cmd));
rs.FetchString(3, access, sizeof(access)); rs.FetchString(3, access, sizeof(access));
GroupId gid; GroupId grp;
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
{ {
continue; continue;
} }
@ -325,16 +325,16 @@ FetchGroups(Database db)
} }
#if defined _DEBUG #if defined _DEBUG
PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", gid, cmd, o_type, o_rule); PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", grp, cmd, o_type, o_rule);
#endif #endif
AddAdmGroupCmdOverride(gid, cmd, o_type, o_rule); grp.AddCommandOverride(cmd, o_type, o_rule);
} }
delete rs; delete rs;
} }
FetchOverrides(Database db) void FetchOverrides(Database db)
{ {
char query[255]; char query[255];
DBResultSet rs; DBResultSet rs;

View File

@ -36,7 +36,7 @@
#include <sourcemod> #include <sourcemod>
public Plugin:myinfo = public Plugin myinfo =
{ {
name = "SQL Admins (Threaded)", name = "SQL Admins (Threaded)",
author = "AlliedModders LLC", author = "AlliedModders LLC",
@ -68,15 +68,15 @@ public Plugin:myinfo =
*/ */
Database hDatabase = null; /** Database connection */ Database hDatabase = null; /** Database connection */
new g_sequence = 0; /** Global unique sequence number */ int g_sequence = 0; /** Global unique sequence number */
new ConnectLock = 0; /** Connect sequence number */ int ConnectLock = 0; /** Connect sequence number */
new RebuildCachePart[3] = {0}; /** Cache part sequence numbers */ int RebuildCachePart[3] = {0}; /** Cache part sequence numbers */
new PlayerSeq[MAXPLAYERS+1]; /** Player-specific sequence numbers */ int PlayerSeq[MAXPLAYERS+1]; /** Player-specific sequence numbers */
new bool:PlayerAuth[MAXPLAYERS+1]; /** Whether a player has been "pre-authed" */ bool PlayerAuth[MAXPLAYERS+1]; /** Whether a player has been "pre-authed" */
//#define _DEBUG //#define _DEBUG
public OnMapEnd() public void OnMapEnd()
{ {
/** /**
* Clean up on map end just so we can start a fresh connection when we need it later. * Clean up on map end just so we can start a fresh connection when we need it later.
@ -84,14 +84,14 @@ public OnMapEnd()
delete hDatabase; delete hDatabase;
} }
public bool:OnClientConnect(client, String:rejectmsg[], maxlen) public bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
{ {
PlayerSeq[client] = 0; PlayerSeq[client] = 0;
PlayerAuth[client] = false; PlayerAuth[client] = false;
return true; return true;
} }
public OnClientDisconnect(client) public void OnClientDisconnect(int client)
{ {
PlayerSeq[client] = 0; PlayerSeq[client] = 0;
PlayerAuth[client] = false; PlayerAuth[client] = false;
@ -128,22 +128,22 @@ public void OnDatabaseConnect(Database db, const char[] error, any data)
/** /**
* See if we need to get any of the cache stuff now. * See if we need to get any of the cache stuff now.
*/ */
new sequence; int sequence;
if ((sequence = RebuildCachePart[_:AdminCache_Overrides]) != 0) if ((sequence = RebuildCachePart[AdminCache_Overrides]) != 0)
{ {
FetchOverrides(hDatabase, sequence); FetchOverrides(hDatabase, sequence);
} }
if ((sequence = RebuildCachePart[_:AdminCache_Groups]) != 0) if ((sequence = RebuildCachePart[AdminCache_Groups]) != 0)
{ {
FetchGroups(hDatabase, sequence); FetchGroups(hDatabase, sequence);
} }
if ((sequence = RebuildCachePart[_:AdminCache_Admins]) != 0) if ((sequence = RebuildCachePart[AdminCache_Admins]) != 0)
{ {
FetchUsersWeCan(hDatabase); FetchUsersWeCan(hDatabase);
} }
} }
RequestDatabaseConnection() void RequestDatabaseConnection()
{ {
ConnectLock = ++g_sequence; ConnectLock = ++g_sequence;
if (SQL_CheckConfig("admins")) if (SQL_CheckConfig("admins"))
@ -154,7 +154,7 @@ RequestDatabaseConnection()
} }
} }
public OnRebuildAdminCache(AdminCachePart part) public void OnRebuildAdminCache(AdminCachePart part)
{ {
/** /**
* Mark this part of the cache as being rebuilt. This is used by the * Mark this part of the cache as being rebuilt. This is used by the
@ -162,7 +162,7 @@ public OnRebuildAdminCache(AdminCachePart part)
* used. * used.
*/ */
int sequence = ++g_sequence; int sequence = ++g_sequence;
RebuildCachePart[_:part] = sequence; RebuildCachePart[part] = sequence;
/** /**
* If we don't have a database connection, we can't do any lookups just yet. * If we don't have a database connection, we can't do any lookups just yet.
@ -189,7 +189,7 @@ public OnRebuildAdminCache(AdminCachePart part)
} }
} }
public Action OnClientPreAdminCheck(client) public Action OnClientPreAdminCheck(int client)
{ {
PlayerAuth[client] = true; PlayerAuth[client] = true;
@ -209,7 +209,7 @@ public Action OnClientPreAdminCheck(client)
* the user's normal connection flow. The database will soon auth the user * the user's normal connection flow. The database will soon auth the user
* normally. * normally.
*/ */
if (RebuildCachePart[_:AdminCache_Admins] != 0) if (RebuildCachePart[AdminCache_Admins] != 0)
{ {
return Plugin_Continue; return Plugin_Continue;
} }
@ -272,22 +272,22 @@ public void OnReceiveUserGroups(Database db, DBResultSet rs, const char[] error,
} }
char name[80]; char name[80];
GroupId gid; GroupId grp;
while (rs.FetchRow()) while (rs.FetchRow())
{ {
rs.FetchString(0, name, sizeof(name)); rs.FetchString(0, name, sizeof(name));
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
{ {
continue; continue;
} }
#if defined _DEBUG #if defined _DEBUG
PrintToServer("Binding user group (%d, %d, %d, %s, %d)", client, sequence, adm, name, gid); PrintToServer("Binding user group (%d, %d, %d, %s, %d)", client, sequence, adm, name, grp);
#endif #endif
AdminInheritGroup(adm, gid); adm.InheritGroup(grp);
} }
/** /**
@ -366,18 +366,18 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
/* For dynamic admins we clear anything already in the cache. */ /* For dynamic admins we clear anything already in the cache. */
if ((adm = FindAdminByIdentity(authtype, identity)) != INVALID_ADMIN_ID) if ((adm = FindAdminByIdentity(authtype, identity)) != INVALID_ADMIN_ID)
{ {
RemoveAdmin(adm); adm.Purge();
} }
adm = CreateAdmin(name); adm = CreateAdmin(name);
if (!BindAdminIdentity(adm, authtype, identity)) if (!adm.BindIdentity(authtype, identity))
{ {
LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity); LogError("Could not bind prefetched SQL admin (authtype \"%s\") (identity \"%s\")", authtype, identity);
continue; continue;
} }
user_lookup[total_users][0] = id; user_lookup[total_users][0] = id;
user_lookup[total_users][1] = _:adm; user_lookup[total_users][1] = view_as<int>(adm);
user_lookup[total_users][2] = rs.FetchInt(6); user_lookup[total_users][2] = rs.FetchInt(6);
total_users++; total_users++;
@ -388,21 +388,21 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
/* See if this admin wants a password */ /* See if this admin wants a password */
if (password[0] != '\0') if (password[0] != '\0')
{ {
SetAdminPassword(adm, password); adm.SetPassword(password);
} }
SetAdminImmunityLevel(adm, immunity); adm.ImmunityLevel = immunity;
/* Apply each flag */ /* Apply each flag */
int len = strlen(flags); int len = strlen(flags);
AdminFlag flag; AdminFlag flag;
for (new i=0; i<len; i++) for (int i=0; i<len; i++)
{ {
if (!FindFlagByChar(flags[i], flag)) if (!FindFlagByChar(flags[i], flag))
{ {
continue; continue;
} }
SetAdminFlag(adm, flag, true); adm.SetFlag(flag, true);
} }
} }
@ -415,9 +415,9 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
id = 0; id = 0;
for (new i=0; i<total_users; i++) for (int i=0; i<total_users; i++)
{ {
if (user_lookup[i][1] == _:adm) if (user_lookup[i][1] == view_as<int>(adm))
{ {
id = user_lookup[i][0]; id = user_lookup[i][0];
group_count = user_lookup[i][2]; group_count = user_lookup[i][2];
@ -449,13 +449,13 @@ public void OnReceiveUser(Database db, DBResultSet rs, const char[] error, any d
pk.Reset(); pk.Reset();
pk.WriteCell(client); pk.WriteCell(client);
pk.WriteCell(sequence); pk.WriteCell(sequence);
pk.WriteCell(_:adm); pk.WriteCell(adm);
pk.WriteString(query); pk.WriteString(query);
db.Query(OnReceiveUserGroups, query, pk, DBPrio_High); db.Query(OnReceiveUserGroups, query, pk, DBPrio_High);
} }
FetchUser(Database db, client) void FetchUser(Database db, int client)
{ {
char name[65]; char name[65];
char safe_name[140]; char safe_name[140];
@ -484,7 +484,7 @@ FetchUser(Database db, client)
* Construct the query using the information the user gave us. * Construct the query using the information the user gave us.
*/ */
char query[512]; char query[512];
new len = 0; int len = 0;
len += Format(query[len], sizeof(query)-len, "SELECT a.id, a.authtype, a.identity, a.password, a.flags, a.name, COUNT(ag.group_id), immunity"); len += Format(query[len], sizeof(query)-len, "SELECT a.id, a.authtype, a.identity, a.password, a.flags, a.name, COUNT(ag.group_id), immunity");
len += Format(query[len], sizeof(query)-len, " FROM sm_admins a LEFT JOIN sm_admins_groups ag ON a.id = ag.admin_id WHERE "); len += Format(query[len], sizeof(query)-len, " FROM sm_admins a LEFT JOIN sm_admins_groups ag ON a.id = ag.admin_id WHERE ");
@ -516,7 +516,7 @@ FetchUser(Database db, client)
db.Query(OnReceiveUser, query, pk, DBPrio_High); db.Query(OnReceiveUser, query, pk, DBPrio_High);
} }
FetchUsersWeCan(Database db) void FetchUsersWeCan(Database db)
{ {
for (int i=1; i<=MaxClients; i++) for (int i=1; i<=MaxClients; i++)
{ {
@ -529,7 +529,7 @@ FetchUsersWeCan(Database db)
/** /**
* This round of updates is done. Go in peace. * This round of updates is done. Go in peace.
*/ */
RebuildCachePart[_:AdminCache_Admins] = 0; RebuildCachePart[AdminCache_Admins] = 0;
} }
@ -542,7 +542,7 @@ public void OnReceiveGroupImmunity(Database db, DBResultSet rs, const char[] err
* Check if this is the latest result request. * Check if this is the latest result request.
*/ */
int sequence = pk.ReadCell(); int sequence = pk.ReadCell();
if (RebuildCachePart[_:AdminCache_Groups] != sequence) if (RebuildCachePart[AdminCache_Groups] != sequence)
{ {
/* Discard everything, since we're out of sequence. */ /* Discard everything, since we're out of sequence. */
delete pk; delete pk;
@ -569,28 +569,28 @@ public void OnReceiveGroupImmunity(Database db, DBResultSet rs, const char[] err
{ {
char group1[80]; char group1[80];
char group2[80]; char group2[80];
GroupId gid1, gid2; GroupId grp, other;
rs.FetchString(0, group1, sizeof(group1)); rs.FetchString(0, group1, sizeof(group1));
rs.FetchString(1, group2, sizeof(group2)); rs.FetchString(1, group2, sizeof(group2));
if (((gid1 = FindAdmGroup(group1)) == INVALID_GROUP_ID) if (((grp = FindAdmGroup(group1)) == INVALID_GROUP_ID)
|| (gid2 = FindAdmGroup(group2)) == INVALID_GROUP_ID) || (other = FindAdmGroup(group2)) == INVALID_GROUP_ID)
{ {
continue; continue;
} }
SetAdmGroupImmuneFrom(gid1, gid2); grp.AddGroupImmunity(other);
#if defined _DEBUG #if defined _DEBUG
PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", gid1, gid2); PrintToServer("SetAdmGroupImmuneFrom(%d, %d)", grp, other);
#endif #endif
} }
/* Clear the sequence so another connect doesn't refetch */ /* Clear the sequence so another connect doesn't refetch */
RebuildCachePart[_:AdminCache_Groups] = 0; RebuildCachePart[AdminCache_Groups] = 0;
} }
public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, any data) public void OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error, any data)
{ {
DataPack pk = view_as<DataPack>(data); DataPack pk = view_as<DataPack>(data);
pk.Reset(); pk.Reset();
@ -599,7 +599,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
* Check if this is the latest result request. * Check if this is the latest result request.
*/ */
int sequence = pk.ReadCell(); int sequence = pk.ReadCell();
if (RebuildCachePart[_:AdminCache_Groups] != sequence) if (RebuildCachePart[AdminCache_Groups] != sequence)
{ {
/* Discard everything, since we're out of sequence. */ /* Discard everything, since we're out of sequence. */
delete pk; delete pk;
@ -626,7 +626,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
char type[16]; char type[16];
char command[64]; char command[64];
char access[16]; char access[16];
GroupId gid; GroupId grp;
while (rs.FetchRow()) while (rs.FetchRow())
{ {
rs.FetchString(0, name, sizeof(name)); rs.FetchString(0, name, sizeof(name));
@ -635,7 +635,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
rs.FetchString(3, access, sizeof(access)); rs.FetchString(3, access, sizeof(access));
/* Find the group. This is actually faster than doing the ID lookup. */ /* Find the group. This is actually faster than doing the ID lookup. */
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
{ {
/* Oh well, just ignore it. */ /* Oh well, just ignore it. */
continue; continue;
@ -654,10 +654,10 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
} }
#if defined _DEBUG #if defined _DEBUG
PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", gid, command, o_type, o_rule); PrintToServer("AddAdmGroupCmdOverride(%d, %s, %d, %d)", grp, command, o_type, o_rule);
#endif #endif
AddAdmGroupCmdOverride(gid, command, o_type, o_rule); grp.AddCommandOverride(command, o_type, o_rule);
} }
/** /**
@ -676,7 +676,7 @@ public OnReceiveGroupOverrides(Database db, DBResultSet rs, const char[] error,
db.Query(OnReceiveGroupImmunity, query, pk, DBPrio_High); db.Query(OnReceiveGroupImmunity, query, pk, DBPrio_High);
} }
public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data) public void OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data)
{ {
DataPack pk = view_as<DataPack>(data); DataPack pk = view_as<DataPack>(data);
pk.Reset(); pk.Reset();
@ -685,7 +685,7 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data
* Check if this is the latest result request. * Check if this is the latest result request.
*/ */
int sequence = pk.ReadCell(); int sequence = pk.ReadCell();
if (RebuildCachePart[_:AdminCache_Groups] != sequence) if (RebuildCachePart[AdminCache_Groups] != sequence)
{ {
/* Discard everything, since we're out of sequence. */ /* Discard everything, since we're out of sequence. */
delete pk; delete pk;
@ -722,25 +722,25 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data
#endif #endif
/* Find or create the group */ /* Find or create the group */
GroupId gid; GroupId grp;
if ((gid = FindAdmGroup(name)) == INVALID_GROUP_ID) if ((grp = FindAdmGroup(name)) == INVALID_GROUP_ID)
{ {
gid = CreateAdmGroup(name); grp = CreateAdmGroup(name);
} }
/* Add flags from the database to the group */ /* Add flags from the database to the group */
int num_flag_chars = strlen(flags); int num_flag_chars = strlen(flags);
for (int i=0; i<num_flag_chars; i++) for (int i=0; i<num_flag_chars; i++)
{ {
decl AdminFlag:flag; AdminFlag flag;
if (!FindFlagByChar(flags[i], flag)) if (!FindFlagByChar(flags[i], flag))
{ {
continue; continue;
} }
SetAdmGroupAddFlag(gid, flag, true); grp.SetFlag(flag, true);
} }
SetAdmGroupImmunityLevel(gid, immunity); grp.ImmunityLevel = immunity;
} }
/** /**
@ -758,7 +758,7 @@ public OnReceiveGroups(Database db, DBResultSet rs, const char[] error, any data
db.Query(OnReceiveGroupOverrides, query, pk, DBPrio_High); db.Query(OnReceiveGroupOverrides, query, pk, DBPrio_High);
} }
void FetchGroups(Database db, sequence) void FetchGroups(Database db, int sequence)
{ {
char query[255]; char query[255];
@ -780,7 +780,7 @@ public void OnReceiveOverrides(Database db, DBResultSet rs, const char[] error,
* Check if this is the latest result request. * Check if this is the latest result request.
*/ */
int sequence = pk.ReadCell(); int sequence = pk.ReadCell();
if (RebuildCachePart[_:AdminCache_Overrides] != sequence) if (RebuildCachePart[AdminCache_Overrides] != sequence)
{ {
/* Discard everything, since we're out of sequence. */ /* Discard everything, since we're out of sequence. */
delete pk; delete pk;
@ -829,10 +829,10 @@ public void OnReceiveOverrides(Database db, DBResultSet rs, const char[] error,
} }
/* Clear the sequence so another connect doesn't refetch */ /* Clear the sequence so another connect doesn't refetch */
RebuildCachePart[_:AdminCache_Overrides] = 0; RebuildCachePart[AdminCache_Overrides] = 0;
} }
void FetchOverrides(Database db, sequence) void FetchOverrides(Database db, int sequence)
{ {
char query[255]; char query[255];