summaryrefslogtreecommitdiffstats
path: root/src/RankManager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/RankManager.cpp')
-rw-r--r--src/RankManager.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/RankManager.cpp b/src/RankManager.cpp
index 65e5d264c..349582950 100644
--- a/src/RankManager.cpp
+++ b/src/RankManager.cpp
@@ -365,7 +365,8 @@ protected:
cRankManager::cRankManager(void) :
m_DB("Ranks.sqlite", SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE),
- m_IsInitialized(false)
+ m_IsInitialized(false),
+ m_MojangAPI(NULL)
{
}
@@ -373,6 +374,18 @@ cRankManager::cRankManager(void) :
+cRankManager::~cRankManager()
+{
+ if (m_MojangAPI != NULL)
+ {
+ m_MojangAPI->SetRankManager(NULL);
+ }
+}
+
+
+
+
+
void cRankManager::Initialize(cMojangAPI & a_MojangAPI)
{
ASSERT(!m_IsInitialized); // Calling Initialize for the second time?
@@ -386,6 +399,8 @@ void cRankManager::Initialize(cMojangAPI & a_MojangAPI)
m_IsInitialized = true;
+ a_MojangAPI.SetRankManager(this);
+
// Check if tables empty, migrate from ini files then
if (AreDBTablesEmpty())
{
@@ -1655,6 +1670,28 @@ bool cRankManager::IsPermissionInGroup(const AString & a_Permission, const AStri
+void cRankManager::NotifyNameUUID(const AString & a_PlayerName, const AString & a_UUID)
+{
+ ASSERT(m_IsInitialized);
+ cCSLock Lock(m_CS);
+
+ try
+ {
+ SQLite::Statement stmt(m_DB, "UPDATE PlayerRank SET PlayerName = ? WHERE PlayerUUID = ?");
+ stmt.bind(1, a_PlayerName);
+ stmt.bind(2, a_UUID);
+ stmt.exec();
+ }
+ catch (const SQLite::Exception & ex)
+ {
+ LOGWARNING("%s: Failed to update DB: %s", __FUNCTION__, ex.what());
+ }
+}
+
+
+
+
+
bool cRankManager::AreDBTablesEmpty(void)
{
return (