encapsulated water level

This commit is contained in:
Marc Zinnschlag 2014-02-23 17:34:18 +01:00
parent 79e723ad06
commit b72c1c2c58
4 changed files with 20 additions and 7 deletions

View file

@ -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<float>().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());
}
};

View file

@ -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::ESMReader> &esm)
{
if (mState!=State_Loaded)

View file

@ -65,6 +65,7 @@ namespace MWWorld
const ESM::Cell *mCell;
State mState;
std::vector<std::string> 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<ESM::Activator> mActivators;

View file

@ -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