diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 54fa6ab46..46c34f1b9 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -1,10 +1,12 @@ #include "engine.hpp" +#include "components/esm/loadcell.hpp" #include #include #include +#include #include #include #include @@ -107,11 +109,14 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) } //If the region has changed - if(mEnvironment.mWorld->getIsExterior() && test.name != mEnvironment.mWorld->getCurrentRegion().name){ - test = mEnvironment.mWorld->getCurrentRegion(); + MWWorld::Ptr::CellStore *current = mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); + if(!(current->cell->data.flags & current->cell->Interior) && (test.name != current->cell->region)){ + test = *(mEnvironment.mWorld->getStore().regions.find(current->cell->region)); if(test.soundList.size() > 0) { std::vector::iterator soundIter = test.soundList.begin(); + mEnvironment.mWorld->getPlayerPos().getPlayer().getCell(); + //mEnvironment.mSoundManager while (!(soundIter == test.soundList.end())) { ESM::NAME32 go = soundIter->sound; @@ -126,7 +131,7 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt) //printf("REGION: %s\n", test.name); } - else if(!mEnvironment.mWorld->getIsExterior()) + else if(current->cell->data.flags & current->cell->Interior) { test.name = ""; } diff --git a/apps/openmw/mwworld/world.cpp b/apps/openmw/mwworld/world.cpp index 3e91b76b8..317dc2361 100644 --- a/apps/openmw/mwworld/world.cpp +++ b/apps/openmw/mwworld/world.cpp @@ -66,30 +66,7 @@ namespace namespace MWWorld { - ESM::ESMReader World::getEsmReader(){ - return mEsm; - } - Ptr::CellStore World::getMCurrentCell() - { - return *mCurrentCell; - } - - - ESM::Region World::getCurrentRegion() - { - return *currentRegion; - } - - - bool World::getIsExterior() - { - return isExterior; - } - void World::setIsExterior(bool set) - { - isExterior = set; - } void World::insertInteriorScripts (ESMS::CellStore& cell) { listCellScripts (mStore, cell.activators, mLocalScripts, &cell); @@ -343,7 +320,6 @@ namespace MWWorld : mSkyManager (0), mScene (renderer), mPlayerPos (0), mCurrentCell (0), mGlobalVariables (0), mSky (false), mCellChanged (false), mEnvironment (environment) { - isExterior = false; boost::filesystem::path masterPath (dataDir); masterPath /= master; @@ -634,7 +610,6 @@ namespace MWWorld adjustSky(); mCellChanged = true; - isExterior = false; //currentRegion->name = ""; } @@ -712,11 +687,11 @@ namespace MWWorld mCellChanged = true; } - void World::changeToExteriorCell (const ESM::Position& position) + + void World::changeToExteriorCell (const ESM::Position& position) { int x = 0; int y = 0; - isExterior = true; positionToIndex (position.pos[0], position.pos[1], x, y); @@ -727,21 +702,9 @@ namespace MWWorld { // first try named cells if (const ESM::Cell *cell = mStore.cells.searchExtByName (cellName)) - { - //mCellChanged = true; - - getExteriorRegion(cell->region); return cell; - } - - - return getExteriorRegion(cellName); - } - - const ESM::Cell *World::getExteriorRegion(const std::string& cellName) const - { - // didn't work -> now check for regions + // didn't work -> now check for regions std::string cellName2 = ESMS::RecListT::toLower (cellName); for (ESMS::RecListT::MapType::const_iterator iter (mStore.regions.list.begin()); @@ -749,7 +712,6 @@ namespace MWWorld { if (ESMS::RecListT::toLower (iter->second.name)==cellName2) { - *currentRegion = iter->second; if (const ESM::Cell *cell = mStore.cells.searchExtByRegion (iter->first)) return cell; @@ -757,9 +719,8 @@ namespace MWWorld } } - return 0; - } - + return 0; + } void World::markCellAsUnchanged() { mCellChanged = false; diff --git a/apps/openmw/mwworld/world.hpp b/apps/openmw/mwworld/world.hpp index 56cba9e9a..f774cd68e 100644 --- a/apps/openmw/mwworld/world.hpp +++ b/apps/openmw/mwworld/world.hpp @@ -43,12 +43,6 @@ namespace MWWorld public: typedef std::list > ScriptList; - ESM::ESMReader getEsmReader(); - Ptr::CellStore getMCurrentCell(); - ESM::Region getCurrentRegion(); - bool getIsExterior(); - void setIsExterior(bool set); - private: typedef std::map CellRenderCollection; @@ -56,7 +50,7 @@ namespace MWWorld MWRender::SkyManager* mSkyManager; MWRender::MWScene mScene; MWRender::PlayerPos *mPlayerPos; - Ptr::CellStore *mCurrentCell; // the cell, the player is in + Ptr::CellStore *mCurrentCell; // the cell, the player is in CellRenderCollection mActiveCells; CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet) ESM::ESMReader mEsm; @@ -67,9 +61,7 @@ namespace MWWorld MWWorld::Globals *mGlobalVariables; bool mSky; bool mCellChanged; - bool isExterior; Environment& mEnvironment; - ESM::Region *currentRegion; // not implemented World (const World&); @@ -104,7 +96,7 @@ namespace MWWorld MWRender::PlayerPos& getPlayerPos(); - ESMS::ESMStore& getStore(); + ESMS::ESMStore& getStore(); const ScriptList& getLocalScripts() const; ///< Names and local variable state of all local scripts in active cells. @@ -154,7 +146,6 @@ namespace MWWorld void changeToExteriorCell (const ESM::Position& position); const ESM::Cell *getExterior (const std::string& cellName) const; - const ESM::Cell *getExteriorRegion (const std::string& cellName) const; ///< Return a cell matching the given name or a 0-pointer, if there is no such cell. void markCellAsUnchanged();