From 7693f712bcc5e661961157b03dd2ade794b7ea24 Mon Sep 17 00:00:00 2001 From: Marc Zinnschlag Date: Fri, 21 Feb 2014 11:35:46 +0100 Subject: [PATCH] started making CellStore into a proper class; encapsulated mCell member --- apps/openmw/mwdialogue/filter.cpp | 4 +- apps/openmw/mwgui/mapwindow.cpp | 2 +- apps/openmw/mwgui/travelwindow.cpp | 6 ++- apps/openmw/mwgui/waitdialog.cpp | 2 +- apps/openmw/mwgui/windowmanagerimp.cpp | 16 ++++---- apps/openmw/mwmechanics/aiactivate.cpp | 10 ++--- apps/openmw/mwmechanics/aicombat.cpp | 30 +++++++------- apps/openmw/mwmechanics/aiescort.cpp | 22 +++++----- apps/openmw/mwmechanics/aifollow.cpp | 8 ++-- apps/openmw/mwmechanics/aitravel.cpp | 10 ++--- apps/openmw/mwmechanics/aiwander.cpp | 10 ++--- apps/openmw/mwmechanics/pathfinding.cpp | 8 ++-- apps/openmw/mwmechanics/spellcasting.cpp | 2 +- apps/openmw/mwrender/animation.cpp | 4 +- apps/openmw/mwrender/debugging.cpp | 16 ++++---- apps/openmw/mwrender/localmap.cpp | 8 ++-- apps/openmw/mwrender/renderingmanager.cpp | 20 ++++----- apps/openmw/mwscript/cellextensions.cpp | 10 ++--- apps/openmw/mwsound/soundmanagerimp.cpp | 4 +- apps/openmw/mwstate/statemanagerimp.cpp | 2 +- apps/openmw/mwworld/cells.cpp | 4 +- apps/openmw/mwworld/cellstore.cpp | 5 +++ apps/openmw/mwworld/cellstore.hpp | 23 +++++++---- apps/openmw/mwworld/physicssystem.cpp | 2 +- apps/openmw/mwworld/player.cpp | 4 +- apps/openmw/mwworld/scene.cpp | 50 +++++++++++------------ apps/openmw/mwworld/weather.cpp | 4 +- apps/openmw/mwworld/worldimp.cpp | 20 ++++----- 28 files changed, 161 insertions(+), 145 deletions(-) diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 3d45b85ce..846cff114 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -110,7 +110,7 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const // check cell if (!info.mCell.empty()) - if (!Misc::StringUtils::ciEqual(player.getCell()->mCell->mName, info.mCell)) + if (!Misc::StringUtils::ciEqual(player.getCell()->getCell()->mName, info.mCell)) return false; return true; @@ -445,7 +445,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co case SelectWrapper::Function_NotCell: - return !Misc::StringUtils::ciEqual(mActor.getCell()->mCell->mName, select.getName()); + return !Misc::StringUtils::ciEqual(mActor.getCell()->getCell()->mName, select.getName()); case SelectWrapper::Function_NotLocal: { diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 1b4af6d82..267c761e2 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -356,7 +356,7 @@ namespace MWGui ESM::Position markedPosition; MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition); if (markedCell && markedCell->isExterior() == !mInterior - && (!mInterior || Misc::StringUtils::ciEqual(markedCell->mCell->mName, mPrefix))) + && (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix))) { MarkerPosition markerPos; MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos); diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index c314ce1fd..348178d81 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -109,7 +109,11 @@ namespace MWGui int x,y; MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get()->mBase->mTransport[i].mPos.pos[0], mPtr.get()->mBase->mTransport[i].mPos.pos[1],x,y); - if(cellname == "") {cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->mCell->mName; interior= false;} + if (cellname == "") + { + cellname = MWBase::Environment::get().getWorld()->getExterior(x,y)->getCell()->mName; + interior = false; + } addDestination(cellname,mPtr.get()->mBase->mTransport[i].mPos,interior); } diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 3c1a4b3fa..fd487c87f 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -129,7 +129,7 @@ namespace MWGui MWWorld::Ptr player = world->getPlayerPtr(); if (mSleeping && player.getCell()->isExterior()) { - std::string regionstr = player.getCell()->mCell->mRegion; + std::string regionstr = player.getCell()->getCell()->mRegion; if (!regionstr.empty()) { const ESM::Region *region = world->getStore().get().find (regionstr); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index 5448bc3c4..ba9684589 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -739,22 +739,22 @@ namespace MWGui mMap->setCellName( name ); mHud->setCellName( name ); - if (cell->mCell->isExterior()) + if (cell->getCell()->isExterior()) { - if (!cell->mCell->mName.empty()) - mMap->addVisitedLocation ("#{sCell=" + name + "}", cell->mCell->getGridX (), cell->mCell->getGridY ()); + if (!cell->getCell()->mName.empty()) + mMap->addVisitedLocation ("#{sCell=" + name + "}", cell->getCell()->getGridX (), cell->getCell()->getGridY ()); - mMap->cellExplored(cell->mCell->getGridX(), cell->mCell->getGridY()); + mMap->cellExplored (cell->getCell()->getGridX(), cell->getCell()->getGridY()); mMap->setCellPrefix("Cell"); mHud->setCellPrefix("Cell"); - mMap->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); - mHud->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); + mMap->setActiveCell (cell->getCell()->getGridX(), cell->getCell()->getGridY()); + mHud->setActiveCell (cell->getCell()->getGridX(), cell->getCell()->getGridY()); } else { - mMap->setCellPrefix( cell->mCell->mName ); - mHud->setCellPrefix( cell->mCell->mName ); + mMap->setCellPrefix (cell->getCell()->mName ); + mHud->setCellPrefix (cell->getCell()->mName ); Ogre::Vector3 worldPos; if (!MWBase::Environment::get().getWorld()->findInteriorPositionInWorldSpace(cell, worldPos)) diff --git a/apps/openmw/mwmechanics/aiactivate.cpp b/apps/openmw/mwmechanics/aiactivate.cpp index 1f3c58521..ea146625a 100644 --- a/apps/openmw/mwmechanics/aiactivate.cpp +++ b/apps/openmw/mwmechanics/aiactivate.cpp @@ -33,12 +33,12 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration) MWBase::World *world = MWBase::Environment::get().getWorld(); ESM::Position pos = actor.getRefData().getPosition(); Movement &movement = actor.getClass().getMovementSettings(actor); - const ESM::Cell *cell = actor.getCell()->mCell; + const ESM::Cell *cell = actor.getCell()->getCell(); MWWorld::Ptr player = world->getPlayerPtr(); - if(cell->mData.mX != player.getCell()->mCell->mData.mX) + if(cell->mData.mX != player.getCell()->getCell()->mData.mX) { - int sideX = sgn(cell->mData.mX - player.getCell()->mCell->mData.mX); + int sideX = sgn(cell->mData.mX - player.getCell()->getCell()->mData.mX); //check if actor is near the border of an inactive cell. If so, stop walking. if(sideX * (pos.pos[0] - cell->mData.mX*ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) @@ -47,9 +47,9 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration) return false; } } - if(cell->mData.mY != player.getCell()->mCell->mData.mY) + if(cell->mData.mY != player.getCell()->getCell()->mData.mY) { - int sideY = sgn(cell->mData.mY - player.getCell()->mCell->mData.mY); + int sideY = sgn(cell->mData.mY - player.getCell()->getCell()->mData.mY); //check if actor is near the border of an inactive cell. If so, stop walking. if(sideY * (pos.pos[1] - cell->mData.mY*ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index 3653587f8..b0e0c2f7b 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -34,9 +34,9 @@ namespace namespace MWMechanics { AiCombat::AiCombat(const MWWorld::Ptr& actor) : - mTarget(actor), - mTimerAttack(0), - mTimerReact(0), + mTarget(actor), + mTimerAttack(0), + mTimerReact(0), mTimerCombatMove(0), mFollowTarget(false), mReadyToAttack(false), @@ -77,7 +77,7 @@ namespace MWMechanics if (zTurn(actor, Ogre::Degree(mTargetAngle))) mRotate = false; } - + mTimerAttack -= duration; actor.getClass().getCreatureStats(actor).setAttackingOrSpell(mStrike); @@ -105,7 +105,7 @@ namespace MWMechanics //Also it seems that this time is different for slash/thrust/chop mTimerAttack = 0.35f * static_cast(rand())/RAND_MAX; mStrike = true; - + //say a provoking combat phrase if (actor.getClass().isNpc()) { @@ -126,7 +126,7 @@ namespace MWMechanics mTimerAttack = -attackPeriod; mStrike = false; } - + const MWWorld::Class &cls = actor.getClass(); const ESM::Weapon *weapon = NULL; MWMechanics::WeaponType weaptype; @@ -138,14 +138,14 @@ namespace MWMechanics { MWMechanics::DrawState_ state = actor.getClass().getCreatureStats(actor).getDrawState(); if (state == MWMechanics::DrawState_Spell || state == MWMechanics::DrawState_Nothing) - actor.getClass().getNpcStats(actor).setDrawState(MWMechanics::DrawState_Weapon); + actor.getClass().getNpcStats(actor).setDrawState(MWMechanics::DrawState_Weapon); //Get weapon speed and range - MWWorld::ContainerStoreIterator weaponSlot = + MWWorld::ContainerStoreIterator weaponSlot = MWMechanics::getActiveWeapon(cls.getNpcStats(actor), cls.getInventoryStore(actor), &weaptype); if (weaptype == WeapType_HandToHand) { - const MWWorld::Store &gmst = + const MWWorld::Store &gmst = MWBase::Environment::get().getWorld()->getStore().get(); weapRange = gmst.find("fHandToHandReach")->getFloat(); } @@ -246,12 +246,12 @@ namespace MWMechanics mPathFinder.checkPathCompleted(pos.pos[0],pos.pos[1],pos.pos[2]); //try shortcut - if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget)) + if(vDir.length() < mPathFinder.getDistToNext(pos.pos[0],pos.pos[1],pos.pos[2]) && MWBase::Environment::get().getWorld()->getLOS(actor, mTarget)) mTargetAngle = Ogre::Radian( Ogre::Math::ACos(vDir.y / vDir.length()) * sgn(Ogre::Math::ASin(vDir.x / vDir.length())) ).valueDegrees(); else mTargetAngle = mPathFinder.getZAngleToNext(pos.pos[0], pos.pos[1]); mRotate = true; - + mMovement.mPosition[1] = 1; mReadyToAttack = false; } @@ -305,13 +305,13 @@ namespace MWMechanics float dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length()); float targetPosThreshold; - bool isOutside = actor.getCell()->mCell->isExterior(); + bool isOutside = actor.getCell()->getCell()->isExterior(); if (isOutside) targetPosThreshold = 300; else targetPosThreshold = 100; - if(dist > targetPosThreshold) + if(dist > targetPosThreshold) { //construct new path only if target has moved away more than on ESM::Position pos = actor.getRefData().getPosition(); @@ -328,7 +328,7 @@ namespace MWMechanics PathFinder newPathFinder; newPathFinder.buildPath(start, dest, actor.getCell(), isOutside); - //TO EXPLORE: + //TO EXPLORE: //maybe here is a mistake (?): PathFinder::getPathSize() returns number of grid points in the path, //not the actual path length. Here we should know if the new path is actually more effective. //if(pathFinder2.getPathSize() < mPathFinder.getPathSize()) @@ -391,7 +391,7 @@ void chooseBestAttack(const ESM::Weapon* weapon, MWMechanics::Movement &movement int thrust = (weapon->mData.mThrust[0] + weapon->mData.mThrust[1])/2; float total = slash + chop + thrust; - + float roll = static_cast(rand())/RAND_MAX; if(roll <= static_cast(slash)/total) { diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index bac258425..a58bfef05 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -86,25 +86,25 @@ namespace MWMechanics MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); ESM::Position pos = actor.getRefData().getPosition(); - bool cellChange = actor.getCell()->mCell->mData.mX != mCellX || actor.getCell()->mCell->mData.mY != mCellY; + bool cellChange = actor.getCell()->getCell()->mData.mX != mCellX || actor.getCell()->getCell()->mData.mY != mCellY; - if(actor.getCell()->mCell->mData.mX != player.getCell()->mCell->mData.mX) + if(actor.getCell()->getCell()->mData.mX != player.getCell()->getCell()->mData.mX) { - int sideX = sgn(actor.getCell()->mCell->mData.mX - player.getCell()->mCell->mData.mX); + int sideX = sgn(actor.getCell()->getCell()->mData.mX - player.getCell()->getCell()->mData.mX); // Check if actor is near the border of an inactive cell. If so, pause walking. - if(sideX * (pos.pos[0] - actor.getCell()->mCell->mData.mX * ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE / - 2.0 - 200)) + if(sideX * (pos.pos[0] - actor.getCell()->getCell()->mData.mX * ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE / + 2.0 - 200)) { MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; return false; } } - if(actor.getCell()->mCell->mData.mY != player.getCell()->mCell->mData.mY) + if(actor.getCell()->getCell()->mData.mY != player.getCell()->getCell()->mData.mY) { - int sideY = sgn(actor.getCell()->mCell->mData.mY - player.getCell()->mCell->mData.mY); + int sideY = sgn(actor.getCell()->getCell()->mData.mY - player.getCell()->getCell()->mData.mY); // Check if actor is near the border of an inactive cell. If so, pause walking. - if(sideY*(pos.pos[1] - actor.getCell()->mCell->mData.mY * ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE / - 2.0 - 200)) + if(sideY*(pos.pos[1] - actor.getCell()->getCell()->mData.mY * ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE / + 2.0 - 200)) { MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; return false; @@ -114,8 +114,8 @@ namespace MWMechanics if(!mPathFinder.isPathConstructed() || cellChange) { - mCellX = actor.getCell()->mCell->mData.mX; - mCellY = actor.getCell()->mCell->mData.mY; + mCellX = actor.getCell()->getCell()->mData.mX; + mCellY = actor.getCell()->getCell()->mData.mY; ESM::Pathgrid::Point dest; dest.mX = mX; diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index cf5291fd3..ef6ead9d7 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -33,16 +33,16 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration) if((pos.pos[0]-mX)*(pos.pos[0]-mX) + (pos.pos[1]-mY)*(pos.pos[1]-mY) + - (pos.pos[2]-mZ)*(pos.pos[2]-mZ) < 100*100) + (pos.pos[2]-mZ)*(pos.pos[2]-mZ) < 100*100) { if(actor.getCell()->isExterior()) { - if(mCellId == "") + if(mCellId == "") return true; } else { - if(mCellId == actor.getCell()->mCell->mName) + if(mCellId == actor.getCell()->getCell()->mName) return true; } } @@ -67,7 +67,7 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration) { ESM::Pathgrid::Point lastPos = mPathFinder.getPath().back(); - if((dest.mX - lastPos.mX)*(dest.mX - lastPos.mX) + if((dest.mX - lastPos.mX)*(dest.mX - lastPos.mX) +(dest.mY - lastPos.mY)*(dest.mY - lastPos.mY) +(dest.mZ - lastPos.mZ)*(dest.mZ - lastPos.mZ) > 100*100) diff --git a/apps/openmw/mwmechanics/aitravel.cpp b/apps/openmw/mwmechanics/aitravel.cpp index 03052f327..41226ad79 100644 --- a/apps/openmw/mwmechanics/aitravel.cpp +++ b/apps/openmw/mwmechanics/aitravel.cpp @@ -36,12 +36,12 @@ namespace MWMechanics MWBase::World *world = MWBase::Environment::get().getWorld(); ESM::Position pos = actor.getRefData().getPosition(); Movement &movement = actor.getClass().getMovementSettings(actor); - const ESM::Cell *cell = actor.getCell()->mCell; + const ESM::Cell *cell = actor.getCell()->getCell(); MWWorld::Ptr player = world->getPlayerPtr(); - if(cell->mData.mX != player.getCell()->mCell->mData.mX) + if(cell->mData.mX != player.getCell()->getCell()->mData.mX) { - int sideX = sgn(cell->mData.mX - player.getCell()->mCell->mData.mX); + int sideX = sgn(cell->mData.mX - player.getCell()->getCell()->mData.mX); //check if actor is near the border of an inactive cell. If so, stop walking. if(sideX * (pos.pos[0] - cell->mData.mX*ESM::Land::REAL_SIZE) > sideX * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) @@ -50,9 +50,9 @@ namespace MWMechanics return false; } } - if(cell->mData.mY != player.getCell()->mCell->mData.mY) + if(cell->mData.mY != player.getCell()->getCell()->mData.mY) { - int sideY = sgn(cell->mData.mY - player.getCell()->mCell->mData.mY); + int sideY = sgn(cell->mData.mY - player.getCell()->getCell()->mData.mY); //check if actor is near the border of an inactive cell. If so, stop walking. if(sideY * (pos.pos[1] - cell->mData.mY*ESM::Land::REAL_SIZE) > sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) diff --git a/apps/openmw/mwmechanics/aiwander.cpp b/apps/openmw/mwmechanics/aiwander.cpp index 77316fedf..012f71b72 100644 --- a/apps/openmw/mwmechanics/aiwander.cpp +++ b/apps/openmw/mwmechanics/aiwander.cpp @@ -103,10 +103,10 @@ namespace MWMechanics if(!mStoredAvailableNodes) { mStoredAvailableNodes = true; - mPathgrid = world->getStore().get().search(*actor.getCell()->mCell); + mPathgrid = world->getStore().get().search(*actor.getCell()->getCell()); - mCellX = actor.getCell()->mCell->mData.mX; - mCellY = actor.getCell()->mCell->mData.mY; + mCellX = actor.getCell()->getCell()->mData.mX; + mCellY = actor.getCell()->getCell()->mData.mY; if(!mPathgrid) mDistance = 0; @@ -117,7 +117,7 @@ namespace MWMechanics { mXCell = 0; mYCell = 0; - if(actor.getCell()->mCell->isExterior()) + if(actor.getCell()->getCell()->isExterior()) { mXCell = mCellX * ESM::Land::REAL_SIZE; mYCell = mCellY * ESM::Land::REAL_SIZE; @@ -157,7 +157,7 @@ namespace MWMechanics mDistance = 0; // Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles. - if(mDistance && (mCellX != actor.getCell()->mCell->mData.mX || mCellY != actor.getCell()->mCell->mData.mY)) + if(mDistance && (mCellX != actor.getCell()->getCell()->mData.mX || mCellY != actor.getCell()->getCell()->mData.mY)) mDistance = 0; if(mChooseAction) diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 4407363a6..2503181ae 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -299,14 +299,14 @@ namespace MWMechanics if(!allowShortcuts) { const ESM::Pathgrid *pathGrid = - MWBase::Environment::get().getWorld()->getStore().get().search(*mCell->mCell); + MWBase::Environment::get().getWorld()->getStore().get().search(*mCell->getCell()); float xCell = 0; float yCell = 0; if (mCell->isExterior()) { - xCell = mCell->mCell->mData.mX * ESM::Land::REAL_SIZE; - yCell = mCell->mCell->mData.mY * ESM::Land::REAL_SIZE; + xCell = mCell->getCell()->mData.mX * ESM::Land::REAL_SIZE; + yCell = mCell->getCell()->mData.mY * ESM::Land::REAL_SIZE; } int startNode = getClosestPoint(pathGrid, startPoint.mX - xCell, startPoint.mY - yCell,startPoint.mZ); int endNode = getClosestPoint(pathGrid, endPoint.mX - xCell, endPoint.mY - yCell, endPoint.mZ); @@ -393,7 +393,7 @@ namespace MWMechanics { std::list::const_iterator oldStart = path.begin(); std::list::iterator iter = ++mPath.begin(); - + if( (*iter).mX == oldStart->mX && (*iter).mY == oldStart->mY && (*iter).mZ == oldStart->mZ diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index fe395e566..30072a8cc 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -503,7 +503,7 @@ namespace MWMechanics MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition); if (markedCell) { - MWWorld::ActionTeleport action(markedCell->isExterior() ? "" : markedCell->mCell->mName, + MWWorld::ActionTeleport action(markedCell->isExterior() ? "" : markedCell->getCell()->mName, markedPosition); action.execute(target); } diff --git a/apps/openmw/mwrender/animation.cpp b/apps/openmw/mwrender/animation.cpp index 44bba90d0..820857137 100644 --- a/apps/openmw/mwrender/animation.cpp +++ b/apps/openmw/mwrender/animation.cpp @@ -334,7 +334,7 @@ void Animation::addExtraLight(Ogre::SceneManager *sceneMgr, NifOgre::ObjectScene )); objlist->mControllers.push_back(Ogre::Controller(src, dest, func)); - bool interior = !(mPtr.isInCell() && mPtr.getCell()->mCell->isExterior()); + bool interior = !(mPtr.isInCell() && mPtr.getCell()->getCell()->isExterior()); bool quadratic = fallback->getFallbackBool("LightAttenuation_OutQuadInLin") ? !interior : fallback->getFallbackBool("LightAttenuation_UseQuadratic"); @@ -1070,7 +1070,7 @@ bool Animation::allowSwitchViewMode() const { for (AnimStateMap::const_iterator stateiter = mStates.begin(); stateiter != mStates.end(); ++stateiter) { - if(stateiter->second.mPriority > MWMechanics::Priority_Movement + if(stateiter->second.mPriority > MWMechanics::Priority_Movement && stateiter->second.mPriority < MWMechanics::Priority_Torch) return false; } diff --git a/apps/openmw/mwrender/debugging.cpp b/apps/openmw/mwrender/debugging.cpp index 2b61e109b..0cfcf826f 100644 --- a/apps/openmw/mwrender/debugging.cpp +++ b/apps/openmw/mwrender/debugging.cpp @@ -230,22 +230,22 @@ void Debugging::togglePathgrid() void Debugging::enableCellPathgrid(MWWorld::CellStore *store) { const ESM::Pathgrid *pathgrid = - MWBase::Environment::get().getWorld()->getStore().get().search(*store->mCell); + MWBase::Environment::get().getWorld()->getStore().get().search(*store->getCell()); if (!pathgrid) return; Vector3 cellPathGridPos(0, 0, 0); - if (store->mCell->isExterior()) + if (store->getCell()->isExterior()) { - cellPathGridPos.x = store->mCell->mData.mX * ESM::Land::REAL_SIZE; - cellPathGridPos.y = store->mCell->mData.mY * ESM::Land::REAL_SIZE; + cellPathGridPos.x = store->getCell()->mData.mX * ESM::Land::REAL_SIZE; + cellPathGridPos.y = store->getCell()->mData.mY * ESM::Land::REAL_SIZE; } SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos); cellPathGrid->attachObject(createPathgridLines(pathgrid)); cellPathGrid->attachObject(createPathgridPoints(pathgrid)); - if (store->mCell->isExterior()) + if (store->getCell()->isExterior()) { - mExteriorPathgridNodes[std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())] = cellPathGrid; + mExteriorPathgridNodes[std::make_pair(store->getCell()->getGridX(), store->getCell()->getGridY())] = cellPathGrid; } else { @@ -256,10 +256,10 @@ void Debugging::enableCellPathgrid(MWWorld::CellStore *store) void Debugging::disableCellPathgrid(MWWorld::CellStore *store) { - if (store->mCell->isExterior()) + if (store->getCell()->isExterior()) { ExteriorPathgridNodes::iterator it = - mExteriorPathgridNodes.find(std::make_pair(store->mCell->getGridX(), store->mCell->getGridY())); + mExteriorPathgridNodes.find(std::make_pair(store->getCell()->getGridX(), store->getCell()->getGridY())); if (it != mExteriorPathgridNodes.end()) { destroyCellPathgridNode(it->second); diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index f147ae7b7..554ba22fa 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -115,8 +115,8 @@ void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax) mCameraRotNode->setOrientation(Quaternion::IDENTITY); mCellCamera->setOrientation(Quaternion(Ogre::Math::Cos(Ogre::Degree(0)/2.f), 0, 0, -Ogre::Math::Sin(Ogre::Degree(0)/2.f))); - int x = cell->mCell->getGridX(); - int y = cell->mCell->getGridY(); + int x = cell->getCell()->getGridX(); + int y = cell->getCell()->getGridY(); std::string name = "Cell_"+coordStr(x, y); @@ -182,7 +182,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell, const int segsX = std::ceil( length.x / sSize ); const int segsY = std::ceil( length.y / sSize ); - mInteriorName = cell->mCell->mName; + mInteriorName = cell->getCell()->mName; for (int x=0; xmCell->mName + "_" + coordStr(x,y)); + cell->getCell()->mName + "_" + coordStr(x,y)); } } } diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 0a82d67fb..0311c90b3 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -422,9 +422,9 @@ void RenderingManager::postRenderTargetUpdate(const RenderTargetEvent &evt) void RenderingManager::waterAdded (MWWorld::CellStore *store) { - if(store->mCell->mData.mFlags & ESM::Cell::HasWater) + if (store->getCell()->mData.mFlags & ESM::Cell::HasWater) { - mWater->changeCell(store->mCell); + mWater->changeCell (store->getCell()); mWater->setActive(true); } else @@ -501,9 +501,9 @@ bool RenderingManager::toggleRenderMode(int mode) void RenderingManager::configureFog(MWWorld::CellStore &mCell) { Ogre::ColourValue color; - color.setAsABGR (mCell.mCell->mAmbi.mFog); + color.setAsABGR (mCell.getCell()->mAmbi.mFog); - configureFog(mCell.mCell->mAmbi.mFogDensity, color); + configureFog (mCell.getCell()->mAmbi.mFogDensity, color); } void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour) @@ -553,8 +553,8 @@ void RenderingManager::setAmbientMode() void RenderingManager::configureAmbient(MWWorld::CellStore &mCell) { - if (mCell.mCell->mData.mFlags & ESM::Cell::Interior) - mAmbientColor.setAsABGR (mCell.mCell->mAmbi.mAmbient); + if (mCell.getCell()->mData.mFlags & ESM::Cell::Interior) + mAmbientColor.setAsABGR (mCell.getCell()->mAmbi.mAmbient); setAmbientMode(); // Create a "sun" that shines light downwards. It doesn't look @@ -564,10 +564,10 @@ void RenderingManager::configureAmbient(MWWorld::CellStore &mCell) mSun = mRendering.getScene()->createLight(); mSun->setType(Ogre::Light::LT_DIRECTIONAL); } - if (mCell.mCell->mData.mFlags & ESM::Cell::Interior) + if (mCell.getCell()->mData.mFlags & ESM::Cell::Interior) { Ogre::ColourValue colour; - colour.setAsABGR (mCell.mCell->mAmbi.mSunlight); + colour.setAsABGR (mCell.getCell()->mAmbi.mSunlight); mSun->setDiffuseColour (colour); mSun->setDirection(0,-1,0); } @@ -650,12 +650,12 @@ void RenderingManager::setGlare(bool glare) void RenderingManager::requestMap(MWWorld::CellStore* cell) { - if (cell->mCell->isExterior()) + if (cell->getCell()->isExterior()) { assert(mTerrain); Ogre::AxisAlignedBox dims = mObjects->getDimensions(cell); - Ogre::Vector2 center(cell->mCell->getGridX() + 0.5, cell->mCell->getGridY() + 0.5); + Ogre::Vector2 center (cell->getCell()->getGridX() + 0.5, cell->getCell()->getGridY() + 0.5); dims.merge(mTerrain->getWorldBoundingBox(center)); if (dims.isFinite()) diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index a0acfa4da..2140076c3 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -88,7 +88,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { bool interior = - !MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->mCell->isExterior(); + !MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell()->isExterior(); runtime.push (interior ? 1 : 0); } @@ -103,7 +103,7 @@ namespace MWScript std::string name = runtime.getStringLiteral (runtime[0].mInteger); runtime.pop(); - const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->mCell; + const ESM::Cell *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell(); std::string current = cell->mName; @@ -131,7 +131,7 @@ namespace MWScript virtual void execute (Interpreter::Runtime& runtime) { MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(); - if (cell->mCell->hasWater()) + if (cell->getCell()->hasWater()) runtime.push (cell->mWaterLevel); else runtime.push (-std::numeric_limits().max()); @@ -148,7 +148,7 @@ namespace MWScript MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(); - if (cell->mCell->isExterior()) + if (cell->getCell()->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel = level; @@ -166,7 +166,7 @@ namespace MWScript MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(); - if (cell->mCell->isExterior()) + if (cell->getCell()->isExterior()) throw std::runtime_error("Can't set water level in exterior cell"); cell->mWaterLevel +=level; diff --git a/apps/openmw/mwsound/soundmanagerimp.cpp b/apps/openmw/mwsound/soundmanagerimp.cpp index fd3fe4c0a..13e152e68 100644 --- a/apps/openmw/mwsound/soundmanagerimp.cpp +++ b/apps/openmw/mwsound/soundmanagerimp.cpp @@ -480,7 +480,7 @@ namespace MWSound static float sTimePassed = 0.0; MWBase::World *world = MWBase::Environment::get().getWorld(); const MWWorld::Ptr player = world->getPlayerPtr(); - const ESM::Cell *cell = player.getCell()->mCell; + const ESM::Cell *cell = player.getCell()->getCell(); sTimePassed += duration; if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound) @@ -548,7 +548,7 @@ namespace MWSound MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); - const ESM::Cell *cell = player.getCell()->mCell; + const ESM::Cell *cell = player.getCell()->getCell(); Environment env = Env_Normal; if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater) diff --git a/apps/openmw/mwstate/statemanagerimp.cpp b/apps/openmw/mwstate/statemanagerimp.cpp index ba0e1d056..8c59247f4 100644 --- a/apps/openmw/mwstate/statemanagerimp.cpp +++ b/apps/openmw/mwstate/statemanagerimp.cpp @@ -301,7 +301,7 @@ void MWState::StateManager::loadGame (const Character *character, const Slot *sl MWWorld::Ptr ptr = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); - ESM::CellId cellId = ptr.getCell()->mCell->getCellId(); + ESM::CellId cellId = ptr.getCell()->getCell()->getCellId(); MWBase::Environment::get().getWorld()->changeToCell (cellId, ptr.getRefData().getPosition()); } diff --git a/apps/openmw/mwworld/cells.cpp b/apps/openmw/mwworld/cells.cpp index 965c9fc5d..cdfbb7b45 100644 --- a/apps/openmw/mwworld/cells.cpp +++ b/apps/openmw/mwworld/cells.cpp @@ -83,8 +83,8 @@ bool MWWorld::Cells::hasState (const CellStore& cellStore) const if (cellStore.mState==CellStore::State_Loaded) return true; - if (cellStore.mCell->mData.mFlags & ESM::Cell::Interior) - return cellStore.mCell->mData.mFlags & ESM::Cell::HasWater; + if (cellStore.getCell()->mData.mFlags & ESM::Cell::Interior) + return cellStore.getCell()->mData.mFlags & ESM::Cell::HasWater; else return false; } diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 42c954afb..c3c3eb6e9 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -145,6 +145,11 @@ namespace MWWorld mWaterLevel = cell->mWater; } + const ESM::Cell *CellStore::getCell() const + { + return mCell; + } + 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 a4f219013..b90ea72a5 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -49,19 +49,26 @@ namespace MWWorld } }; - /// A storage struct for one single cell reference. + /// \brief Mutable state of a cell class CellStore { - public: + public: - enum State - { - State_Unloaded, State_Preloaded, State_Loaded - }; + enum State + { + State_Unloaded, State_Preloaded, State_Loaded + }; + + private: + + const ESM::Cell *mCell; + + public: + + CellStore (const ESM::Cell *cell_); - CellStore (const ESM::Cell *cell_); + const ESM::Cell *getCell() const; - const ESM::Cell *mCell; State mState; std::vector mIds; diff --git a/apps/openmw/mwworld/physicssystem.cpp b/apps/openmw/mwworld/physicssystem.cpp index a7103b991..56d19c8be 100644 --- a/apps/openmw/mwworld/physicssystem.cpp +++ b/apps/openmw/mwworld/physicssystem.cpp @@ -574,7 +574,7 @@ namespace MWWorld for(;iter != mMovementQueue.end();iter++) { float waterlevel = -std::numeric_limits::max(); - const ESM::Cell *cell = iter->first.getCell()->mCell; + const ESM::Cell *cell = iter->first.getCell()->getCell(); if(cell->hasWater()) waterlevel = cell->mWater; diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index c1cce84fc..ba816d6d5 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -191,7 +191,7 @@ namespace MWWorld ESM::Player player; mPlayer.save (player.mObject); - player.mCellId = mCellStore->mCell->getCellId(); + player.mCellId = mCellStore->getCell()->getCellId(); player.mBirthsign = mSign; @@ -203,7 +203,7 @@ namespace MWWorld { player.mHasMark = true; player.mMarkedPosition = mMarkedPosition; - player.mMarkedCell = mMarkedCell->mCell->getCellId(); + player.mMarkedCell = mMarkedCell->getCell()->getCellId(); } else player.mHasMark = false; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 167adf301..06141db54 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -97,15 +97,15 @@ namespace MWWorld } } - if ((*iter)->mCell->isExterior()) + if ((*iter)->getCell()->isExterior()) { ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().get().search( - (*iter)->mCell->getGridX(), - (*iter)->mCell->getGridY() + (*iter)->getCell()->getGridX(), + (*iter)->getCell()->getGridY() ); if (land) - mPhysics->removeHeightField( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() ); + mPhysics->removeHeightField ((*iter)->getCell()->getGridX(), (*iter)->getCell()->getGridY()); } mRendering.removeCell(*iter); @@ -128,18 +128,18 @@ namespace MWWorld float worldsize = ESM::Land::REAL_SIZE; // Load terrain physics first... - if (cell->mCell->isExterior()) + if (cell->getCell()->isExterior()) { ESM::Land* land = MWBase::Environment::get().getWorld()->getStore().get().search( - cell->mCell->getGridX(), - cell->mCell->getGridY() + cell->getCell()->getGridX(), + cell->getCell()->getGridY() ); if (land) { mPhysics->addHeightField ( land->mLandData->mHeights, - cell->mCell->getGridX(), - cell->mCell->getGridY(), + cell->getCell()->getGridX(), + cell->getCell()->getGridY(), 0, worldsize / (verts-1), verts) @@ -218,10 +218,10 @@ namespace MWWorld int numUnload = 0; while (active!=mActiveCells.end()) { - if ((*active)->mCell->isExterior()) + if ((*active)->getCell()->isExterior()) { - if (std::abs (X-(*active)->mCell->getGridX())<=1 && - std::abs (Y-(*active)->mCell->getGridY())<=1) + if (std::abs (X-(*active)->getCell()->getGridX())<=1 && + std::abs (Y-(*active)->getCell()->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; @@ -235,10 +235,10 @@ namespace MWWorld active = mActiveCells.begin(); while (active!=mActiveCells.end()) { - if ((*active)->mCell->isExterior()) + if ((*active)->getCell()->isExterior()) { - if (std::abs (X-(*active)->mCell->getGridX())<=1 && - std::abs (Y-(*active)->mCell->getGridY())<=1) + if (std::abs (X-(*active)->getCell()->getGridX())<=1 && + std::abs (Y-(*active)->getCell()->getGridY())<=1) { // keep cells within the new 3x3 grid ++active; @@ -257,10 +257,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert ((*iter)->mCell->isExterior()); + assert ((*iter)->getCell()->isExterior()); - if (x==(*iter)->mCell->getGridX() && - y==(*iter)->mCell->getGridY()) + if (x==(*iter)->getCell()->getGridX() && + y==(*iter)->getCell()->getGridY()) break; ++iter; @@ -280,10 +280,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert ((*iter)->mCell->isExterior()); + assert ((*iter)->getCell()->isExterior()); - if (x==(*iter)->mCell->getGridX() && - y==(*iter)->mCell->getGridY()) + if (x==(*iter)->getCell()->getGridX() && + y==(*iter)->getCell()->getGridY()) break; ++iter; @@ -302,10 +302,10 @@ namespace MWWorld while (iter!=mActiveCells.end()) { - assert ((*iter)->mCell->isExterior()); + assert ((*iter)->getCell()->isExterior()); - if (X==(*iter)->mCell->getGridX() && - Y==(*iter)->mCell->getGridY()) + if (X==(*iter)->getCell()->getGridX() && + Y==(*iter)->getCell()->getGridY()) break; ++iter; @@ -407,7 +407,7 @@ namespace MWWorld loadingListener->setProgressRange(refsToLoad); // Load cell. - std::cout << "cellName: " << cell->mCell->mName << std::endl; + std::cout << "cellName: " << cell->getCell()->mName << std::endl; //Loading Interior loading text diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index b00ad15ca..c79d7ee4f 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -664,7 +664,7 @@ void WeatherManager::changeWeather(const std::string& region, const unsigned int mRegionOverrides[Misc::StringUtils::lowerCase(region)] = weather; - std::string playerRegion = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->mCell->mRegion; + std::string playerRegion = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell()->mRegion; if (Misc::StringUtils::ciEqual(region, playerRegion)) setWeather(weather); } @@ -695,7 +695,7 @@ void WeatherManager::switchToNextWeather(bool instantly) MWBase::World* world = MWBase::Environment::get().getWorld(); if (world->isCellExterior() || world->isCellQuasiExterior()) { - std::string regionstr = Misc::StringUtils::lowerCase(world->getPlayerPtr().getCell()->mCell->mRegion); + std::string regionstr = Misc::StringUtils::lowerCase(world->getPlayerPtr().getCell()->getCell()->mRegion); if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion) { diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index be6c0b338..4c97c594d 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -506,10 +506,10 @@ namespace MWWorld if (!cell) cell = mWorldScene->getCurrentCell(); - if (!cell->mCell->isExterior() || !cell->mCell->mName.empty()) - return cell->mCell->mName; + if (!cell->getCell()->isExterior() || !cell->getCell()->mName.empty()) + return cell->getCell()->mName; - if (const ESM::Region* region = getStore().get().search (cell->mCell->mRegion)) + if (const ESM::Region* region = getStore().get().search (cell->getCell()->mRegion)) return region->mName; return getStore().get().find ("sDefaultCellname")->mValue.getString(); @@ -946,11 +946,11 @@ namespace MWWorld if (isPlayer) { if (!newCell.isExterior()) - changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.mCell->mName), pos); + changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.getCell()->mName), pos); else { - int cellX = newCell.mCell->getGridX(); - int cellY = newCell.mCell->getGridY(); + int cellX = newCell.getCell()->getGridX(); + int cellY = newCell.getCell()->getGridY(); mWorldScene->changeCell(cellX, cellY, pos, false); } addContainerScripts (getPlayerPtr(), &newCell); @@ -1465,7 +1465,7 @@ namespace MWWorld CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - return currentCell->mCell->isExterior(); + return currentCell->getCell()->isExterior(); } return false; } @@ -1475,7 +1475,7 @@ namespace MWWorld CellStore *currentCell = mWorldScene->getCurrentCell(); if (currentCell) { - if (!(currentCell->mCell->mData.mFlags & ESM::Cell::QuasiEx)) + if (!(currentCell->getCell()->mData.mFlags & ESM::Cell::QuasiEx)) return false; else return true; @@ -1757,7 +1757,7 @@ namespace MWWorld bool World::isUnderwater(const MWWorld::CellStore* cell, const Ogre::Vector3 &pos) const { - if (!(cell->mCell->mData.mFlags & ESM::Cell::HasWater)) { + if (!(cell->getCell()->mData.mFlags & ESM::Cell::HasWater)) { return false; } return pos.z < cell->mWaterLevel; @@ -1816,7 +1816,7 @@ namespace MWWorld const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle()); if((!physactor->getOnGround()&&physactor->getCollisionMode()) || isUnderwater(currentCell, playerPos)) return 2; - if((currentCell->mCell->mData.mFlags&ESM::Cell::NoSleep) || + if((currentCell->getCell()->mData.mFlags&ESM::Cell::NoSleep) || Class::get(player).getNpcStats(player).isWerewolf()) return 1;