Merge branch 'cellstore'

actorid
Marc Zinnschlag 11 years ago
commit c62a352956

@ -57,7 +57,7 @@ add_openmw_dir (mwworld
cells localscripts customdata weather inventorystore ptr actionopen actionread
actionequip timestamp actionalchemy cellstore actionapply actioneat
esmstore store recordcmp fallback actionrepair actionsoulgem livecellref actiondoor
contentloader esmloader omwloader actiontrap
contentloader esmloader omwloader actiontrap cellreflist
)
add_openmw_dir (mwclass

@ -39,6 +39,12 @@ namespace ESM
struct Spell;
struct NPC;
struct CellId;
struct Armor;
struct Weapon;
struct Clothing;
struct Enchantment;
struct Book;
struct EffectList;
}
namespace MWRender

@ -128,6 +128,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Activator> *ref =
ptr.get<ESM::Activator>();
return MWWorld::Ptr(&cell.mActivators.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Activator>().insert(*ref), &cell);
}
}

@ -148,7 +148,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>();
return MWWorld::Ptr(&cell.mAppas.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Apparatus>().insert(*ref), &cell);
}
bool Apparatus::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -363,7 +363,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>();
return MWWorld::Ptr(&cell.mArmors.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Armor>().insert(*ref), &cell);
}
int Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -186,7 +186,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>();
return MWWorld::Ptr(&cell.mBooks.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Book>().insert(*ref), &cell);
}
int Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -276,7 +276,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>();
return MWWorld::Ptr(&cell.mClothes.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Clothing>().insert(*ref), &cell);
}
int Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -257,7 +257,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>();
return MWWorld::Ptr(&cell.mContainers.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Container>().insert(*ref), &cell);
}
void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)

@ -22,6 +22,7 @@
#include "../mwworld/customdata.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/renderinginterface.hpp"
#include "../mwrender/actors.hpp"
@ -679,7 +680,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>();
return MWWorld::Ptr(&cell.mCreatures.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Creature>().insert(*ref), &cell);
}
bool Creature::isFlying(const MWWorld::Ptr &ptr) const

@ -3,6 +3,11 @@
#include "../mwworld/class.hpp"
namespace ESM
{
struct GameSetting;
}
namespace MWClass
{
class Creature : public MWWorld::Class

@ -258,6 +258,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Door> *ref =
ptr.get<ESM::Door>();
return MWWorld::Ptr(&cell.mDoors.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Door>().insert(*ref), &cell);
}
}

@ -1,6 +1,8 @@
#ifndef GAME_MWCLASS_DOOR_H
#define GAME_MWCLASS_DOOR_H
#include <components/esm/loaddoor.hpp>
#include "../mwworld/class.hpp"
namespace MWClass

@ -189,7 +189,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>();
return MWWorld::Ptr(&cell.mIngreds.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Ingredient>().insert(*ref), &cell);
}
bool Ingredient::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -227,7 +227,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>();
return MWWorld::Ptr(&cell.mLights.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Light>().insert(*ref), &cell);
}
void Light::ensureCustomData (const MWWorld::Ptr& ptr) const

@ -169,7 +169,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>();
return MWWorld::Ptr(&cell.mLockpicks.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Lockpick>().insert(*ref), &cell);
}
bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -218,13 +218,13 @@ namespace MWClass
MWWorld::ManualRef newRef(store, base);
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
newRef.getPtr().get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
newPtr = MWWorld::Ptr(&cell.get<ESM::Miscellaneous>().insert(*ref), &cell);
newPtr.getCellRef().mGoldValue = goldAmount;
newPtr.getRefData().setCount(1);
} else {
MWWorld::LiveCellRef<ESM::Miscellaneous> *ref =
ptr.get<ESM::Miscellaneous>();
newPtr = MWWorld::Ptr(&cell.mMiscItems.insert(*ref), &cell);
newPtr = MWWorld::Ptr(&cell.get<ESM::Miscellaneous>().insert(*ref), &cell);
}
return newPtr;
}

@ -30,6 +30,7 @@
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/customdata.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/actors.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -1252,7 +1253,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>();
return MWWorld::Ptr(&cell.mNpcs.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::NPC>().insert(*ref), &cell);
}
int Npc::getSkill(const MWWorld::Ptr& ptr, int skill) const

@ -185,7 +185,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>();
return MWWorld::Ptr(&cell.mPotions.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Potion>().insert(*ref), &cell);
}
bool Potion::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -168,7 +168,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>();
return MWWorld::Ptr(&cell.mProbes.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Probe>().insert(*ref), &cell);
}
bool Probe::canSell (const MWWorld::Ptr& item, int npcServices) const

@ -163,7 +163,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>();
return MWWorld::Ptr(&cell.mRepairs.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Repair>().insert(*ref), &cell);
}
boost::shared_ptr<MWWorld::Action> Repair::use (const MWWorld::Ptr& ptr) const

@ -5,6 +5,7 @@
#include "../mwworld/ptr.hpp"
#include "../mwworld/physicssystem.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/objects.hpp"
#include "../mwrender/renderinginterface.hpp"
@ -57,6 +58,6 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Static> *ref =
ptr.get<ESM::Static>();
return MWWorld::Ptr(&cell.mStatics.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Static>().insert(*ref), &cell);
}
}

@ -426,7 +426,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>();
return MWWorld::Ptr(&cell.mWeapons.insert(*ref), &cell);
return MWWorld::Ptr(&cell.get<ESM::Weapon>().insert(*ref), &cell);
}
int Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

