@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user