Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarPlayerStorage.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-11-27 10:13:21 +1100
committerKae <80987908+Novaenia@users.noreply.github.com>2023-11-27 10:13:21 +1100
commit24c2820ce1ad4347717253cb5c239d70604d0974 (patch)
tree63f9e9e137641d14cedd0f3b548b5660e623e0ce /source/game/StarPlayerStorage.cpp
parentac66491b3ff1c816cfbe7e2a89dadc84db8641fa (diff)
Update StarPlayerStorage.cpp
Diffstat (limited to 'source/game/StarPlayerStorage.cpp')
-rw-r--r--source/game/StarPlayerStorage.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/source/game/StarPlayerStorage.cpp b/source/game/StarPlayerStorage.cpp
index 7e4b74b..5bb3f4e 100644
--- a/source/game/StarPlayerStorage.cpp
+++ b/source/game/StarPlayerStorage.cpp
@@ -64,7 +64,12 @@ PlayerStorage::PlayerStorage(String const& storageDir) {
if (player->uuid() != entry.first)
throw PlayerException(strf("Uuid mismatch in loaded player with filename uuid '{}'", entry.first.hex()));
} catch (StarException const& e) {
- Logger::error("Failed to valid player with uuid {} : {}", entry.first.hex(), outputException(e, true));
+ auto& fileName = uuidFileName(entry.first);
+ String uuidHex = entry.first.hex();
+ if (uuidHex == fileName)
+ Logger::error("Failed to validate player with uuid {} : {}", uuidHex, outputException(e, true));
+ else
+ Logger::error("Failed to validate player with uuid {} ({}.player) : {}", uuidHex, fileName, outputException(e, true));
it.remove();
}
}
@@ -76,8 +81,11 @@ PlayerStorage::PlayerStorage(String const& storageDir) {
m_metadata = Json::parseJson(File::readFileString(filename)).toObject();
if (auto order = m_metadata.value("order")) {
- for (auto const& uuid : order.iterateArray())
- m_savedPlayersCache.toBack(Uuid(uuid.toString()));
+ for (auto const& jUuid : order.iterateArray()) {
+ auto entry = m_savedPlayersCache.find(Uuid(jUuid.toString()));
+ if (entry != m_savedPlayersCache.end())
+ m_savedPlayersCache.toBack(entry);
+ }
}
} catch (std::exception const& e) {
Logger::warn("Error loading player storage metadata file, resetting: {}", outputException(e, false));