@ -13,6 +13,11 @@
#include "../mwscript/compilercontext.hpp"
namespace ESM
{
struct Dialogue;
}
namespace MWDialogue
{
class DialogueManager : public MWBase::DialogueManager

@ -8,8 +8,9 @@
#include "../mwbase/dialoguemanager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/creaturestats.hpp"
@ -110,7 +111,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 +446,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:
{

@ -2,6 +2,8 @@
#include <boost/lexical_cast.hpp>
#include <components/esm/loadbook.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"

@ -1,6 +1,9 @@
#ifndef CHARACTER_CREATION_HPP
#define CHARACTER_CREATION_HPP
#include <components/esm/loadskil.hpp>
#include <components/esm/loadclas.hpp>
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"

@ -8,6 +8,8 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWGui
{
class ConsoleInterpreterContext : public MWScript::InterpreterContext

@ -8,6 +8,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/fallback.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"

@ -7,7 +7,9 @@
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/globalmap.hpp"
@ -356,7 +358,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);

@ -1,5 +1,7 @@
#include "merchantrepair.hpp"
#include <components/esm/loadgmst.hpp>
#include <boost/lexical_cast.hpp>
#include "../mwbase/world.hpp"
@ -10,6 +12,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWGui
{

@ -1,5 +1,7 @@
#include "scrollwindow.hpp"
#include <components/esm/loadbook.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/soundmanager.hpp"

@ -1,5 +1,18 @@
#include "sortfilteritemmodel.hpp"
#include <components/esm/loadalch.hpp>
#include <components/esm/loadappa.hpp>
#include <components/esm/loadarmo.hpp>
#include <components/esm/loadbook.hpp>
#include <components/esm/loadclot.hpp>
#include <components/esm/loadingr.hpp>
#include <components/esm/loadlock.hpp>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadmisc.hpp>
#include <components/esm/loadprob.hpp>
#include <components/esm/loadrepa.hpp>
#include <components/esm/loadweap.hpp>
#include "../mwworld/class.hpp"
namespace

@ -10,6 +10,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp"

@ -1,5 +1,7 @@
#include "tradeitemmodel.hpp"
#include <components/misc/stringops.hpp>
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp"

@ -13,6 +13,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
namespace MWGui
{
@ -109,7 +111,11 @@ namespace MWGui
int x,y;
MWBase::Environment::get().getWorld()->positionToIndex(mPtr.get<ESM::NPC>()->mBase->mTransport[i].mPos.pos[0],
mPtr.get<ESM::NPC>()->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<ESM::NPC>()->mBase->mTransport[i].mPos,interior);
}

@ -10,6 +10,7 @@
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -129,7 +130,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<ESM::Region>().find (regionstr);

@ -18,6 +18,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "console.hpp"
#include "journalwindow.hpp"
@ -739,22 +740,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))

@ -15,13 +15,16 @@
#include "../engine.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/statemanager.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
using namespace ICS;

@ -1,8 +1,14 @@
#include "activespells.hpp"
#include <components/misc/stringops.hpp>
#include <components/esm/loadmgef.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/esmstore.hpp"
namespace MWMechanics
{
void ActiveSpells::update() const

@ -1,14 +1,14 @@
#include "aiactivate.hpp"
#include <iostream>
#include "movement.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/action.hpp"
#include "../mwworld/cellstore.hpp"
#include "steering.hpp"
#include "movement.hpp"
namespace
{
@ -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))

@ -7,6 +7,8 @@
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
@ -305,7 +307,7 @@ 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

@ -1,14 +1,15 @@
#include "aiescort.hpp"
#include "movement.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "steering.hpp"
#include "movement.hpp"
namespace
{
@ -86,24 +87,24 @@ 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 /
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 /
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;
@ -114,8 +115,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;

@ -1,12 +1,14 @@
#include "aifollow.hpp"
#include <iostream>
#include <OgreMath.h>
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "movement.hpp"
#include <OgreMath.h>
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "movement.hpp"
#include "steering.hpp"
MWMechanics::AiFollow::AiFollow(const std::string &actorId,float duration, float x, float y, float z)
@ -42,7 +44,7 @@ bool MWMechanics::AiFollow::execute (const MWWorld::Ptr& actor,float duration)
}
else
{
if(mCellId == actor.getCell()->mCell->mName)
if(mCellId == actor.getCell()->getCell()->mName)
return true;
}
}

@ -2,7 +2,9 @@
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "steering.hpp"
#include "movement.hpp"
@ -36,12 +38,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 +52,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))

@ -1,17 +1,19 @@
#include "aiwander.hpp"
#include "movement.hpp"
#include <OgreVector3.h>
#include "../mwworld/class.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/dialoguemanager.hpp"
#include "creaturestats.hpp"
#include <OgreVector3.h>
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "creaturestats.hpp"
#include "steering.hpp"
#include "movement.hpp"
namespace
{
@ -103,10 +105,10 @@ namespace MWMechanics
if(!mStoredAvailableNodes)
{
mStoredAvailableNodes = true;
mPathgrid = world->getStore().get<ESM::Pathgrid>().search(*actor.getCell()->mCell);
mPathgrid = world->getStore().get<ESM::Pathgrid>().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 +119,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 +159,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)

@ -8,6 +8,11 @@
#include "../mwworld/ptr.hpp"
namespace ESM
{
struct Potion;
}
namespace MWMechanics
{
struct EffectKey;

@ -36,6 +36,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
namespace
{

@ -10,6 +10,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/windowmanager.hpp"

@ -6,6 +6,7 @@
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/spells.hpp"
#include "../mwmechanics/creaturestats.hpp"

@ -1,13 +1,15 @@
#include "pathfinding.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include <map>
#include "OgreMath.h"
#include "OgreVector3.h"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include <map>
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
namespace
{
@ -299,14 +301,14 @@ namespace MWMechanics
if(!allowShortcuts)
{
const ESM::Pathgrid *pathGrid =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*mCell->mCell);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().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);

@ -1,8 +1,11 @@
#include "pickpocket.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include "npcstats.hpp"
namespace MWMechanics

@ -10,6 +10,7 @@
#include "../mwworld/containerstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"

@ -2,6 +2,7 @@
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"

@ -14,6 +14,7 @@
#include "../mwworld/actionteleport.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/animation.hpp"
@ -503,7 +504,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);
}

@ -5,6 +5,16 @@
#include <OgreVector3.h>
#include <components/esm/loadskil.hpp>
namespace ESM
{
struct Spell;
struct Ingredient;
struct Potion;
struct EffectList;
}
namespace MWMechanics
{
class EffectKey;

@ -4,6 +4,8 @@
#include <map>
#include <string>
#include <components/misc/stringops.hpp>
#include "../mwworld/ptr.hpp"
#include "magiceffects.hpp"

@ -1,9 +1,11 @@
#include "activatoranimation.hpp"
#include "renderconst.hpp"
#include <components/esm/loadacti.hpp>
#include "../mwbase/world.hpp"
#include "renderconst.hpp"
namespace MWRender
{

@ -11,18 +11,26 @@
#include <OgreControllerManager.h>
#include <OgreStaticGeometry.h>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadweap.hpp>
#include <components/esm/loadench.hpp>
#include <components/esm/loadstat.hpp>
#include <libs/openengine/ogre/lights.hpp>
#include <extern/shiny/Main/Factory.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/world.hpp"
#include <extern/shiny/Main/Factory.hpp>
#include "../mwmechanics/character.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/fallback.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "renderconst.hpp"
@ -334,7 +342,7 @@ void Animation::addExtraLight(Ogre::SceneManager *sceneMgr, NifOgre::ObjectScene
));
objlist->mControllers.push_back(Ogre::Controller<Ogre::Real>(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");

@ -8,6 +8,10 @@
#include "../mwworld/ptr.hpp"
namespace ESM
{
struct Light;
}
namespace MWRender
{

@ -4,12 +4,14 @@
#include <OgreSkeletonInstance.h>
#include <OgreBone.h>
#include "renderconst.hpp"
#include <components/esm/loadcrea.hpp>
#include "../mwbase/world.hpp"
#include "../mwworld/class.hpp"
#include "renderconst.hpp"
namespace MWRender
{

@ -13,12 +13,12 @@
#include <components/esm/loadstat.hpp>
#include <components/esm/loadpgrd.hpp>
#include "../mwworld/esmstore.hpp"
#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "renderconst.hpp"
@ -230,22 +230,22 @@ void Debugging::togglePathgrid()
void Debugging::enableCellPathgrid(MWWorld::CellStore *store)
{
const ESM::Pathgrid *pathgrid =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().search(*store->mCell);
MWBase::Environment::get().getWorld()->getStore().get<ESM::Pathgrid>().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);

@ -7,12 +7,13 @@
#include <OgreCamera.h>
#include <OgreTextureManager.h>
#include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "renderconst.hpp"
#include "renderingmanager.hpp"
@ -115,8 +116,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 +183,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; x<segsX; ++x)
{
@ -192,7 +193,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
Vector2 newcenter = start + 4096;
render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, sSize, sSize,
cell->mCell->mName + "_" + coordStr(x,y));
cell->getCell()->mName + "_" + coordStr(x,y));
}
}
}

@ -11,11 +11,15 @@
#include <OgreParticleEmitter.h>
#include <OgreStaticGeometry.h>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadstat.hpp>
#include <components/nifogre/ogrenifloader.hpp>
#include <components/settings/settings.hpp>
#include "../mwworld/ptr.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "renderconst.hpp"
#include "animation.hpp"

@ -24,6 +24,7 @@
#include "../mwworld/esmstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwbase/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwbase/environment.hpp"
@ -422,9 +423,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 +502,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 +554,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 +565,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 +651,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())

