diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 2140076c3..4d1c15f1e 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -132,7 +132,7 @@ namespace MWScript { MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(); if (cell->getCell()->hasWater()) - runtime.push (cell->mWaterLevel); + runtime.push (cell->getWaterLevel()); else runtime.push (-std::numeric_limits().max()); } @@ -151,8 +151,8 @@ namespace MWScript if (cell->getCell()->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); - cell->mWaterLevel = level; - MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); + cell->setWaterLevel (level); + MWBase::Environment::get().getWorld()->setWaterHeight (cell->getWaterLevel()); } }; @@ -169,8 +169,8 @@ namespace MWScript if (cell->getCell()->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); - cell->mWaterLevel +=level; - MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); + cell->setWaterLevel (cell->getWaterLevel()+level); + MWBase::Environment::get().getWorld()->setWaterHeight(cell->getWaterLevel()); } }; diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index e95fd226b..ceb27274e 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -233,6 +233,16 @@ namespace MWWorld return Ptr(); } + float CellStore::getWaterLevel() const + { + return mWaterLevel; + } + + void CellStore::setWaterLevel (float level) + { + mWaterLevel = level; + } + void CellStore::load (const MWWorld::ESMStore &store, std::vector &esm) { if (mState!=State_Loaded) diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 66f5bbf8d..428890764 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -65,6 +65,7 @@ namespace MWWorld const ESM::Cell *mCell; State mState; std::vector mIds; + float mWaterLevel; public: @@ -82,7 +83,9 @@ namespace MWWorld ///< Will return an empty Ptr if cell is not loaded. Does not check references in /// containers. - float mWaterLevel; + float getWaterLevel() const; + + void setWaterLevel (float level); // Lists for each individual object type CellRefList mActivators; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 4c97c594d..e258d8503 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1760,7 +1760,7 @@ namespace MWWorld if (!(cell->getCell()->mData.mFlags & ESM::Cell::HasWater)) { return false; } - return pos.z < cell->mWaterLevel; + return pos.z < cell->getWaterLevel(); } bool World::isOnGround(const MWWorld::Ptr &ptr) const