diff options
author | Mattes D <github@xoft.cz> | 2014-08-24 20:00:45 +0200 |
---|---|---|
committer | Mattes D <github@xoft.cz> | 2014-08-24 20:00:45 +0200 |
commit | 8630b20c523033b359e4f9d7513cb6e4aafec1cb (patch) | |
tree | 2a74722a5dd9ba1fcb78d57996624f7f38e33efc /src/RankManager.cpp | |
parent | RankMgr: Unified function signature comments in the bindings. (diff) | |
download | cuberite-8630b20c523033b359e4f9d7513cb6e4aafec1cb.tar cuberite-8630b20c523033b359e4f9d7513cb6e4aafec1cb.tar.gz cuberite-8630b20c523033b359e4f9d7513cb6e4aafec1cb.tar.bz2 cuberite-8630b20c523033b359e4f9d7513cb6e4aafec1cb.tar.lz cuberite-8630b20c523033b359e4f9d7513cb6e4aafec1cb.tar.xz cuberite-8630b20c523033b359e4f9d7513cb6e4aafec1cb.tar.zst cuberite-8630b20c523033b359e4f9d7513cb6e4aafec1cb.zip |
Diffstat (limited to '')
-rw-r--r-- | src/RankManager.cpp | 69 |
1 files changed, 12 insertions, 57 deletions
diff --git a/src/RankManager.cpp b/src/RankManager.cpp index 0cee7724b..65ce33b92 100644 --- a/src/RankManager.cpp +++ b/src/RankManager.cpp @@ -534,34 +534,12 @@ AStringVector cRankManager::GetPlayerGroups(const AString & a_PlayerUUID) AStringVector cRankManager::GetPlayerPermissions(const AString & a_PlayerUUID) { - ASSERT(m_IsInitialized); - cCSLock Lock(m_CS); - - AStringVector res; - try + AString Rank = GetPlayerRankName(a_PlayerUUID); + if (Rank.empty()) { - // Prepare the DB statement: - SQLite::Statement stmt(m_DB, - "SELECT DISTINCT(PermissionItem.Permission) FROM PermissionItem " - "LEFT JOIN RankPermGroup " - "ON PermissionItem.PermGroupID = RankPermGroup.PermGroupID " - "LEFT JOIN PlayerRank " - "ON PlayerRank.RankID = RankPermGroup.RankID " - "WHERE PlayerRank.PlayerUUID = ?" - ); - stmt.bind(1, a_PlayerUUID); - - // Execute and get results: - while (stmt.executeStep()) - { - res.push_back(stmt.getColumn(0).getText()); - } + Rank = m_DefaultRank; } - catch (const SQLite::Exception & ex) - { - LOGWARNING("%s: Cannot get player permissions: %s", __FUNCTION__, ex.what()); - } - return res; + return GetRankPermissions(Rank); } @@ -742,39 +720,16 @@ bool cRankManager::GetPlayerMsgVisuals( AString & a_MsgNameColorCode ) { - ASSERT(m_IsInitialized); - cCSLock Lock(m_CS); - - AStringVector res; - try - { - SQLite::Statement stmt(m_DB, - "SELECT Rank.MsgPrefix, Rank.MsgSuffix, Rank.MsgNameColorCode FROM Rank " - "LEFT JOIN PlayerRank ON Rank.RankID = PlayerRank.RankID " - "WHERE PlayerRank.PlayerUUID = ?" - ); - stmt.bind(1, a_PlayerUUID); - if (!stmt.executeStep()) - { - LOGD("%s: Player UUID %s not found in the DB, returning empty values.", __FUNCTION__, a_PlayerUUID.c_str()); - a_MsgPrefix.clear(); - a_MsgSuffix.clear(); - a_MsgNameColorCode.clear(); - return false; - } - a_MsgPrefix = stmt.getColumn(0).getText(); - a_MsgSuffix = stmt.getColumn(1).getText(); - a_MsgNameColorCode = stmt.getColumn(2).getText(); - return true; - } - catch (const SQLite::Exception & ex) + AString Rank = GetPlayerRankName(a_PlayerUUID); + if (Rank.empty()) { - LOGWARNING("%s: Failed to get ranks from DB: %s. Returning empty values.", __FUNCTION__, ex.what()); + // Rank not found, return failure: + a_MsgPrefix.clear(); + a_MsgSuffix.clear(); + a_MsgNameColorCode.clear(); + return false; } - a_MsgPrefix.clear(); - a_MsgSuffix.clear(); - a_MsgNameColorCode.clear(); - return false; + return GetRankVisuals(Rank, a_MsgPrefix, a_MsgSuffix, a_MsgNameColorCode); } |