@ -13,6 +13,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "interpretercontext.hpp"
@ -88,7 +89,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 +104,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,8 +132,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime)
{
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell();
if (cell->mCell->hasWater())
runtime.push (cell->mWaterLevel);
if (cell->getCell()->hasWater())
runtime.push (cell->getWaterLevel());
else
runtime.push (-std::numeric_limits<float>().max());
}
@ -148,11 +149,11 @@ 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;
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel);
cell->setWaterLevel (level);
MWBase::Environment::get().getWorld()->setWaterHeight (cell->getWaterLevel());
}
};
@ -166,11 +167,11 @@ 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;
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel);
cell->setWaterLevel (cell->getWaterLevel()+level);
MWBase::Environment::get().getWorld()->setWaterHeight(cell->getWaterLevel());
}
};

@ -14,6 +14,8 @@
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
#include <components/esm/loadskil.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"

@ -13,12 +13,16 @@
#include <components/interpreter/runtime.hpp>
#include <components/interpreter/opcodes.hpp>
#include <components/esm/loadmgef.hpp>
#include <components/esm/loadcrea.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/scriptmanager.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/creaturestats.hpp"

@ -9,6 +9,7 @@
#include "../mwbase/statemanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "sound_output.hpp"
#include "sound_decoder.hpp"
@ -480,7 +481,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 +549,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)

@ -23,6 +23,7 @@
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/npcstats.hpp"
@ -301,7 +302,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());
}

@ -3,6 +3,8 @@
#include <cstdlib>
#include <components/esm/loadskil.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"

