Simplified the player data loading.
This commit is contained in:
parent
ebea2b7efc
commit
f73042fb02
@ -1692,8 +1692,7 @@ bool cPlayer::LoadFromDisk(void)
|
|||||||
LoadPermissionsFromDisk();
|
LoadPermissionsFromDisk();
|
||||||
|
|
||||||
// Load from the UUID file:
|
// Load from the UUID file:
|
||||||
bool res = LoadFromFile(GetUUIDFileName(m_UUID));
|
if (LoadFromFile(GetUUIDFileName(m_UUID)))
|
||||||
if (res)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1702,8 +1701,7 @@ bool cPlayer::LoadFromDisk(void)
|
|||||||
AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName());
|
AString OfflineUUID = cClientHandle::GenerateOfflineUUID(GetName());
|
||||||
if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData())
|
if (cRoot::Get()->GetServer()->ShouldLoadOfflinePlayerData())
|
||||||
{
|
{
|
||||||
res = LoadFromFile(GetUUIDFileName(OfflineUUID));
|
if (LoadFromFile(GetUUIDFileName(OfflineUUID)))
|
||||||
if (res)
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1713,18 +1711,19 @@ bool cPlayer::LoadFromDisk(void)
|
|||||||
if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData())
|
if (cRoot::Get()->GetServer()->ShouldLoadNamedPlayerData())
|
||||||
{
|
{
|
||||||
AString OldStyleFileName = Printf("players/%s.json", GetName().c_str());
|
AString OldStyleFileName = Printf("players/%s.json", GetName().c_str());
|
||||||
res = LoadFromFile(OldStyleFileName);
|
if (LoadFromFile(OldStyleFileName))
|
||||||
if (res)
|
|
||||||
{
|
{
|
||||||
// Save in new format and remove the old file
|
// Save in new format and remove the old file
|
||||||
SaveToDisk();
|
if (SaveToDisk())
|
||||||
cFile::Delete(OldStyleFileName);
|
{
|
||||||
|
cFile::Delete(OldStyleFileName);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// None of the files loaded successfully
|
// None of the files loaded successfully
|
||||||
LOGD("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), 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()
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user