diff --git a/src/jasper/modules/world/include/jasper/world/worldstatic.hpp b/src/jasper/modules/world/include/jasper/world/worldstatic.hpp index 28052f0..5c9f315 100644 --- a/src/jasper/modules/world/include/jasper/world/worldstatic.hpp +++ b/src/jasper/modules/world/include/jasper/world/worldstatic.hpp @@ -137,9 +137,11 @@ OX_MODEL_END() [[nodiscard]] constexpr bool valid(WorldStatic const&ws) noexcept { auto const tileCnt = static_cast(ws.columns * ws.rows); - return ox::all_of(ws.map.begin(), ws.map.end(), [tileCnt](BgLayer const&v) { - return v.tiles.size() == tileCnt; - }); + return + !ws.objTileRefSets.empty() && + ox::all_of(ws.map.begin(), ws.map.end(), [tileCnt](BgLayer const&v) { + return v.tiles.size() == tileCnt; + }); } [[nodiscard]] @@ -192,9 +194,9 @@ class WorldStaticLoader { TileStatic &dst, TileDoc const&src) noexcept; + private: void reset(); - private: ox::Result setupTileResrc(DocObjRef const&docObjRef) noexcept; void deleteRefSet(uint8_t refIdx, DocObjRef const&oldObjRef) noexcept; diff --git a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp index 2b1600a..be1d207 100644 --- a/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp +++ b/src/jasper/modules/world/src/studio/worldeditor/worldeditor-imgui.cpp @@ -405,7 +405,6 @@ ox::Error WorldEditorImGui::handleDepUpdate(ox::StringViewCR, ox::UUID const&uui auto const depUpdated = ox::any_of(m_doc.objSets.begin(), m_doc.objSets.end(), objSetMatches) || ox::any_of(m_dependencies.pairs().begin(), m_dependencies.pairs().end(), depMatches); if (depUpdated) { - m_loader.reset(); OX_RETURN_ERROR(m_loader.loadWorldStatic()); OX_RETURN_ERROR(loadObjectSets()); } @@ -429,7 +428,6 @@ ox::Error WorldEditorImGui::loadObjectSets() noexcept { ox::Error WorldEditorImGui::undoStackChanged(studio::UndoCommand const*cmd) { if (dynamic_cast(cmd)) { - m_loader.reset(); OX_RETURN_ERROR(m_loader.loadWorldStatic()); } OX_RETURN_ERROR(m_view.setupWorld()); diff --git a/src/jasper/modules/world/src/worldstatic.cpp b/src/jasper/modules/world/src/worldstatic.cpp index 71e67ac..d0dd1bd 100644 --- a/src/jasper/modules/world/src/worldstatic.cpp +++ b/src/jasper/modules/world/src/worldstatic.cpp @@ -56,7 +56,7 @@ ox::Error WorldStaticLoader::loadWorldStatic() noexcept { } } m_loaded = true; - return {}; + return keel::ensureValid(m_worldStatic); } ox::Error WorldStaticLoader::updateTile(