summaryrefslogtreecommitdiffstats
path: root/src/Protocol/MojangAPI.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Protocol/MojangAPI.cpp')
-rw-r--r--src/Protocol/MojangAPI.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/Protocol/MojangAPI.cpp b/src/Protocol/MojangAPI.cpp
index 0a6716e6f..67f513e44 100644
--- a/src/Protocol/MojangAPI.cpp
+++ b/src/Protocol/MojangAPI.cpp
@@ -7,7 +7,7 @@
#include "MojangAPI.h"
#include "SQLiteCpp/Database.h"
#include "SQLiteCpp/Statement.h"
-#include "inifile/iniFile.h"
+#include "../IniFile.h"
#include "json/json.h"
#include "PolarSSL++/BlockingSslClientSocket.h"
#include "../RankManager.h"
@@ -196,7 +196,7 @@ cMojangAPI::cMojangAPI(void) :
m_NameToUUIDAddress(DEFAULT_NAME_TO_UUID_ADDRESS),
m_UUIDToProfileServer(DEFAULT_UUID_TO_PROFILE_SERVER),
m_UUIDToProfileAddress(DEFAULT_UUID_TO_PROFILE_ADDRESS),
- m_RankMgr(NULL),
+ m_RankMgr(nullptr),
m_UpdateThread(new cUpdateThread())
{
}
@@ -214,14 +214,17 @@ cMojangAPI::~cMojangAPI()
-void cMojangAPI::Start(cIniFile & a_SettingsIni)
+void cMojangAPI::Start(cIniFile & a_SettingsIni, bool a_ShouldAuth)
{
m_NameToUUIDServer = a_SettingsIni.GetValueSet("MojangAPI", "NameToUUIDServer", DEFAULT_NAME_TO_UUID_SERVER);
m_NameToUUIDAddress = a_SettingsIni.GetValueSet("MojangAPI", "NameToUUIDAddress", DEFAULT_NAME_TO_UUID_ADDRESS);
m_UUIDToProfileServer = a_SettingsIni.GetValueSet("MojangAPI", "UUIDToProfileServer", DEFAULT_UUID_TO_PROFILE_SERVER);
m_UUIDToProfileAddress = a_SettingsIni.GetValueSet("MojangAPI", "UUIDToProfileAddress", DEFAULT_UUID_TO_PROFILE_ADDRESS);
LoadCachesFromDisk();
- m_UpdateThread->Start();
+ if (a_ShouldAuth)
+ {
+ m_UpdateThread->Start();
+ }
}
@@ -332,7 +335,7 @@ AStringVector cMojangAPI::GetUUIDsFromPlayerNames(const AStringVector & a_Player
void cMojangAPI::AddPlayerNameToUUIDMapping(const AString & a_PlayerName, const AString & a_UUID)
{
AString UUID = MakeUUIDShort(a_UUID);
- Int64 Now = time(NULL);
+ Int64 Now = time(nullptr);
{
cCSLock Lock(m_CSNameToUUID);
m_NameToUUID[StrToLower(a_PlayerName)] = sProfile(a_PlayerName, UUID, "", "", Now);
@@ -351,7 +354,7 @@ void cMojangAPI::AddPlayerNameToUUIDMapping(const AString & a_PlayerName, const
void cMojangAPI::AddPlayerProfile(const AString & a_PlayerName, const AString & a_UUID, const Json::Value & a_Properties)
{
AString UUID = MakeUUIDShort(a_UUID);
- Int64 Now = time(NULL);
+ Int64 Now = time(nullptr);
{
cCSLock Lock(m_CSNameToUUID);
m_NameToUUID[StrToLower(a_PlayerName)] = sProfile(a_PlayerName, UUID, "", "", Now);
@@ -555,7 +558,7 @@ void cMojangAPI::SaveCachesToDisk(void)
db.exec("DELETE FROM UUIDToProfile");
// Save all cache entries - m_PlayerNameToUUID:
- Int64 LimitDateTime = time(NULL) - MAX_AGE;
+ Int64 LimitDateTime = time(nullptr) - MAX_AGE;
{
SQLite::Statement stmt(db, "INSERT INTO PlayerNameToUUID(PlayerName, UUID, DateTime) VALUES (?, ?, ?)");
cCSLock Lock(m_CSNameToUUID);
@@ -694,7 +697,7 @@ void cMojangAPI::QueryNamesToUUIDs(AStringVector & a_NamesToQuery)
// Store the returned results into cache:
Json::Value::UInt JsonCount = root.size();
- Int64 Now = time(NULL);
+ Int64 Now = time(nullptr);
{
cCSLock Lock(m_CSNameToUUID);
for (Json::Value::UInt idx = 0; idx < JsonCount; ++idx)
@@ -828,7 +831,7 @@ void cMojangAPI::QueryUUIDToProfile(const AString & a_UUID)
return;
}
Json::Value Properties = root.get("properties", "");
- Int64 Now = time(NULL);
+ Int64 Now = time(nullptr);
{
cCSLock Lock(m_CSUUIDToProfile);
m_UUIDToProfile[a_UUID] = sProfile(PlayerName, a_UUID, Properties, Now);
@@ -852,7 +855,7 @@ void cMojangAPI::NotifyNameUUID(const AString & a_PlayerName, const AString & a_
{
// Notify the rank manager:
cCSLock Lock(m_CSRankMgr);
- if (m_RankMgr != NULL)
+ if (m_RankMgr != nullptr)
{
m_RankMgr->NotifyNameUUID(a_PlayerName, a_UUID);
}
@@ -864,7 +867,7 @@ void cMojangAPI::NotifyNameUUID(const AString & a_PlayerName, const AString & a_
void cMojangAPI::Update(void)
{
- Int64 LimitDateTime = time(NULL) - MAX_AGE;
+ Int64 LimitDateTime = time(nullptr) - MAX_AGE;
// Re-query all playernames that are stale:
AStringVector PlayerNames;