again
Some checks failed
Build / Build Game (push) Has been cancelled

This commit is contained in:
2026-02-28 22:19:24 -05:00
parent acb1505308
commit 3817f1cc39
3 changed files with 22 additions and 13 deletions

View File

@@ -18,16 +18,17 @@ namespace game::resource::xml
Save::Save(const std::filesystem::path& path)
{
XMLDocument document;
auto pathString = path.string();
// Fail silently if there's no save.
auto result = document.LoadFile(path.c_str());
auto result = document.LoadFile(pathString.c_str());
if (result == XML_ERROR_FILE_NOT_FOUND || result == XML_ERROR_FILE_COULD_NOT_BE_OPENED) return;
if (result != XML_SUCCESS)
{
logger.error(
std::format("Could not initialize character save file: {} ({})", path.string(), document.ErrorStr()));
std::format("Could not initialize character save file: {} ({})", pathString, document.ErrorStr()));
return;
}
@@ -99,7 +100,7 @@ namespace game::resource::xml
}
}
logger.info(std::format("Initialized character save file: {}", path.string()));
logger.info(std::format("Initialized character save file: {}", pathString));
isValid = true;
}
@@ -109,6 +110,7 @@ namespace game::resource::xml
void Save::serialize(const std::filesystem::path& path)
{
XMLDocument document;
auto pathString = path.string();
auto element = document.NewElement("Save");
element->SetAttribute("IsPostgame", isPostgame ? "true" : "false");
@@ -168,13 +170,13 @@ namespace game::resource::xml
document.InsertFirstChild(element);
if (document.SaveFile(path.c_str()) != XML_SUCCESS)
if (document.SaveFile(pathString.c_str()) != XML_SUCCESS)
{
logger.error(std::format("Failed to save character save file: {} ({})", path.string(), document.ErrorStr()));
logger.error(std::format("Failed to save character save file: {} ({})", pathString, document.ErrorStr()));
return;
}
logger.info(std::format("Saved character save file: {}", path.string()));
logger.info(std::format("Saved character save file: {}", pathString));
#ifdef __EMSCRIPTEN__
web_filesystem::flush_async();