@ -0,0 +1,54 @@
#ifndef GAME_MWWORLD_CELLREFLIST_H
#define GAME_MWWORLD_CELLREFLIST_H
#include <list>
#include "livecellref.hpp"
namespace MWWorld
{
/// \brief Collection of references of one type
template <typename X>
struct CellRefList
{
typedef LiveCellRef<X> LiveRef;
typedef std::list<LiveRef> List;
List mList;
/// Search for the given reference in the given reclist from
/// ESMStore. Insert the reference into the list if a match is
/// found. If not, throw an exception.
/// Moved to cpp file, as we require a custom compare operator for it,
/// and the build will fail with an ugly three-way cyclic header dependence
/// so we need to pass the instantiation of the method to the linker, when
/// all methods are known.
void load (ESM::CellRef &ref, bool deleted, const MWWorld::ESMStore &esmStore);
LiveRef *find (const std::string& name)
{
for (typename List::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
if (iter->mData.getCount() > 0 && iter->mRef.mRefID == name)
return &*iter;
return 0;
}
LiveRef &insert (const LiveRef &item)
{
mList.push_back(item);
return mList.back();
}
LiveCellRef<X> *searchViaHandle (const std::string& handle)
{
for (typename List::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
if (iter->mData.getCount()>0 && iter->mData.getBaseNode() &&
iter->mData.getHandle()==handle)
return &*iter;
return 0;
}
};
}
#endif

@ -11,6 +11,7 @@
#include "class.hpp"
#include "esmstore.hpp"
#include "containerstore.hpp"
#include "cellstore.hpp"
MWWorld::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell)
{
@ -65,8 +66,11 @@ MWWorld::Ptr MWWorld::Cells::getPtrAndCache (const std::string& name, CellStore&
return ptr;
}
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, const CellStore& cell) const
void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, CellStore& cell) const
{
if (cell.getState()!=CellStore::State_Loaded)
cell.load (mStore, mReader);
ESM::CellState cellState;
cell.saveState (cellState);
@ -78,17 +82,6 @@ void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, const CellStore& cell) c
writer.endRecord (ESM::REC_CSTA);
}
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;
else
return false;
}
MWWorld::Cells::Cells (const MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& reader)
: mStore (store), mReader (reader),
mIdCache (40, std::pair<std::string, CellStore *> ("", (CellStore*)0)), /// \todo make cache size configurable
@ -122,7 +115,7 @@ MWWorld::CellStore *MWWorld::Cells::getExterior (int x, int y)
std::make_pair (x, y), CellStore (cell))).first;
}
if (result->second.mState!=CellStore::State_Loaded)
if (result->second.getState()!=CellStore::State_Loaded)
{
// Multiple plugin support for landscape data is much easier than for references. The last plugin wins.
result->second.load (mStore, mReader);
@ -143,7 +136,7 @@ MWWorld::CellStore *MWWorld::Cells::getInterior (const std::string& name)
result = mInteriors.insert (std::make_pair (lowerName, CellStore (cell))).first;
}
if (result->second.mState!=CellStore::State_Loaded)
if (result->second.getState()!=CellStore::State_Loaded)
{
result->second.load (mStore, mReader);
}
@ -162,12 +155,12 @@ MWWorld::CellStore *MWWorld::Cells::getCell (const ESM::CellId& id)
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
bool searchInContainers)
{
if (cell.mState==CellStore::State_Unloaded)
if (cell.getState()==CellStore::State_Unloaded)
cell.preload (mStore, mReader);
if (cell.mState==CellStore::State_Preloaded)
if (cell.getState()==CellStore::State_Preloaded)
{
if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), name))
if (cell.hasId (name))
{
cell.load (mStore, mReader);
}
@ -175,65 +168,10 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
return Ptr();
}
if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.mActivators.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.mPotions.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.mAppas.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.mArmors.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.mBooks.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.mClothes.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.mContainers.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.mCreatures.find (name))
return Ptr (ref, &cell);
Ptr ptr = cell.search (name);
if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.mDoors.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.mIngreds.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.mCreatureLists.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.mItemLists.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.mLights.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Lockpick> *ref = cell.mLockpicks.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.mMiscItems.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.mNpcs.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.mProbes.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.mRepairs.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.mStatics.find (name))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.mWeapons.find (name))
return Ptr (ref, &cell);
if (!ptr.isEmpty())
return ptr;
if (searchInContainers)
return cell.searchInContainer (name);
@ -328,12 +266,12 @@ int MWWorld::Cells::countSavedGameRecords() const
for (std::map<std::string, CellStore>::const_iterator iter (mInteriors.begin());
iter!=mInteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
++count;
for (std::map<std::pair<int, int>, CellStore>::const_iterator iter (mExteriors.begin());
iter!=mExteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
++count;
return count;
@ -341,14 +279,14 @@ int MWWorld::Cells::countSavedGameRecords() const
void MWWorld::Cells::write (ESM::ESMWriter& writer) const
{
for (std::map<std::pair<int, int>, CellStore>::const_iterator iter (mExteriors.begin());
for (std::map<std::pair<int, int>, CellStore>::iterator iter (mExteriors.begin());
iter!=mExteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
writeCell (writer, iter->second);
for (std::map<std::string, CellStore>::const_iterator iter (mInteriors.begin());
for (std::map<std::string, CellStore>::iterator iter (mInteriors.begin());
iter!=mInteriors.end(); ++iter)
if (hasState (iter->second))
if (iter->second.hasState())
writeCell (writer, iter->second);
}
@ -375,7 +313,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, int32_t type,
state.load (reader);
cellStore->loadState (state);
if (cellStore->mState!=CellStore::State_Loaded)
if (cellStore->getState()!=CellStore::State_Loaded)
cellStore->load (mStore, mReader);
cellStore->readReferences (reader, contentFileMap);

@ -12,6 +12,7 @@ namespace ESM
class ESMReader;
class ESMWriter;
struct CellId;
struct Cell;
}
namespace MWWorld
@ -23,8 +24,8 @@ namespace MWWorld
{
const MWWorld::ESMStore& mStore;
std::vector<ESM::ESMReader>& mReader;
std::map<std::string, CellStore> mInteriors;
std::map<std::pair<int, int>, CellStore> mExteriors;
mutable std::map<std::string, CellStore> mInteriors;
mutable std::map<std::pair<int, int>, CellStore> mExteriors;
std::vector<std::pair<std::string, CellStore *> > mIdCache;
std::size_t mIdCacheIndex;
@ -35,10 +36,7 @@ namespace MWWorld
Ptr getPtrAndCache (const std::string& name, CellStore& cellStore);
void writeCell (ESM::ESMWriter& writer, const CellStore& cell) const;
bool hasState (const CellStore& cellStore) const;
///< Check if cell has state that needs to be included in a saved game file.
void writeCell (ESM::ESMWriter& writer, CellStore& cell) const;
public:

@ -1,6 +1,7 @@
#include "cellstore.hpp"
#include <iostream>
#include <algorithm>
#include <components/esm/cellstate.hpp>
#include <components/esm/cellid.hpp>
@ -140,11 +141,216 @@ namespace MWWorld
}
CellStore::CellStore (const ESM::Cell *cell)
: mCell (cell), mState (State_Unloaded)
: mCell (cell), mState (State_Unloaded), mHasState (false)
{
mWaterLevel = cell->mWater;
}
const ESM::Cell *CellStore::getCell() const
{
return mCell;
}
CellStore::State CellStore::getState() const
{
return mState;
}
bool CellStore::hasState() const
{
return mHasState;
}
bool CellStore::hasId (const std::string& id) const
{
if (mState==State_Unloaded)
return false;
if (mState==State_Preloaded)
return std::binary_search (mIds.begin(), mIds.end(), id);
/// \todo address const-issues
return const_cast<CellStore *> (this)->search (id).isEmpty();
}
Ptr CellStore::search (const std::string& id)
{
bool oldState = mHasState;
mHasState = true;
if (LiveCellRef<ESM::Activator> *ref = mActivators.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Potion> *ref = mPotions.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Apparatus> *ref = mAppas.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Armor> *ref = mArmors.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Book> *ref = mBooks.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Clothing> *ref = mClothes.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Container> *ref = mContainers.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Creature> *ref = mCreatures.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Door> *ref = mDoors.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Ingredient> *ref = mIngreds.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::CreatureLevList> *ref = mCreatureLists.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::ItemLevList> *ref = mItemLists.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Light> *ref = mLights.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Lockpick> *ref = mLockpicks.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Miscellaneous> *ref = mMiscItems.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::NPC> *ref = mNpcs.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Probe> *ref = mProbes.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Repair> *ref = mRepairs.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Static> *ref = mStatics.find (id))
return Ptr (ref, this);
if (LiveCellRef<ESM::Weapon> *ref = mWeapons.find (id))
return Ptr (ref, this);
mHasState = oldState;
return Ptr();
}
Ptr CellStore::searchViaHandle (const std::string& handle)
{
bool oldState = mHasState;
mHasState = true;
if (LiveCellRef<ESM::Activator> *ref = mActivators.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Potion> *ref = mPotions.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Apparatus> *ref = mAppas.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Armor> *ref = mArmors.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Book> *ref = mBooks.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Clothing> *ref = mClothes.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Container> *ref = mContainers.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Creature> *ref = mCreatures.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Door> *ref = mDoors.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Ingredient> *ref = mIngreds.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::CreatureLevList> *ref = mCreatureLists.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::ItemLevList> *ref = mItemLists.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Light> *ref = mLights.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Lockpick> *ref = mLockpicks.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Miscellaneous> *ref = mMiscItems.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::NPC> *ref = mNpcs.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Probe> *ref = mProbes.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Repair> *ref = mRepairs.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Static> *ref = mStatics.searchViaHandle (handle))
return Ptr (ref, this);
if (LiveCellRef<ESM::Weapon> *ref = mWeapons.searchViaHandle (handle))
return Ptr (ref, this);
mHasState = oldState;
return Ptr();
}
float CellStore::getWaterLevel() const
{
return mWaterLevel;
}
void CellStore::setWaterLevel (float level)
{
mWaterLevel = level;
mHasState = true;
}
int CellStore::count() const
{
return
mActivators.mList.size()
+ mPotions.mList.size()
+ mAppas.mList.size()
+ mArmors.mList.size()
+ mBooks.mList.size()
+ mClothes.mList.size()
+ mContainers.mList.size()
+ mDoors.mList.size()
+ mIngreds.mList.size()
+ mCreatureLists.mList.size()
+ mItemLists.mList.size()
+ mLights.mList.size()
+ mLockpicks.mList.size()
+ mMiscItems.mList.size()
+ mProbes.mList.size()
+ mRepairs.mList.size()
+ mStatics.mList.size()
+ mWeapons.mList.size()
+ mCreatures.mList.size()
+ mNpcs.mList.size();
}
void CellStore::load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
{
if (mState!=State_Loaded)
@ -242,28 +448,27 @@ namespace MWWorld
}
}
bool CellStore::isExterior() const
{
return mCell->isExterior();
}
Ptr CellStore::searchInContainer (const std::string& id)
{
{
Ptr ptr = searchInContainerList (mContainers, id);
bool oldState = mHasState;
if (!ptr.isEmpty())
return ptr;
}
mHasState = true;
{
Ptr ptr = searchInContainerList (mCreatures, id);
if (Ptr ptr = searchInContainerList (mContainers, id))
return ptr;
if (!ptr.isEmpty())
return ptr;
}
if (Ptr ptr = searchInContainerList (mCreatures, id))
return ptr;
{
Ptr ptr = searchInContainerList (mNpcs, id);
if (Ptr ptr = searchInContainerList (mNpcs, id))
return ptr;
if (!ptr.isEmpty())
return ptr;
}
mHasState = oldState;
return Ptr();
}
@ -305,6 +510,8 @@ namespace MWWorld
void CellStore::loadState (const ESM::CellState& state)
{
mHasState = true;
if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
mWaterLevel = state.mWaterLevel;
@ -348,6 +555,8 @@ namespace MWWorld
void CellStore::readReferences (ESM::ESMReader& reader,
const std::map<int, int>& contentFileMap)
{
mHasState = true;
while (reader.isNextSub ("OBJE"))
{
unsigned int id = 0;
@ -461,4 +670,14 @@ namespace MWWorld
}
}
}
bool operator== (const CellStore& left, const CellStore& right)
{
return left.getCell()->getCellId()==right.getCell()->getCellId();
}
bool operator!= (const CellStore& left, const CellStore& right)
{
return !(left==right);
}
}

@ -1,11 +1,12 @@
#ifndef GAME_MWWORLD_CELLSTORE_H
#define GAME_MWWORLD_CELLSTORE_H
#include <deque>
#include <algorithm>
#include <stdexcept>
#include "livecellref.hpp"
#include "esmstore.hpp"
#include "cellreflist.hpp"
namespace ESM
{
@ -14,164 +15,301 @@ namespace ESM
namespace MWWorld
{
class Ptr;
/// A list of cell references
template <typename X>
struct CellRefList
{
typedef LiveCellRef<X> LiveRef;
typedef std::list<LiveRef> List;
List mList;
/// \brief Mutable state of a cell
class CellStore
{
public:
enum State
{
State_Unloaded, State_Preloaded, State_Loaded
};
private:
const ESM::Cell *mCell;
State mState;
bool mHasState;
std::vector<std::string> mIds;
float mWaterLevel;
CellRefList<ESM::Activator> mActivators;
CellRefList<ESM::Potion> mPotions;
CellRefList<ESM::Apparatus> mAppas;
CellRefList<ESM::Armor> mArmors;
CellRefList<ESM::Book> mBooks;
CellRefList<ESM::Clothing> mClothes;
CellRefList<ESM::Container> mContainers;
CellRefList<ESM::Creature> mCreatures;
CellRefList<ESM::Door> mDoors;
CellRefList<ESM::Ingredient> mIngreds;
CellRefList<ESM::CreatureLevList> mCreatureLists;
CellRefList<ESM::ItemLevList> mItemLists;
CellRefList<ESM::Light> mLights;
CellRefList<ESM::Lockpick> mLockpicks;
CellRefList<ESM::Miscellaneous> mMiscItems;
CellRefList<ESM::NPC> mNpcs;
CellRefList<ESM::Probe> mProbes;
CellRefList<ESM::Repair> mRepairs;
CellRefList<ESM::Static> mStatics;
CellRefList<ESM::Weapon> mWeapons;
public:
CellStore (const ESM::Cell *cell_);
const ESM::Cell *getCell() const;
State getState() const;
bool hasState() const;
///< Does this cell have state that needs to be stored in a saved game file?
bool hasId (const std::string& id) const;
///< May return true for deleted IDs when in preload state. Will return false, if cell is
/// unloaded.
Ptr search (const std::string& id);
///< Will return an empty Ptr if cell is not loaded. Does not check references in
/// containers.
Ptr searchViaHandle (const std::string& handle);
///< Will return an empty Ptr if cell is not loaded.
float getWaterLevel() const;
void setWaterLevel (float level);
int count() const;
///< Return total number of references, including deleted ones.
void load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
///< Load references from content file.
void preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
///< Build ID list from content file.
/// Call functor (ref) for each reference. functor must return a bool. Returning
/// false will abort the iteration.
/// \return Iteration completed?
///
/// \note Creatures and NPCs are handled last.
template<class Functor>
bool forEach (Functor& functor)
{
mHasState = true;
return
forEachImp (functor, mActivators) &&
forEachImp (functor, mPotions) &&
forEachImp (functor, mAppas) &&
forEachImp (functor, mArmors) &&
forEachImp (functor, mBooks) &&
forEachImp (functor, mClothes) &&
forEachImp (functor, mContainers) &&
forEachImp (functor, mDoors) &&
forEachImp (functor, mIngreds) &&
forEachImp (functor, mItemLists) &&
forEachImp (functor, mLights) &&
forEachImp (functor, mLockpicks) &&
forEachImp (functor, mMiscItems) &&
forEachImp (functor, mProbes) &&
forEachImp (functor, mRepairs) &&
forEachImp (functor, mStatics) &&
forEachImp (functor, mWeapons) &&
forEachImp (functor, mCreatures) &&
forEachImp (functor, mNpcs) &&
forEachImp (functor, mCreatureLists);
}
bool isExterior() const;
Ptr searchInContainer (const std::string& id);
void loadState (const ESM::CellState& state);
void saveState (ESM::CellState& state) const;
void writeReferences (ESM::ESMWriter& writer) const;
void readReferences (ESM::ESMReader& reader, const std::map<int, int>& contentFileMap);
template <class T>
CellRefList<T>& get() {
throw std::runtime_error ("Storage for this type not exist in cells");
}
private:
template<class Functor, class List>
bool forEachImp (Functor& functor, List& list)
{
for (typename List::List::iterator iter (list.mList.begin()); iter!=list.mList.end();
++iter)
{
if (!iter->mData.getCount())
continue;
if (!functor (MWWorld::Ptr(&*iter, this)))
return false;
}
return true;
}
/// Run through references and store IDs
void listRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRef (ESM::CellRef& ref, bool deleted, const ESMStore& store);
///< Make case-adjustments to \a ref and insert it into the respective container.
///
/// Invalid \a ref objects are silently dropped.
};
// Search for the given reference in the given reclist from
// ESMStore. Insert the reference into the list if a match is
// found. If not, throw an exception.
// Moved to cpp file, as we require a custom compare operator for it,
// and the build will fail with an ugly three-way cyclic header dependence
// so we need to pass the instantiation of the method to the lnker, when
// all methods are known.
void load(ESM::CellRef &ref, bool deleted, const MWWorld::ESMStore &esmStore);
template<>
inline CellRefList<ESM::Activator>& CellStore::get<ESM::Activator>()
{
mHasState = true;
return mActivators;
}
LiveRef *find (const std::string& name)
template<>
inline CellRefList<ESM::Potion>& CellStore::get<ESM::Potion>()
{
for (typename std::list<LiveRef>::iterator iter (mList.begin()); iter!=mList.end(); ++iter)
{
if (iter->mData.getCount() > 0 && iter->mRef.mRefID == name)
return &*iter;
}
mHasState = true;
return mPotions;
}
return 0;
template<>
inline CellRefList<ESM::Apparatus>& CellStore::get<ESM::Apparatus>()
{
mHasState = true;
return mAppas;
}
LiveRef &insert(const LiveRef &item) {
mList.push_back(item);
return mList.back();
template<>
inline CellRefList<ESM::Armor>& CellStore::get<ESM::Armor>()
{
mHasState = true;
return mArmors;
}
};
/// A storage struct for one single cell reference.
class CellStore
{
public:
template<>
inline CellRefList<ESM::Book>& CellStore::get<ESM::Book>()
{
mHasState = true;
return mBooks;
}
enum State
template<>
inline CellRefList<ESM::Clothing>& CellStore::get<ESM::Clothing>()
{
State_Unloaded, State_Preloaded, State_Loaded
};
mHasState = true;
return mClothes;
}
template<>
inline CellRefList<ESM::Container>& CellStore::get<ESM::Container>()
{
mHasState = true;
return mContainers;
}
CellStore (const ESM::Cell *cell_);
const ESM::Cell *mCell;
State mState;
std::vector<std::string> mIds;
template<>
inline CellRefList<ESM::Creature>& CellStore::get<ESM::Creature>()
{
mHasState = true;
return mCreatures;
}
float mWaterLevel;
template<>
inline CellRefList<ESM::Door>& CellStore::get<ESM::Door>()
{
mHasState = true;
return mDoors;
}
template<>
inline CellRefList<ESM::Ingredient>& CellStore::get<ESM::Ingredient>()
{
mHasState = true;
return mIngreds;
}
template<>
inline CellRefList<ESM::CreatureLevList>& CellStore::get<ESM::CreatureLevList>()
{
mHasState = true;
return mCreatureLists;
}
template<>
inline CellRefList<ESM::ItemLevList>& CellStore::get<ESM::ItemLevList>()
{
mHasState = true;
return mItemLists;
}
template<>
inline CellRefList<ESM::Light>& CellStore::get<ESM::Light>()
{
mHasState = true;
return mLights;
}
template<>
inline CellRefList<ESM::Lockpick>& CellStore::get<ESM::Lockpick>()
{
mHasState = true;
return mLockpicks;
}
template<>
inline CellRefList<ESM::Miscellaneous>& CellStore::get<ESM::Miscellaneous>()
{
mHasState = true;
return mMiscItems;
}
template<>
inline CellRefList<ESM::NPC>& CellStore::get<ESM::NPC>()
{
mHasState = true;
return mNpcs;
}
template<>
inline CellRefList<ESM::Probe>& CellStore::get<ESM::Probe>()
{
mHasState = true;
return mProbes;
}
template<>
inline CellRefList<ESM::Repair>& CellStore::get<ESM::Repair>()
{
mHasState = true;
return mRepairs;
}
template<>
inline CellRefList<ESM::Static>& CellStore::get<ESM::Static>()
{
mHasState = true;
return mStatics;
}
template<>
inline CellRefList<ESM::Weapon>& CellStore::get<ESM::Weapon>()
{
mHasState = true;
return mWeapons;
}
// Lists for each individual object type
CellRefList<ESM::Activator> mActivators;
CellRefList<ESM::Potion> mPotions;
CellRefList<ESM::Apparatus> mAppas;
CellRefList<ESM::Armor> mArmors;
CellRefList<ESM::Book> mBooks;
CellRefList<ESM::Clothing> mClothes;
CellRefList<ESM::Container> mContainers;
CellRefList<ESM::Creature> mCreatures;
CellRefList<ESM::Door> mDoors;
CellRefList<ESM::Ingredient> mIngreds;
CellRefList<ESM::CreatureLevList> mCreatureLists;
CellRefList<ESM::ItemLevList> mItemLists;
CellRefList<ESM::Light> mLights;
CellRefList<ESM::Lockpick> mLockpicks;
CellRefList<ESM::Miscellaneous> mMiscItems;
CellRefList<ESM::NPC> mNpcs;
CellRefList<ESM::Probe> mProbes;
CellRefList<ESM::Repair> mRepairs;
CellRefList<ESM::Static> mStatics;
CellRefList<ESM::Weapon> mWeapons;
void load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
/// Call functor (ref) for each reference. functor must return a bool. Returning
/// false will abort the iteration.
/// \return Iteration completed?
template<class Functor>
bool forEach (Functor& functor)
{
return
forEachImp (functor, mActivators) &&
forEachImp (functor, mPotions) &&
forEachImp (functor, mAppas) &&
forEachImp (functor, mArmors) &&
forEachImp (functor, mBooks) &&
forEachImp (functor, mClothes) &&
forEachImp (functor, mContainers) &&
forEachImp (functor, mCreatures) &&
forEachImp (functor, mDoors) &&
forEachImp (functor, mIngreds) &&
forEachImp (functor, mCreatureLists) &&
forEachImp (functor, mItemLists) &&
forEachImp (functor, mLights) &&
forEachImp (functor, mLockpicks) &&
forEachImp (functor, mMiscItems) &&
forEachImp (functor, mNpcs) &&
forEachImp (functor, mProbes) &&
forEachImp (functor, mRepairs) &&
forEachImp (functor, mStatics) &&
forEachImp (functor, mWeapons);
}
bool operator==(const CellStore &cell) {
return mCell->mName == cell.mCell->mName &&
mCell->mData.mX == cell.mCell->mData.mX &&
mCell->mData.mY == cell.mCell->mData.mY;
}
bool operator!=(const CellStore &cell) {
return !(*this == cell);
}
bool isExterior() const {
return mCell->isExterior();
}
Ptr searchInContainer (const std::string& id);
void loadState (const ESM::CellState& state);
void saveState (ESM::CellState& state) const;
void writeReferences (ESM::ESMWriter& writer) const;
void readReferences (ESM::ESMReader& reader, const std::map<int, int>& contentFileMap);
private:
template<class Functor, class List>
bool forEachImp (Functor& functor, List& list)
{
for (typename List::List::iterator iter (list.mList.begin()); iter!=list.mList.end();
++iter)
{
if (!iter->mData.getCount())
continue;
if (!functor (MWWorld::Ptr(&*iter, this)))
return false;
}
return true;
}
/// Run through references and store IDs
void listRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRefs(const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
void loadRef (ESM::CellRef& ref, bool deleted, const ESMStore& store);
///< Make case-adjustments to \a ref and insert it into the respective container.
///
/// Invalid \a ref objects are silently dropped.
};
bool operator== (const CellStore& left, const CellStore& right);
bool operator!= (const CellStore& left, const CellStore& right);
}
#endif

@ -3,6 +3,19 @@
#include <iterator>
#include <components/esm/loadalch.hpp>
#include <components/esm/loadappa.hpp>
#include <components/esm/loadarmo.hpp>
#include <components/esm/loadbook.hpp>
#include <components/esm/loadclot.hpp>
#include <components/esm/loadingr.hpp>
#include <components/esm/loadlock.hpp>
#include <components/esm/loadligh.hpp>
#include <components/esm/loadmisc.hpp>
#include <components/esm/loadprob.hpp>
#include <components/esm/loadrepa.hpp>
#include <components/esm/loadweap.hpp>
#include "ptr.hpp"
namespace ESM

@ -5,6 +5,11 @@
#include "../mwmechanics/magiceffects.hpp"
namespace ESM
{
struct MagicEffect;
}
namespace MWMechanics
{
class NpcStats;

@ -101,26 +101,26 @@ void MWWorld::LocalScripts::add (const std::string& scriptName, const Ptr& ptr)
void MWWorld::LocalScripts::addCell (CellStore *cell)
{
listCellScripts (*this, cell->mActivators, cell);
listCellScripts (*this, cell->mPotions, cell);
listCellScripts (*this, cell->mAppas, cell);
listCellScripts (*this, cell->mArmors, cell);
listCellScripts (*this, cell->mBooks, cell);
listCellScripts (*this, cell->mClothes, cell);
listCellScripts (*this, cell->mContainers, cell);
listCellScriptsCont (*this, cell->mContainers, cell);
listCellScripts (*this, cell->mCreatures, cell);
listCellScriptsCont (*this, cell->mCreatures, cell);
listCellScripts (*this, cell->mDoors, cell);
listCellScripts (*this, cell->mIngreds, cell);
listCellScripts (*this, cell->mLights, cell);
listCellScripts (*this, cell->mLockpicks, cell);
listCellScripts (*this, cell->mMiscItems, cell);
listCellScripts (*this, cell->mNpcs, cell);
listCellScriptsCont (*this, cell->mNpcs, cell);
listCellScripts (*this, cell->mProbes, cell);
listCellScripts (*this, cell->mRepairs, cell);
listCellScripts (*this, cell->mWeapons, cell);
listCellScripts (*this, cell->get<ESM::Activator>(), cell);
listCellScripts (*this, cell->get<ESM::Potion>(), cell);
listCellScripts (*this, cell->get<ESM::Apparatus>(), cell);
listCellScripts (*this, cell->get<ESM::Armor>(), cell);
listCellScripts (*this, cell->get<ESM::Book>(), cell);
listCellScripts (*this, cell->get<ESM::Clothing>(), cell);
listCellScripts (*this, cell->get<ESM::Container>(), cell);
listCellScriptsCont (*this, cell->get<ESM::Container>(), cell);
listCellScripts (*this, cell->get<ESM::Creature>(), cell);
listCellScriptsCont (*this, cell->get<ESM::Creature>(), cell);
listCellScripts (*this, cell->get<ESM::Door>(), cell);
listCellScripts (*this, cell->get<ESM::Ingredient>(), cell);
listCellScripts (*this, cell->get<ESM::Light>(), cell);
listCellScripts (*this, cell->get<ESM::Lockpick>(), cell);
listCellScripts (*this, cell->get<ESM::Miscellaneous>(), cell);
listCellScripts (*this, cell->get<ESM::NPC>(), cell);
listCellScriptsCont (*this, cell->get<ESM::NPC>(), cell);
listCellScripts (*this, cell->get<ESM::Probe>(), cell);
listCellScripts (*this, cell->get<ESM::Repair>(), cell);
listCellScripts (*this, cell->get<ESM::Weapon>(), cell);
}
void MWWorld::LocalScripts::clear()

@ -15,13 +15,15 @@
#include <components/nifbullet/bulletnifloader.hpp>
#include <components/esm/loadgmst.hpp>
#include "../mwbase/world.hpp" // FIXME
#include "../mwbase/environment.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include <components/esm/loadgmst.hpp>
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "ptr.hpp"
#include "class.hpp"
@ -574,7 +576,7 @@ namespace MWWorld
for(;iter != mMovementQueue.end();iter++)
{
float waterlevel = -std::numeric_limits<float>::max();
const ESM::Cell *cell = iter->first.getCell()->mCell;
const ESM::Cell *cell = iter->first.getCell()->getCell();
if(cell->hasWater())
waterlevel = cell->mWater;

@ -7,19 +7,20 @@
#include <components/esm/esmwriter.hpp>
#include <components/esm/player.hpp>
#include <components/esm/defs.hpp>
#include <components/esm/loadbsgn.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwmechanics/movement.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "class.hpp"
#include "ptr.hpp"
#include "inventorystore.hpp"
#include "cellstore.hpp"
namespace MWWorld
{
@ -191,7 +192,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 +204,7 @@ namespace MWWorld
{
player.mHasMark = true;
player.mMarkedPosition = mMarkedPosition;
player.mMarkedCell = mMarkedCell->mCell->getCellId();
player.mMarkedCell = mMarkedCell->getCell()->getCellId();
}
else
player.mHasMark = false;

@ -55,3 +55,8 @@ MWWorld::ContainerStore *MWWorld::Ptr::getContainerStore() const
{
return mContainerStore;
}
MWWorld::Ptr::operator const void *()
{
return mRef;
}

@ -1,12 +1,18 @@
#ifndef GAME_MWWORLD_PTR_H
#define GAME_MWWORLD_PTR_H
#include "cellstore.hpp"
#include <cassert>
#include <string>
#include <sstream>
#include "cellreflist.hpp"
#include "livecellref.hpp"
namespace MWWorld
{
class ContainerStore;
class CellStore;
/// \brief Pointer to a LiveCellRef
@ -74,6 +80,9 @@ namespace MWWorld
ContainerStore *getContainerStore() const;
///< May return a 0-pointer, if reference is not in a container.
operator const void *();
///< Return a 0-pointer, if Ptr is empty; return a non-0-pointer, if Ptr is not empty
};
inline bool operator== (const Ptr& left, const Ptr& right)

@ -17,11 +17,68 @@
#include "localscripts.hpp"
#include "esmstore.hpp"
#include "class.hpp"
#include "cellfunctors.hpp"
#include "cellstore.hpp"
namespace
{
struct InsertFunctor
{
MWWorld::CellStore& mCell;
bool mRescale;
Loading::Listener& mLoadingListener;
MWWorld::PhysicsSystem& mPhysics;
MWRender::RenderingManager& mRendering;
InsertFunctor (MWWorld::CellStore& cell, bool rescale, Loading::Listener& loadingListener,
MWWorld::PhysicsSystem& physics, MWRender::RenderingManager& rendering);
bool operator() (const MWWorld::Ptr& ptr);
};
InsertFunctor::InsertFunctor (MWWorld::CellStore& cell, bool rescale,
Loading::Listener& loadingListener, MWWorld::PhysicsSystem& physics,
MWRender::RenderingManager& rendering)
: mCell (cell), mRescale (rescale), mLoadingListener (loadingListener),
mPhysics (physics), mRendering (rendering)
{}
bool InsertFunctor::InsertFunctor::operator() (const MWWorld::Ptr& ptr)
{
if (mRescale)
{
if (ptr.getCellRef().mScale<0.5)
ptr.getCellRef().mScale = 0.5;
else if (ptr.getCellRef().mScale>2)
ptr.getCellRef().mScale = 2;
}
if (ptr.getRefData().getCount() && ptr.getRefData().isEnabled())
{
try
{
mRendering.addObject (ptr);
ptr.getClass().insertObject (ptr, mPhysics);
float ax = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[0]).valueDegrees();
float ay = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[1]).valueDegrees();
float az = Ogre::Radian(ptr.getRefData().getLocalRotation().rot[2]).valueDegrees();
MWBase::Environment::get().getWorld()->localRotateObject (ptr, ax, ay, az);
MWBase::Environment::get().getWorld()->scaleObject (ptr, ptr.getCellRef().mScale);
ptr.getClass().adjustPosition (ptr);
}
catch (const std::exception& e)
{
std::string error ("error during rendering: ");
std::cerr << error + e.what() << std::endl;
}
}
mLoadingListener.increaseProgress (1);
return true;
}
template<typename T>
void insertCellRefList(MWRender::RenderingManager& rendering,
@ -97,15 +154,15 @@ namespace MWWorld
}
}
if ((*iter)->mCell->isExterior())
if ((*iter)->getCell()->isExterior())
{
ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().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 +185,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<ESM::Land>().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 +275,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 +292,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,17 +314,17 @@ 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;
}
if (iter==mActiveCells.end())
refsToLoad += countRefs(*MWBase::Environment::get().getWorld()->getExterior(x, y));
refsToLoad += MWBase::Environment::get().getWorld()->getExterior(x, y)->count();
}
loadingListener->setProgressRange(refsToLoad);
@ -280,10 +337,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 +359,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;
@ -403,11 +460,11 @@ namespace MWWorld
++current;
}
int refsToLoad = countRefs(*cell);
int refsToLoad = cell->count();
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
@ -451,55 +508,10 @@ namespace MWWorld
mCellChanged = false;
}
int Scene::countRefs (const CellStore& cell)
{
return cell.mActivators.mList.size()
+ cell.mPotions.mList.size()
+ cell.mAppas.mList.size()
+ cell.mArmors.mList.size()
+ cell.mBooks.mList.size()
+ cell.mClothes.mList.size()
+ cell.mContainers.mList.size()
+ cell.mDoors.mList.size()
+ cell.mIngreds.mList.size()
+ cell.mCreatureLists.mList.size()
+ cell.mItemLists.mList.size()
+ cell.mLights.mList.size()
+ cell.mLockpicks.mList.size()
+ cell.mMiscItems.mList.size()
+ cell.mProbes.mList.size()
+ cell.mRepairs.mList.size()
+ cell.mStatics.mList.size()
+ cell.mWeapons.mList.size()
+ cell.mCreatures.mList.size()
+ cell.mNpcs.mList.size();
}
void Scene::insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener)
{
// Loop through all references in the cell
insertCellRefList(mRendering, cell.mActivators, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mPotions, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mAppas, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mArmors, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mBooks, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mClothes, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mContainers, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mDoors, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mIngreds, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mItemLists, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mLights, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mLockpicks, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mMiscItems, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mProbes, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mRepairs, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mStatics, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mWeapons, cell, *mPhysics, rescale, loadingListener);
// Load NPCs and creatures _after_ everything else (important for adjustPosition to work correctly)
insertCellRefList(mRendering, cell.mCreatures, cell, *mPhysics, rescale, loadingListener);
insertCellRefList(mRendering, cell.mNpcs, cell, *mPhysics, rescale, loadingListener);
// Since this adds additional creatures, load afterwards, or they would be loaded twice
insertCellRefList(mRendering, cell.mCreatureLists, cell, *mPhysics, rescale, loadingListener);
InsertFunctor functor (cell, rescale, *loadingListener, *mPhysics, mRendering);
cell.forEach (functor);
}
void Scene::addObjectToScene (const Ptr& ptr)

@ -21,6 +21,11 @@ namespace Files
class Collections;
}
namespace Loading
{
class Listener;
}
namespace Render
{
class OgreRenderer;
@ -58,8 +63,6 @@ namespace MWWorld
void insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener);
int countRefs (const CellStore& cell);
public:
Scene (MWRender::RenderingManager& rendering, PhysicsSystem *physics);

