From 9fe505c8fa9483dcdc711fca841ca39d132fc2c4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Tue, 20 May 2014 18:35:17 +0200 Subject: [PATCH] Only run --script-run commands when bypassing the menu Running them while no game is started yet is dangerous, and also leaves bits and pieces of state (e.g. in LocalScripts for scripted items added to inventory) that will not get cleaned up properly when a game is loaded (since when no game was previously running, no cleanup is performed). As a result, dangling MWWorld::Ptrs were left in LocalScripts. --- apps/openmw/engine.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 66c09b6ff7..8c817b380e 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -462,10 +462,12 @@ void OMW::Engine::go() catch (...) {} } else + { MWBase::Environment::get().getStateManager()->newGame (true); - if (!mStartupScript.empty()) - MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript); + if (!mStartupScript.empty()) + MWBase::Environment::get().getWindowManager()->executeInConsole (mStartupScript); + } // Start the main rendering loop while (!mEnvironment.get().getStateManager()->hasQuitRequest())