diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 372378f312..abc9517269 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -131,6 +131,7 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager) , mFpsLevel(0) , mDebug (false) , mVerboseScripts (false) + , mNewGame (false) , mUseSound (true) , mCompileAll (false) , mScriptContext (0) @@ -277,6 +278,11 @@ void OMW::Engine::setScriptsVerbosity(bool scriptsVerbosity) mVerboseScripts = scriptsVerbosity; } +void OMW::Engine::setNewGame(bool newGame) +{ + mNewGame = newGame; +} + std::string OMW::Engine::loadSettings (Settings::Manager & settings) { // Create the settings manager and load default settings file @@ -375,6 +381,8 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) mEnvironment.setWindowManager (new MWGui::WindowManager( mExtensions, mFpsLevel, mOgre, mCfgMgr.getLogPath().string() + std::string("/"), mCfgMgr.getCachePath ().string(), mScriptConsoleMode, mTranslationDataStorage)); + if (mNewGame) + mEnvironment.getWindowManager()->setNewGame(true); // Create sound system mEnvironment.setSoundManager (new MWSound::SoundManager(mUseSound)); @@ -403,24 +411,29 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings) MWBase::Environment::get().getWorld()->getPlayer(), *MWBase::Environment::get().getWindowManager(), mDebug, *this, keybinderUser, keybinderUserExists)); - // load cell - ESM::Position pos; - pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - pos.pos[2] = 0; - mEnvironment.getWorld()->renderPlayer(); - if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName)) + if (!mNewGame) { - MWBase::Environment::get().getWorld()->indexToPosition (exterior->mData.mX, exterior->mData.mY, - pos.pos[0], pos.pos[1], true); - MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); + // load cell + ESM::Position pos; + pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; + pos.pos[2] = 0; + + if (const ESM::Cell *exterior = MWBase::Environment::get().getWorld()->getExterior (mCellName)) + { + MWBase::Environment::get().getWorld()->indexToPosition (exterior->mData.mX, exterior->mData.mY, + pos.pos[0], pos.pos[1], true); + MWBase::Environment::get().getWorld()->changeToExteriorCell (pos); + } + else + { + pos.pos[0] = pos.pos[1] = 0; + MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos); + } } else - { - pos.pos[0] = pos.pos[1] = 0; - MWBase::Environment::get().getWorld()->changeToInteriorCell (mCellName, pos); - } + mEnvironment.getWorld()->startNewGame(); Ogre::FrameEvent event; event.timeSinceLastEvent = 0; diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index 6742372d89..1fa461c2fb 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -136,6 +136,9 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat ("script-run", bpo::value()->default_value(""), "select a file containing a list of console commands that is executed on startup") + ("new-game", bpo::value()->implicit_value(true) + ->default_value(false), "activate char gen/new game mechanics") + ("fs-strict", bpo::value()->implicit_value(true) ->default_value(false), "strict file system handling (no case folding)") @@ -237,6 +240,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat // startup-settings engine.setCell(variables["start"].as()); + engine.setNewGame(variables["new-game"].as()); // other settings engine.setDebugMode(variables["debug"].as()); diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 564f62c8f1..cb2e49ca08 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -40,10 +40,7 @@ void MWWorld::Cells::clear() { mInteriors.clear(); mExteriors.clear(); - - mIdCache = std::vector >( - 40, std::pair ("", (MWWorld::Ptr::CellStore*)0)), /// \todo make cache size configurable - + std::fill(mIdCache.begin(), mIdCache.end(), std::make_pair("", (MWWorld::Ptr::CellStore*)0)); mIdCacheIndex = 0; } diff --git a/apps/openmw/mwworld/esmstore.hpp b/apps/openmw/mwworld/esmstore.hpp index 49458c9b90..d86faf7663 100644 --- a/apps/openmw/mwworld/esmstore.hpp +++ b/apps/openmw/mwworld/esmstore.hpp @@ -67,6 +67,8 @@ namespace MWWorld std::map mIds; std::map mStores; + ESM::NPC mPlayerTemplate; + unsigned int mDynamicCount; public: @@ -143,19 +145,17 @@ namespace MWWorld void clearDynamic () { - ESM::NPC playerNpc = *mNpcs.find("player"); - for (std::map::iterator it = mStores.begin(); it != mStores.end(); ++it) it->second->clearDynamic(); - mNpcs.insert(playerNpc); + mNpcs.insert(mPlayerTemplate); } void movePlayerRecord () { - ESM::NPC playerNpc = *mNpcs.find("player"); - mNpcs.eraseStatic(playerNpc.mId); - mNpcs.insert(playerNpc); + mPlayerTemplate = *mNpcs.find("player"); + mNpcs.eraseStatic(mPlayerTemplate.mId); + mNpcs.insert(mPlayerTemplate); } void load(ESM::ESMReader &esm); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index e8b68d2667..d7304f2b05 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -225,7 +225,6 @@ namespace MWWorld void World::startNewGame() { - mWorldScene->changeToVoid(); mStore.clearDynamic(); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 205361ef36..1baf3d4ba2 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -122,7 +122,7 @@ namespace MWWorld World (OEngine::Render::OgreRenderer& renderer, const Files::Collections& fileCollections, const std::vector& master, const std::vector& plugins, - const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, + const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, ToUTF8::Utf8Encoder* encoder, const std::map& fallbackMap, int mActivationDistanceOverride); virtual ~World();