@ -9,6 +9,7 @@
#include "player.hpp"
#include "esmstore.hpp"
#include "fallback.hpp"
#include "cellstore.hpp"
using namespace Ogre;
using namespace MWWorld;
@ -664,7 +665,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 +696,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)
{

@ -48,27 +48,6 @@
using namespace Ogre;
namespace
{
template<typename T>
MWWorld::LiveCellRef<T> *searchViaHandle (const std::string& handle,
MWWorld::CellRefList<T>& refList)
{
typedef typename MWWorld::CellRefList<T>::List::iterator iterator;
for (iterator iter (refList.mList.begin()); iter!=refList.mList.end(); ++iter)
{
if (iter->mData.getCount() > 0 && iter->mData.getBaseNode()){
if (iter->mData.getHandle()==handle)
{
return &*iter;
}
}
}
return 0;
}
}
namespace MWWorld
{
struct GameContentLoader : public ContentLoader
@ -103,52 +82,6 @@ namespace MWWorld
LoadersContainer mLoaders;
};
Ptr World::getPtrViaHandle (const std::string& handle, CellStore& cell)
{
if (MWWorld::LiveCellRef<ESM::Activator> *ref =
searchViaHandle (handle, cell.mActivators))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Potion> *ref = searchViaHandle (handle, cell.mPotions))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = searchViaHandle (handle, cell.mAppas))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Armor> *ref = searchViaHandle (handle, cell.mArmors))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Book> *ref = searchViaHandle (handle, cell.mBooks))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Clothing> *ref = searchViaHandle (handle, cell.mClothes))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Container> *ref =
searchViaHandle (handle, cell.mContainers))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Creature> *ref =
searchViaHandle (handle, cell.mCreatures))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Door> *ref = searchViaHandle (handle, cell.mDoors))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Ingredient> *ref =
searchViaHandle (handle, cell.mIngreds))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Light> *ref = searchViaHandle (handle, cell.mLights))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Lockpick> *ref = searchViaHandle (handle, cell.mLockpicks))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = searchViaHandle (handle, cell.mMiscItems))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::NPC> *ref = searchViaHandle (handle, cell.mNpcs))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Probe> *ref = searchViaHandle (handle, cell.mProbes))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Repair> *ref = searchViaHandle (handle, cell.mRepairs))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Static> *ref = searchViaHandle (handle, cell.mStatics))
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Weapon> *ref = searchViaHandle (handle, cell.mWeapons))
return Ptr (ref, &cell);
return Ptr();
}
int World::getDaysPerMonth (int month) const
{
switch (month)
@ -506,10 +439,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<ESM::Region>().search (cell->mCell->mRegion))
if (const ESM::Region* region = getStore().get<ESM::Region>().search (cell->getCell()->mRegion))
return region->mName;
return getStore().get<ESM::GameSetting>().find ("sDefaultCellname")->mValue.getString();
@ -579,7 +512,7 @@ namespace MWWorld
iter!=mWorldScene->getActiveCells().end(); ++iter)
{
CellStore* cellstore = *iter;
Ptr ptr = getPtrViaHandle (handle, *cellstore);
Ptr ptr = cellstore->searchViaHandle (handle);
if (!ptr.isEmpty())
return ptr;
@ -946,11 +879,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 +1398,7 @@ namespace MWWorld
CellStore *currentCell = mWorldScene->getCurrentCell();
if (currentCell)
{
return currentCell->mCell->isExterior();
return currentCell->getCell()->isExterior();
}
return false;
}
@ -1475,7 +1408,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;
@ -1505,7 +1438,7 @@ namespace MWWorld
Ogre::Vector2 World::getNorthVector (CellStore* cell)
{
MWWorld::CellRefList<ESM::Static>& statics = cell->mStatics;
MWWorld::CellRefList<ESM::Static>& statics = cell->get<ESM::Static>();
MWWorld::LiveCellRef<ESM::Static>* ref = statics.find("northmarker");
if (!ref)
return Vector2(0, 1);
@ -1517,7 +1450,7 @@ namespace MWWorld
void World::getDoorMarkers (CellStore* cell, std::vector<World::DoorMarker>& out)
{
MWWorld::CellRefList<ESM::Door>& doors = cell->mDoors;
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>();
CellRefList<ESM::Door>::List& refList = doors.mList;
for (CellRefList<ESM::Door>::List::iterator it = refList.begin(); it != refList.end(); ++it)
{
@ -1757,10 +1690,10 @@ 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;
return pos.z < cell->getWaterLevel();
}
bool World::isOnGround(const MWWorld::Ptr &ptr) const
@ -1816,7 +1749,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;
@ -1900,7 +1833,7 @@ namespace MWWorld
const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells();
for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt)
{
MWWorld::CellRefList<ESM::Container>& containers = (*cellIt)->mContainers;
MWWorld::CellRefList<ESM::Container>& containers = (*cellIt)->get<ESM::Container>();
CellRefList<ESM::Container>::List& refList = containers.mList;
for (CellRefList<ESM::Container>::List::iterator container = refList.begin(); container != refList.end(); ++container)
{
@ -1972,7 +1905,7 @@ namespace MWWorld
if (0 == cellStore) {
return false;
}
const DoorList &doors = cellStore->mDoors.mList;
const DoorList &doors = cellStore->get<ESM::Door>().mList;
for (DoorList::const_iterator it = doors.begin(); it != doors.end(); ++it) {
if (!it->mRef.mTeleport) {
continue;
@ -1994,7 +1927,7 @@ namespace MWWorld
if (0 != source) {
// Find door leading to our current teleport door
// and use it destination to position inside cell.
const DoorList &doors = source->mDoors.mList;
const DoorList &doors = source->get<ESM::Door>().mList;
for (DoorList::const_iterator jt = doors.begin(); jt != doors.end(); ++jt) {
if (it->mRef.mTeleport &&
Misc::StringUtils::ciEqual(name, jt->mRef.mDestCell))
@ -2402,7 +2335,7 @@ namespace MWWorld
{
if (cell->isExterior())
return false;
MWWorld::CellRefList<ESM::Door>& doors = cell->mDoors;
MWWorld::CellRefList<ESM::Door>& doors = cell->get<ESM::Door>();
CellRefList<ESM::Door>::List& refList = doors.mList;
// Check if any door in the cell leads to an exterior directly

@ -24,3 +24,14 @@ void ESM::CellId::save (ESMWriter &esm) const
if (mPaged)
esm.writeHNT ("CIDX", mIndex, 8);
}
bool ESM::operator== (const CellId& left, const CellId& right)
{
return left.mWorldspace==right.mWorldspace && left.mPaged==right.mPaged &&
(!left.mPaged || (left.mIndex.mX==right.mIndex.mX && left.mIndex.mY==right.mIndex.mY));
}
bool ESM::operator!= (const CellId& left, const CellId& right)
{
return !(left==right);
}

@ -23,6 +23,9 @@ namespace ESM
void load (ESMReader &esm);
void save (ESMWriter &esm) const;
};
bool operator== (const CellId& left, const CellId& right);
bool operator!= (const CellId& left, const CellId& right);
}
#endif
Loading…
Cancel
Save