2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-12-27 20:41:49 +00:00

chore: pass ZoneLoading error as result

This commit is contained in:
Jan Laupetin
2025-10-11 15:28:19 +01:00
parent 098be53559
commit b27b7e77bd
9 changed files with 181 additions and 121 deletions

View File

@@ -227,13 +227,15 @@ private:
auto absoluteZoneDirectory = absolute(std::filesystem::path(zonePath).remove_filename()).string();
auto searchPathsForZone = paths.GetSearchPathsForZone(absoluteZoneDirectory);
auto zone = ZoneLoading::LoadZone(zonePath);
if (zone == nullptr)
auto maybeZone = ZoneLoading::LoadZone(zonePath);
if (!maybeZone)
{
con::error("Failed to load zone \"{}\".", zonePath);
con::error("Failed to load zone \"{}\": {}", zonePath, maybeZone.error());
return false;
}
auto zone = std::move(*maybeZone);
con::debug("Loaded zone \"{}\"", zone->m_name);
if (ShouldLoadObj())
@@ -287,16 +289,16 @@ private:
auto searchPathsForZone = paths.GetSearchPathsForZone(absoluteZoneDirectory);
std::string zoneName;
auto zone = ZoneLoading::LoadZone(zonePath);
if (zone == nullptr)
auto maybeZone = ZoneLoading::LoadZone(zonePath);
if (!maybeZone)
{
con::error("Failed to load zone \"{}\".", zonePath);
con::error("Failed to load zone \"{}\": {}", zonePath, maybeZone.error());
return false;
}
zoneName = zone->m_name;
con::debug("Loaded zone \"{}\"", zoneName);
auto zone = std::move(*maybeZone);
con::debug("Loaded zone \"{}\"", zone->m_name);
const auto* objLoader = IObjLoader::GetObjLoaderForGame(zone->m_game_id);
if (ShouldLoadObj())
@@ -308,6 +310,8 @@ private:
if (ShouldLoadObj())
objLoader->UnloadContainersOfZone(*zone);
// Copy zone name for using it after freeing the zone
std::string zoneName = zone->m_name;
zone.reset();
con::debug("Unloaded zone \"{}\"", zoneName);
}