diff --git a/apps/openmw/mwbase/luamanager.hpp b/apps/openmw/mwbase/luamanager.hpp index c70194a0a1..e865756408 100644 --- a/apps/openmw/mwbase/luamanager.hpp +++ b/apps/openmw/mwbase/luamanager.hpp @@ -56,6 +56,7 @@ namespace MWBase virtual void newGameStarted() = 0; virtual void gameLoaded() = 0; virtual void gameEnded() = 0; + virtual void noGame() = 0; virtual void objectAddedToScene(const MWWorld::Ptr& ptr) = 0; virtual void objectRemovedFromScene(const MWWorld::Ptr& ptr) = 0; virtual void objectTeleported(const MWWorld::Ptr& ptr) = 0; diff --git a/apps/openmw/mwlua/luamanagerimp.cpp b/apps/openmw/mwlua/luamanagerimp.cpp index d4366cac50..9029d7509e 100644 --- a/apps/openmw/mwlua/luamanagerimp.cpp +++ b/apps/openmw/mwlua/luamanagerimp.cpp @@ -379,6 +379,12 @@ namespace MWLua mMenuScripts.stateChanged(); } + void LuaManager::noGame() + { + clear(); + mMenuScripts.stateChanged(); + } + void LuaManager::uiModeChanged(const MWWorld::Ptr& arg) { if (mPlayer.isEmpty()) diff --git a/apps/openmw/mwlua/luamanagerimp.hpp b/apps/openmw/mwlua/luamanagerimp.hpp index 1ed9ed233e..a9657e4d61 100644 --- a/apps/openmw/mwlua/luamanagerimp.hpp +++ b/apps/openmw/mwlua/luamanagerimp.hpp @@ -70,6 +70,7 @@ namespace MWLua void newGameStarted() override; void gameLoaded() override; void gameEnded() override; + void noGame() override; void objectAddedToScene(const MWWorld::Ptr& ptr) override; void objectRemovedFromScene(const MWWorld::Ptr& ptr) override; void inputEvent(const InputEvent& event) override; diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index e02b6053ad..5927544f35 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -62,16 +62,19 @@ void MWState::StateManager::cleanup(bool force) MWBase::Environment::get().getInputManager()->clear(); MWBase::Environment::get().getMechanicsManager()->clear(); - mState = State_NoGame; mCharacterManager.setCurrentCharacter(nullptr); mTimePlayed = 0; mLastSavegame.clear(); - MWMechanics::CreatureStats::cleanup(); - endGame(); + mState = State_NoGame; + MWBase::Environment::get().getLuaManager()->noGame(); + } + else + { + // TODO: do we need this cleanup? + MWBase::Environment::get().getLuaManager()->clear(); } - MWBase::Environment::get().getLuaManager()->clear(); } std::map MWState::StateManager::buildContentFileIndexMap(const ESM::ESMReader& reader) const