1
0
Fork 0

Fixed UUIDs handling in cPlayer.

The loading expected dashed UUIDs, MCS uses short UUIDs throughout.
This commit is contained in:
madmaxoft 2014-07-31 22:52:06 +02:00
parent 59adf113f0
commit ecb86935f8
2 changed files with 9 additions and 6 deletions

View File

@ -1700,8 +1700,10 @@ bool cPlayer::LoadFromDisk(void)
// Load from the offline UUID file, if allowed: // Load from the offline UUID file, if allowed:
AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName()); AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName());
const char * OfflineUsage = " (unused)";
if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData()) if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData())
{ {
OfflineUsage = "";
if (LoadFromFile(GetUUIDFileName(OfflineUUID))) if (LoadFromFile(GetUUIDFileName(OfflineUUID)))
{ {
return true; return true;
@ -1724,8 +1726,8 @@ bool cPlayer::LoadFromDisk(void)
} }
// None of the files loaded successfully // None of the files loaded successfully
LOG("Player data file not found for %s (%s, offline %s), will be reset to defaults.", LOG("Player data file not found for %s (%s, offline %s%s), will be reset to defaults.",
GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str() GetName().c_str(), m_UUID.c_str(), OfflineUUID.c_str(), OfflineUsage
); );
return false; return false;
} }
@ -2212,12 +2214,13 @@ void cPlayer::Detach()
AString cPlayer::GetUUIDFileName(const AString & a_UUID) AString cPlayer::GetUUIDFileName(const AString & a_UUID)
{ {
ASSERT(a_UUID.size() == 36); AString UUID = cMojangAPI::MakeUUIDDashed(a_UUID);
ASSERT(UUID.length() == 36);
AString res("players/"); AString res("players/");
res.append(a_UUID, 0, 2); res.append(UUID, 0, 2);
res.push_back('/'); res.push_back('/');
res.append(a_UUID, 2, AString::npos); res.append(UUID, 2, AString::npos);
res.append(".json"); res.append(".json");
return res; return res;
} }

View File

@ -536,7 +536,7 @@ protected:
*/ */
bool m_bIsTeleporting; bool m_bIsTeleporting;
/** The UUID of the player, as read from the ClientHandle. /** The short UUID (no dashes) of the player, as read from the ClientHandle.
If no ClientHandle is given, the UUID is initialized to empty. */ If no ClientHandle is given, the UUID is initialized to empty. */
AString m_UUID; AString m_UUID;