summaryrefslogtreecommitdiffstats
path: root/src/RankManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/RankManager.cpp254
1 files changed, 127 insertions, 127 deletions
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index 922d9768e..0c6ef508e 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -25,14 +25,14 @@ public:
m_MojangAPI(a_MojangAPI)
{
}
-
-
-
+
+
+
/** Performs the complete migration from INI files to DB. */
bool Migrate(void)
{
cRankManager::cMassChangeLock Lock(m_RankManager);
-
+
LOGD("Reading groups...");
if (!ReadGroups())
{
@@ -52,16 +52,16 @@ public:
CleanUserGroups();
LOGD("Resolving user UUIDs...");
ResolveUserUUIDs();
-
+
LOGD("Setting ranks...");
SetRanks();
LOGD("Creating defaults...");
CreateDefaults();
-
+
return true;
}
-
+
protected:
/** Container for a group read from an INI file. */
@@ -71,9 +71,9 @@ protected:
AString m_Color;
AStringVector m_Inherits;
AStringVector m_Permissions;
-
+
sGroup(void) {}
-
+
sGroup(const AString & a_Name, const AString & a_Color, const AStringVector & a_Inherits, const AStringVector & a_Permissions):
m_Name(a_Name),
m_Color(a_Color),
@@ -83,23 +83,23 @@ protected:
}
};
typedef std::map<AString, sGroup> sGroupMap;
-
-
+
+
/** Container for a single user read from an INI file. */
struct sUser
{
AString m_Name;
AStringVector m_Groups;
-
+
/** Assigned by ResolveUserUUIDs(), contains the online (Mojang) UUID of the player. */
AString m_UUID;
/** Assigned by ResolveUserUUIDs(), contains the offline (generated) UUID of the player. */
AString m_OfflineUUID;
-
-
+
+
sUser(void) {}
-
+
sUser(const AString & a_Name, const AStringVector & a_Groups):
m_Name(a_Name),
m_Groups(a_Groups)
@@ -107,22 +107,22 @@ protected:
}
};
typedef std::map<AString, sUser> sUserMap;
-
+
typedef std::map<AString, AString> cStringMap;
-
-
+
+
/** The parent Rank manager where we will create the groups, ranks and players */
cRankManager & m_RankManager;
-
+
/** The player name to UUID resolver */
cMojangAPI & m_MojangAPI;
-
+
/** List of all groups read from the ini file */
sGroupMap m_Groups;
-
+
/** List of all players read from the ini file. */
sUserMap m_Users;
-
+
/** Maps lists of groups to rank names.
Each group list is either a simple "<Group>" if there's only one group,
or "<PrimaryGroup>, <FirstSecondaryGroup>, <SecondSecondaryGroup>...", where the secondary groups are
@@ -132,8 +132,8 @@ protected:
where N is a unique number. */
cStringMap m_GroupsToRanks;
-
-
+
+
/** Reads the groups from the "groups.ini" file into m_Groups */
bool ReadGroups(void)
{
@@ -143,7 +143,7 @@ protected:
{
return false;
}
-
+
// Read all the groups into a map:
int NumGroups = Groups.GetNumKeys();
for (int i = 0; i < NumGroups; i++)
@@ -164,9 +164,9 @@ protected:
} // for i - Groups' keys
return true;
}
-
-
+
+
/** Removes non-existent groups from all the groups' inheritance */
void CleanGroupInheritance(void)
{
@@ -194,8 +194,8 @@ protected:
} // for itrG - m_Groups[]
}
-
-
+
+
/** Reads the users from the "users.ini" file into m_Users */
bool ReadUsers(void)
{
@@ -205,7 +205,7 @@ protected:
{
return false;
}
-
+
// Read all the users into a map:
int NumUsers = Users.GetNumKeys();
for (int i = 0; i < NumUsers; i++)
@@ -224,9 +224,9 @@ protected:
} // for i - Users' keys
return true;
}
-
-
-
+
+
+
/** Removes non-existent groups from each user's definition. */
void CleanUserGroups(void)
{
@@ -253,9 +253,9 @@ protected:
} // for itrG - Groups[]
} // for itrU - m_Users[]
}
-
-
-
+
+
+
/** Creates groups based on m_Groups.
Ignores group inheritance. */
void CreateGroups(void)
@@ -267,8 +267,8 @@ protected:
m_RankManager.AddPermissionsToGroup(itr->second.m_Permissions, itr->second.m_Name);
} // for itr - m_Groups[]
}
-
-
+
+
/** Resolves the UUID of each user in m_Users.
If a user doesn't resolve, they are removed and logged in the console. */
void ResolveUserUUIDs(void)
@@ -280,7 +280,7 @@ protected:
PlayerNames.push_back(itr->second.m_Name);
}
m_MojangAPI.GetUUIDsFromPlayerNames(PlayerNames);
-
+
// Assign the UUIDs back to players, remove those not resolved:
for (sUserMap::iterator itr = m_Users.begin(); itr != m_Users.end(); ++itr)
{
@@ -293,9 +293,9 @@ protected:
itr->second.m_OfflineUUID = cClientHandle::GenerateOfflineUUID(itr->second.m_Name);
}
}
-
-
-
+
+
+
/** Adds the specified groups to the specified ranks. Recurses on the groups' inheritance. */
void AddGroupsToRank(const AStringVector & a_Groups, const AString & a_RankName)
{
@@ -303,21 +303,21 @@ protected:
{
// Normalize the group name:
sGroup & Group = m_Groups[StrToLower(*itr)];
-
+
// Avoid loops, check if the group is already added:
if (m_RankManager.IsGroupInRank(Group.m_Name, a_RankName))
{
continue;
}
-
+
// Add the group, and all the groups it inherits from recursively:
m_RankManager.AddGroupToRank(Group.m_Name, a_RankName);
AddGroupsToRank(Group.m_Inherits, a_RankName);
} // for itr - a_Groups[]
}
-
-
-
+
+
+
/** Creates a rank for each player, based on the master groups they are assigned. */
void SetRanks(void)
{
@@ -330,7 +330,7 @@ protected:
LOGWARNING("RankMigrator: Player %s has no groups assigned to them, skipping the player.", itr->second.m_Name.c_str());
continue;
}
-
+
// Compose the rank name out of group names:
AString RankName;
for (AStringVector::const_iterator itrG = Groups.begin(), endG = Groups.end(); itrG != endG; ++itrG)
@@ -342,14 +342,14 @@ protected:
}
RankName.append(GroupName);
} // for itrG - Groups[]
-
+
// Create the rank, with al its groups:
if (!m_RankManager.RankExists(RankName))
{
m_RankManager.AddRank(RankName, "", "", m_Groups[StrToLower(Groups[0])].m_Color);
AddGroupsToRank(Groups, RankName);
}
-
+
// Set the rank to the user, using both the online and offline UUIDs:
m_RankManager.SetPlayerRank(itr->second.m_UUID, itr->second.m_Name, RankName);
m_RankManager.SetPlayerRank(itr->second.m_OfflineUUID, itr->second.m_Name, RankName);
@@ -407,7 +407,7 @@ cRankManager::~cRankManager()
void cRankManager::Initialize(cMojangAPI & a_MojangAPI)
{
ASSERT(!m_IsInitialized); // Calling Initialize for the second time?
-
+
// Create the DB tables, if they don't exist:
m_DB.exec("CREATE TABLE IF NOT EXISTS Rank (RankID INTEGER PRIMARY KEY, Name, MsgPrefix, MsgSuffix, MsgNameColorCode)");
m_DB.exec("CREATE TABLE IF NOT EXISTS PlayerRank (PlayerUUID, PlayerName, RankID INTEGER)");
@@ -416,9 +416,9 @@ void cRankManager::Initialize(cMojangAPI & a_MojangAPI)
m_DB.exec("CREATE TABLE IF NOT EXISTS PermissionItem (PermGroupID INTEGER, Permission)");
m_DB.exec("CREATE TABLE IF NOT EXISTS RestrictionItem (PermGroupID INTEGER, Permission)");
m_DB.exec("CREATE TABLE IF NOT EXISTS DefaultRank (RankID INTEGER)");
-
+
m_IsInitialized = true;
-
+
a_MojangAPI.SetRankManager(this);
// Check if tables empty, migrate from ini files then
@@ -439,7 +439,7 @@ void cRankManager::Initialize(cMojangAPI & a_MojangAPI)
CreateDefaults();
LOGINFO("Default ranks created.");
}
-
+
// Load the default rank:
try
{
@@ -473,7 +473,7 @@ AString cRankManager::GetPlayerRankName(const AString & a_PlayerUUID)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB, "SELECT Rank.Name FROM Rank LEFT JOIN PlayerRank ON Rank.RankID = PlayerRank.RankID WHERE PlayerRank.PlayerUUID = ?");
@@ -528,7 +528,7 @@ AStringVector cRankManager::GetPlayerGroups(const AString & a_PlayerUUID)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -540,7 +540,7 @@ AStringVector cRankManager::GetPlayerGroups(const AString & a_PlayerUUID)
"WHERE PlayerRank.PlayerUUID = ?"
);
stmt.bind(1, a_PlayerUUID);
-
+
// Execute and get results:
while (stmt.executeStep())
{
@@ -590,7 +590,7 @@ AStringVector cRankManager::GetRankGroups(const AString & a_RankName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -621,7 +621,7 @@ AStringVector cRankManager::GetGroupPermissions(const AString & a_GroupName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -651,7 +651,7 @@ AStringVector cRankManager::GetGroupRestrictions(const AString & a_GroupName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -681,7 +681,7 @@ AStringVector cRankManager::GetRankPermissions(const AString & a_RankName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -712,7 +712,7 @@ AStringVector cRankManager::GetRankRestrictions(const AString & a_RankName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -769,7 +769,7 @@ AStringVector cRankManager::GetAllRanks(void)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -794,7 +794,7 @@ AStringVector cRankManager::GetAllGroups(void)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -819,7 +819,7 @@ AStringVector cRankManager::GetAllPermissions(void)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -844,7 +844,7 @@ AStringVector cRankManager::GetAllRestrictions(void)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
AStringVector res;
try
{
@@ -912,7 +912,7 @@ void cRankManager::AddRank(
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Check if such a rank name is already used:
@@ -928,7 +928,7 @@ void cRankManager::AddRank(
}
}
}
-
+
// Insert a new rank:
SQLite::Statement stmt(m_DB, "INSERT INTO Rank (Name, MsgPrefix, MsgSuffix, MsgNameColorCode) VALUES (?, ?, ?, ?)");
stmt.bind(1, a_RankName);
@@ -955,7 +955,7 @@ void cRankManager::AddGroup(const AString & a_GroupName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Check if such a group name is already used:
@@ -971,7 +971,7 @@ void cRankManager::AddGroup(const AString & a_GroupName)
}
}
}
-
+
// Insert a new group:
SQLite::Statement stmt(m_DB, "INSERT INTO PermGroup (Name) VALUES (?)");
stmt.bind(1, a_GroupName);
@@ -995,7 +995,7 @@ void cRankManager::AddGroups(const AStringVector & a_GroupNames)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
for (AStringVector::const_iterator itr = a_GroupNames.begin(), end = a_GroupNames.end(); itr != end; ++itr)
@@ -1013,7 +1013,7 @@ void cRankManager::AddGroups(const AStringVector & a_GroupNames)
}
}
}
-
+
// Insert a new group:
SQLite::Statement stmt(m_DB, "INSERT INTO PermGroup (Name) VALUES (?)");
stmt.bind(1, *itr);
@@ -1038,7 +1038,7 @@ bool cRankManager::AddGroupToRank(const AString & a_GroupName, const AString & a
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the group's ID:
@@ -1053,7 +1053,7 @@ bool cRankManager::AddGroupToRank(const AString & a_GroupName, const AString & a
}
GroupID = stmt.getColumn(0);
}
-
+
// Get the rank's ID:
int RankID;
{
@@ -1066,7 +1066,7 @@ bool cRankManager::AddGroupToRank(const AString & a_GroupName, const AString & a
}
RankID = stmt.getColumn(0);
}
-
+
// Check if the group is already there:
{
SQLite::Statement stmt(m_DB, "SELECT COUNT(*) FROM RankPermGroup WHERE RankID = ? AND PermGroupID = ?");
@@ -1085,7 +1085,7 @@ bool cRankManager::AddGroupToRank(const AString & a_GroupName, const AString & a
return true;
}
}
-
+
// Add the group:
{
SQLite::Statement stmt(m_DB, "INSERT INTO RankPermGroup (RankID, PermGroupID) VALUES (?, ?)");
@@ -1097,7 +1097,7 @@ bool cRankManager::AddGroupToRank(const AString & a_GroupName, const AString & a
return false;
}
}
-
+
// Adding succeeded:
return true;
}
@@ -1116,7 +1116,7 @@ bool cRankManager::AddPermissionToGroup(const AString & a_Permission, const AStr
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the group's ID:
@@ -1131,7 +1131,7 @@ bool cRankManager::AddPermissionToGroup(const AString & a_Permission, const AStr
}
GroupID = stmt.getColumn(0).getInt();
}
-
+
// Check if the permission is already present:
{
SQLite::Statement stmt(m_DB, "SELECT COUNT(*) FROM PermissionItem WHERE PermGroupID = ? AND Permission = ?");
@@ -1150,7 +1150,7 @@ bool cRankManager::AddPermissionToGroup(const AString & a_Permission, const AStr
return true;
}
}
-
+
// Add the permission:
{
SQLite::Statement stmt(m_DB, "INSERT INTO PermissionItem (Permission, PermGroupID) VALUES (?, ?)");
@@ -1162,7 +1162,7 @@ bool cRankManager::AddPermissionToGroup(const AString & a_Permission, const AStr
return false;
}
}
-
+
// Adding succeeded:
return true;
}
@@ -1183,7 +1183,7 @@ bool cRankManager::AddRestrictionToGroup(const AString & a_Restriction, const AS
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the group's ID:
@@ -1198,7 +1198,7 @@ bool cRankManager::AddRestrictionToGroup(const AString & a_Restriction, const AS
}
GroupID = stmt.getColumn(0).getInt();
}
-
+
// Check if the restriction is already present:
{
SQLite::Statement stmt(m_DB, "SELECT COUNT(*) FROM RestrictionItem WHERE PermGroupID = ? AND Permission = ?");
@@ -1217,7 +1217,7 @@ bool cRankManager::AddRestrictionToGroup(const AString & a_Restriction, const AS
return true;
}
}
-
+
// Add the restriction:
{
SQLite::Statement stmt(m_DB, "INSERT INTO RestrictionItem (Permission, PermGroupID) VALUES (?, ?)");
@@ -1229,7 +1229,7 @@ bool cRankManager::AddRestrictionToGroup(const AString & a_Restriction, const AS
return false;
}
}
-
+
// Adding succeeded:
return true;
}
@@ -1250,7 +1250,7 @@ bool cRankManager::AddPermissionsToGroup(const AStringVector & a_Permissions, co
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the group's ID:
@@ -1265,7 +1265,7 @@ bool cRankManager::AddPermissionsToGroup(const AStringVector & a_Permissions, co
}
GroupID = stmt.getColumn(0).getInt();
}
-
+
for (AStringVector::const_iterator itr = a_Permissions.begin(), end = a_Permissions.end(); itr != end; ++itr)
{
// Check if the permission is already present:
@@ -1286,7 +1286,7 @@ bool cRankManager::AddPermissionsToGroup(const AStringVector & a_Permissions, co
continue;
}
}
-
+
// Add the permission:
{
SQLite::Statement stmt(m_DB, "INSERT INTO PermissionItem (Permission, PermGroupID) VALUES (?, ?)");
@@ -1299,7 +1299,7 @@ bool cRankManager::AddPermissionsToGroup(const AStringVector & a_Permissions, co
}
}
} // for itr - a_Permissions[]
-
+
// Adding succeeded:
return true;
}
@@ -1320,7 +1320,7 @@ bool cRankManager::AddRestrictionsToGroup(const AStringVector & a_Restrictions,
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the group's ID:
@@ -1335,7 +1335,7 @@ bool cRankManager::AddRestrictionsToGroup(const AStringVector & a_Restrictions,
}
GroupID = stmt.getColumn(0).getInt();
}
-
+
for (auto itr = a_Restrictions.cbegin(), end = a_Restrictions.cend(); itr != end; ++itr)
{
// Check if the restriction is already present:
@@ -1356,7 +1356,7 @@ bool cRankManager::AddRestrictionsToGroup(const AStringVector & a_Restrictions,
continue;
}
}
-
+
// Add the permission:
{
SQLite::Statement stmt(m_DB, "INSERT INTO RestrictionItem (Permission, PermGroupID) VALUES (?, ?)");
@@ -1369,7 +1369,7 @@ bool cRankManager::AddRestrictionsToGroup(const AStringVector & a_Restrictions,
}
}
} // for itr - a_Restrictions[]
-
+
// Adding succeeded:
return true;
}
@@ -1397,7 +1397,7 @@ void cRankManager::RemoveRank(const AString & a_RankName, const AString & a_Repl
LOGWARNING("%s: Cannot remove rank %s, it is the default rank and the replacement rank doesn't exist.", __FUNCTION__, a_RankName.c_str());
return;
}
-
+
AStringVector res;
try
{
@@ -1413,7 +1413,7 @@ void cRankManager::RemoveRank(const AString & a_RankName, const AString & a_Repl
}
RemoveRankID = stmt.getColumn(0).getInt();
}
-
+
// Get the RankID for the replacement rank:
int ReplacementRankID = -1;
{
@@ -1424,14 +1424,14 @@ void cRankManager::RemoveRank(const AString & a_RankName, const AString & a_Repl
ReplacementRankID = stmt.getColumn(0).getInt();
}
}
-
+
// Remove the rank's bindings to groups:
{
SQLite::Statement stmt(m_DB, "DELETE FROM RankPermGroup WHERE RankID = ?");
stmt.bind(1, RemoveRankID);
stmt.exec();
}
-
+
// Adjust players:
if (ReplacementRankID == -1)
{
@@ -1448,7 +1448,7 @@ void cRankManager::RemoveRank(const AString & a_RankName, const AString & a_Repl
stmt.bind(2, RemoveRankID);
stmt.exec();
}
-
+
// Remove the rank from the DB:
{
SQLite::Statement stmt(m_DB, "DELETE FROM Rank WHERE RankID = ?");
@@ -1476,7 +1476,7 @@ void cRankManager::RemoveGroup(const AString & a_GroupName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the ID of the group:
@@ -1491,21 +1491,21 @@ void cRankManager::RemoveGroup(const AString & a_GroupName)
}
GroupID = stmt.getColumn(0).getInt();
}
-
+
// Remove all permissions from the group:
{
SQLite::Statement stmt(m_DB, "DELETE FROM PermissionItem WHERE PermGroupID = ?");
stmt.bind(1, GroupID);
stmt.exec();
}
-
+
// Remove the group from all ranks that contain it:
{
SQLite::Statement stmt(m_DB, "DELETE FROM RankPermGroup WHERE PermGroupID = ?");
stmt.bind(1, GroupID);
stmt.exec();
}
-
+
// Remove the group itself:
{
SQLite::Statement stmt(m_DB, "DELETE FROM PermGroup WHERE PermGroupID = ?");
@@ -1527,7 +1527,7 @@ void cRankManager::RemoveGroupFromRank(const AString & a_GroupName, const AStrin
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the IDs of the group and the rank:
@@ -1549,14 +1549,14 @@ void cRankManager::RemoveGroupFromRank(const AString & a_GroupName, const AStrin
GroupID = stmt.getColumn(0).getInt();
RankID = stmt.getColumn(1).getInt();
}
-
+
// Remove the group from all ranks that contain it:
{
SQLite::Statement stmt(m_DB, "DELETE FROM RankPermGroup WHERE PermGroupID = ?");
stmt.bind(1, GroupID);
stmt.exec();
}
-
+
// Remove the group-to-rank binding:
{
SQLite::Statement stmt(m_DB, "DELETE FROM RankPermGroup WHERE PermGroupID = ? AND RankID = ?");
@@ -1579,7 +1579,7 @@ void cRankManager::RemovePermissionFromGroup(const AString & a_Permission, const
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the ID of the group:
@@ -1594,7 +1594,7 @@ void cRankManager::RemovePermissionFromGroup(const AString & a_Permission, const
}
GroupID = stmt.getColumn(0).getInt();
}
-
+
// Remove the permission from the group:
{
SQLite::Statement stmt(m_DB, "DELETE FROM PermissionItem WHERE PermGroupID = ? AND Permission = ?");
@@ -1619,7 +1619,7 @@ void cRankManager::RemoveRestrictionFromGroup(const AString & a_Restriction, con
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the ID of the group:
@@ -1634,7 +1634,7 @@ void cRankManager::RemoveRestrictionFromGroup(const AString & a_Restriction, con
}
GroupID = stmt.getColumn(0).getInt();
}
-
+
// Remove the permission from the group:
{
SQLite::Statement stmt(m_DB, "DELETE FROM RestrictionItem WHERE PermGroupID = ? AND Permission = ?");
@@ -1659,7 +1659,7 @@ bool cRankManager::RenameRank(const AString & a_OldName, const AString & a_NewNa
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Check that NewName doesn't exist:
@@ -1672,7 +1672,7 @@ bool cRankManager::RenameRank(const AString & a_OldName, const AString & a_NewNa
return false;
}
}
-
+
// Rename:
{
SQLite::Statement stmt(m_DB, "UPDATE Rank SET Name = ? WHERE Name = ?");
@@ -1684,7 +1684,7 @@ bool cRankManager::RenameRank(const AString & a_OldName, const AString & a_NewNa
return false;
}
}
-
+
// Update the default rank, if it was the one being renamed:
if (a_OldName == m_DefaultRank)
{
@@ -1709,7 +1709,7 @@ bool cRankManager::RenameGroup(const AString & a_OldName, const AString & a_NewN
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Check that NewName doesn't exist:
@@ -1722,7 +1722,7 @@ bool cRankManager::RenameGroup(const AString & a_OldName, const AString & a_NewN
return false;
}
}
-
+
// Rename:
bool res;
{
@@ -1731,7 +1731,7 @@ bool cRankManager::RenameGroup(const AString & a_OldName, const AString & a_NewN
stmt.bind(2, a_OldName);
res = (stmt.exec() > 0);
}
-
+
return res;
}
catch (const SQLite::Exception & ex)
@@ -1750,7 +1750,7 @@ void cRankManager::SetPlayerRank(const AString & a_PlayerUUID, const AString & a
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
// Get the rank ID:
@@ -1765,7 +1765,7 @@ void cRankManager::SetPlayerRank(const AString & a_PlayerUUID, const AString & a
}
RankID = stmt.getColumn(0).getInt();
}
-
+
// Update the player's rank, if already in DB:
{
SQLite::Statement stmt(m_DB, "UPDATE PlayerRank SET RankID = ?, PlayerName = ? WHERE PlayerUUID = ?");
@@ -1778,7 +1778,7 @@ void cRankManager::SetPlayerRank(const AString & a_PlayerUUID, const AString & a
return;
}
}
-
+
// The player is not yet in the DB, add them:
SQLite::Statement stmt(m_DB, "INSERT INTO PlayerRank (RankID, PlayerUUID, PlayerName) VALUES (?, ?, ?)");
stmt.bind(1, RankID);
@@ -1789,7 +1789,7 @@ void cRankManager::SetPlayerRank(const AString & a_PlayerUUID, const AString & a
// Successfully added the player
return;
}
-
+
LOGWARNING("%s: Failed to set player UUID %s to rank %s.",
__FUNCTION__, a_PlayerUUID.c_str(), a_RankName.c_str()
);
@@ -1838,7 +1838,7 @@ void cRankManager::SetRankVisuals(
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB, "UPDATE Rank SET MsgPrefix = ?, MsgSuffix = ?, MsgNameColorCode = ? WHERE Name = ?");
@@ -1870,7 +1870,7 @@ bool cRankManager::GetRankVisuals(
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB, "SELECT MsgPrefix, MsgSuffix, MsgNameColorCode FROM Rank WHERE Name = ?");
@@ -1900,7 +1900,7 @@ bool cRankManager::RankExists(const AString & a_RankName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB, "SELECT * FROM Rank WHERE Name = ?");
@@ -1926,7 +1926,7 @@ bool cRankManager::GroupExists(const AString & a_GroupName)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB, "SELECT * FROM PermGroup WHERE Name = ?");
@@ -1952,7 +1952,7 @@ bool cRankManager::IsPlayerRankSet(const AString & a_PlayerUUID)
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB, "SELECT * FROM PlayerRank WHERE PlayerUUID = ?");
@@ -1978,7 +1978,7 @@ bool cRankManager::IsGroupInRank(const AString & a_GroupName, const AString & a_
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB,
@@ -2010,7 +2010,7 @@ bool cRankManager::IsPermissionInGroup(const AString & a_Permission, const AStri
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB,
@@ -2041,7 +2041,7 @@ bool cRankManager::IsRestrictionInGroup(const AString & a_Restriction, const ASt
{
ASSERT(m_IsInitialized);
cCSLock Lock(m_CS);
-
+
try
{
SQLite::Statement stmt(m_DB,