Merge branch 'cellstore'

This commit is contained in:
Marc Zinnschlag 2014-02-24 10:03:13 +01:00
commit c62a352956
88 changed files with 1125 additions and 638 deletions

View file

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

View file

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

View file

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

View file

@ -148,7 +148,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Apparatus> *ref = MWWorld::LiveCellRef<ESM::Apparatus> *ref =
ptr.get<ESM::Apparatus>(); 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 bool Apparatus::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -363,7 +363,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Armor> *ref = MWWorld::LiveCellRef<ESM::Armor> *ref =
ptr.get<ESM::Armor>(); 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 int Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

View file

@ -186,7 +186,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Book> *ref = MWWorld::LiveCellRef<ESM::Book> *ref =
ptr.get<ESM::Book>(); 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 int Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

View file

@ -276,7 +276,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Clothing> *ref = MWWorld::LiveCellRef<ESM::Clothing> *ref =
ptr.get<ESM::Clothing>(); 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 int Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

View file

@ -257,7 +257,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Container> *ref = MWWorld::LiveCellRef<ESM::Container> *ref =
ptr.get<ESM::Container>(); 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) void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)

View file

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

View file

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

View file

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

View file

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

View file

@ -189,7 +189,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); 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 bool Ingredient::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -227,7 +227,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Light> *ref = MWWorld::LiveCellRef<ESM::Light> *ref =
ptr.get<ESM::Light>(); 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 void Light::ensureCustomData (const MWWorld::Ptr& ptr) const

View file

@ -169,7 +169,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Lockpick> *ref = MWWorld::LiveCellRef<ESM::Lockpick> *ref =
ptr.get<ESM::Lockpick>(); 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 bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

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

View file

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

View file

@ -185,7 +185,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Potion> *ref = MWWorld::LiveCellRef<ESM::Potion> *ref =
ptr.get<ESM::Potion>(); 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 bool Potion::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -168,7 +168,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Probe> *ref = MWWorld::LiveCellRef<ESM::Probe> *ref =
ptr.get<ESM::Probe>(); 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 bool Probe::canSell (const MWWorld::Ptr& item, int npcServices) const

View file

@ -163,7 +163,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Repair> *ref = MWWorld::LiveCellRef<ESM::Repair> *ref =
ptr.get<ESM::Repair>(); 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 boost::shared_ptr<MWWorld::Action> Repair::use (const MWWorld::Ptr& ptr) const

View file

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

View file

@ -426,7 +426,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Weapon> *ref = MWWorld::LiveCellRef<ESM::Weapon> *ref =
ptr.get<ESM::Weapon>(); 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 int Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const

View file

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

View file

@ -8,8 +8,9 @@
#include "../mwbase/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/containerstore.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
@ -110,7 +111,7 @@ bool MWDialogue::Filter::testPlayer (const ESM::DialInfo& info) const
// check cell // check cell
if (!info.mCell.empty()) 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 false;
return true; return true;
@ -445,7 +446,7 @@ bool MWDialogue::Filter::getSelectStructBoolean (const SelectWrapper& select) co
case SelectWrapper::Function_NotCell: 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: case SelectWrapper::Function_NotLocal:
{ {

View file

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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,9 @@
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/globalmap.hpp" #include "../mwrender/globalmap.hpp"
@ -356,7 +358,7 @@ namespace MWGui
ESM::Position markedPosition; ESM::Position markedPosition;
MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition); MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition);
if (markedCell && markedCell->isExterior() == !mInterior if (markedCell && markedCell->isExterior() == !mInterior
&& (!mInterior || Misc::StringUtils::ciEqual(markedCell->mCell->mName, mPrefix))) && (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix)))
{ {
MarkerPosition markerPos; MarkerPosition markerPos;
MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos); MyGUI::IntPoint widgetPos = getMarkerPosition(markedPosition.pos[0], markedPosition.pos[1], markerPos);

View file

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

View file

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

View file

@ -1,5 +1,18 @@
#include "sortfilteritemmodel.hpp" #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" #include "../mwworld/class.hpp"
namespace namespace

View file

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

View file

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

View file

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

View file

@ -10,6 +10,7 @@
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
@ -129,7 +130,7 @@ namespace MWGui
MWWorld::Ptr player = world->getPlayerPtr(); MWWorld::Ptr player = world->getPlayerPtr();
if (mSleeping && player.getCell()->isExterior()) if (mSleeping && player.getCell()->isExterior())
{ {
std::string regionstr = player.getCell()->mCell->mRegion; std::string regionstr = player.getCell()->getCell()->mRegion;
if (!regionstr.empty()) if (!regionstr.empty())
{ {
const ESM::Region *region = world->getStore().get<ESM::Region>().find (regionstr); const ESM::Region *region = world->getStore().get<ESM::Region>().find (regionstr);

View file

@ -18,6 +18,7 @@
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "console.hpp" #include "console.hpp"
#include "journalwindow.hpp" #include "journalwindow.hpp"
@ -739,22 +740,22 @@ namespace MWGui
mMap->setCellName( name ); mMap->setCellName( name );
mHud->setCellName( name ); mHud->setCellName( name );
if (cell->mCell->isExterior()) if (cell->getCell()->isExterior())
{ {
if (!cell->mCell->mName.empty()) if (!cell->getCell()->mName.empty())
mMap->addVisitedLocation ("#{sCell=" + name + "}", cell->mCell->getGridX (), cell->mCell->getGridY ()); 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"); mMap->setCellPrefix("Cell");
mHud->setCellPrefix("Cell"); mHud->setCellPrefix("Cell");
mMap->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); mMap->setActiveCell (cell->getCell()->getGridX(), cell->getCell()->getGridY());
mHud->setActiveCell( cell->mCell->getGridX(), cell->mCell->getGridY() ); mHud->setActiveCell (cell->getCell()->getGridX(), cell->getCell()->getGridY());
} }
else else
{ {
mMap->setCellPrefix( cell->mCell->mName ); mMap->setCellPrefix (cell->getCell()->mName );
mHud->setCellPrefix( cell->mCell->mName ); mHud->setCellPrefix (cell->getCell()->mName );
Ogre::Vector3 worldPos; Ogre::Vector3 worldPos;
if (!MWBase::Environment::get().getWorld()->findInteriorPositionInWorldSpace(cell, worldPos)) if (!MWBase::Environment::get().getWorld()->findInteriorPositionInWorldSpace(cell, worldPos))

View file

@ -15,13 +15,16 @@
#include "../engine.hpp" #include "../engine.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/statemanager.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" #include "../mwmechanics/creaturestats.hpp"
using namespace ICS; using namespace ICS;

View file

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

View file

@ -1,14 +1,14 @@
#include "aiactivate.hpp" #include "aiactivate.hpp"
#include <iostream>
#include "movement.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/action.hpp" #include "../mwworld/action.hpp"
#include "../mwworld/cellstore.hpp"
#include "steering.hpp" #include "steering.hpp"
#include "movement.hpp"
namespace namespace
{ {
@ -33,12 +33,12 @@ bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor,float duration)
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
ESM::Position pos = actor.getRefData().getPosition(); ESM::Position pos = actor.getRefData().getPosition();
Movement &movement = actor.getClass().getMovementSettings(actor); 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(); 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. //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) > if(sideX * (pos.pos[0] - cell->mData.mX*ESM::Land::REAL_SIZE) >
sideX * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) 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; 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. //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) > if(sideY * (pos.pos[1] - cell->mData.mY*ESM::Land::REAL_SIZE) >
sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f))

View file

@ -7,6 +7,8 @@
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp" #include "../mwworld/timestamp.hpp"
#include "../mwworld/inventorystore.hpp" #include "../mwworld/inventorystore.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
@ -305,7 +307,7 @@ namespace MWMechanics
float dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length()); float dist = Ogre::Math::Abs((newPathTarget - currPathTarget).length());
float targetPosThreshold; float targetPosThreshold;
bool isOutside = actor.getCell()->mCell->isExterior(); bool isOutside = actor.getCell()->getCell()->isExterior();
if (isOutside) if (isOutside)
targetPosThreshold = 300; targetPosThreshold = 300;
else else

View file

@ -1,14 +1,15 @@
#include "aiescort.hpp" #include "aiescort.hpp"
#include "movement.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/timestamp.hpp"
#include "steering.hpp" #include "steering.hpp"
#include "movement.hpp"
namespace namespace
{ {
@ -86,24 +87,24 @@ namespace MWMechanics
MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr(); MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
ESM::Position pos = actor.getRefData().getPosition(); 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. // 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)) 2.0 - 200))
{ {
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
return false; 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. // 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)) 2.0 - 200))
{ {
MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0; MWWorld::Class::get(actor).getMovementSettings(actor).mPosition[1] = 0;
@ -114,8 +115,8 @@ namespace MWMechanics
if(!mPathFinder.isPathConstructed() || cellChange) if(!mPathFinder.isPathConstructed() || cellChange)
{ {
mCellX = actor.getCell()->mCell->mData.mX; mCellX = actor.getCell()->getCell()->mData.mX;
mCellY = actor.getCell()->mCell->mData.mY; mCellY = actor.getCell()->getCell()->mData.mY;
ESM::Pathgrid::Point dest; ESM::Pathgrid::Point dest;
dest.mX = mX; dest.mX = mX;

View file

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

View file

@ -2,7 +2,9 @@
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "steering.hpp" #include "steering.hpp"
#include "movement.hpp" #include "movement.hpp"
@ -36,12 +38,12 @@ namespace MWMechanics
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
ESM::Position pos = actor.getRefData().getPosition(); ESM::Position pos = actor.getRefData().getPosition();
Movement &movement = actor.getClass().getMovementSettings(actor); 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(); 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. //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) > if(sideX * (pos.pos[0] - cell->mData.mX*ESM::Land::REAL_SIZE) >
sideX * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) sideX * (ESM::Land::REAL_SIZE/2.0f - 200.0f))
@ -50,9 +52,9 @@ namespace MWMechanics
return false; 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. //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) > if(sideY * (pos.pos[1] - cell->mData.mY*ESM::Land::REAL_SIZE) >
sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f)) sideY * (ESM::Land::REAL_SIZE/2.0f - 200.0f))

View file

@ -1,17 +1,19 @@
#include "aiwander.hpp" #include "aiwander.hpp"
#include "movement.hpp" #include <OgreVector3.h>
#include "../mwworld/class.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp" #include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/dialoguemanager.hpp" #include "../mwbase/dialoguemanager.hpp"
#include "creaturestats.hpp" #include "../mwworld/class.hpp"
#include <OgreVector3.h> #include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "creaturestats.hpp"
#include "steering.hpp" #include "steering.hpp"
#include "movement.hpp"
namespace namespace
{ {
@ -103,10 +105,10 @@ namespace MWMechanics
if(!mStoredAvailableNodes) if(!mStoredAvailableNodes)
{ {
mStoredAvailableNodes = true; 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; mCellX = actor.getCell()->getCell()->mData.mX;
mCellY = actor.getCell()->mCell->mData.mY; mCellY = actor.getCell()->getCell()->mData.mY;
if(!mPathgrid) if(!mPathgrid)
mDistance = 0; mDistance = 0;
@ -117,7 +119,7 @@ namespace MWMechanics
{ {
mXCell = 0; mXCell = 0;
mYCell = 0; mYCell = 0;
if(actor.getCell()->mCell->isExterior()) if(actor.getCell()->getCell()->isExterior())
{ {
mXCell = mCellX * ESM::Land::REAL_SIZE; mXCell = mCellX * ESM::Land::REAL_SIZE;
mYCell = mCellY * ESM::Land::REAL_SIZE; mYCell = mCellY * ESM::Land::REAL_SIZE;
@ -157,7 +159,7 @@ namespace MWMechanics
mDistance = 0; mDistance = 0;
// Don't try to move if you are in a new cell (ie: positioncell command called) but still play idles. // 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; mDistance = 0;
if(mChooseAction) if(mChooseAction)

View file

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

View file

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

View file

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

View file

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

View file

@ -1,13 +1,15 @@
#include "pathfinding.hpp" #include "pathfinding.hpp"
#include "../mwbase/world.hpp" #include <map>
#include "../mwbase/environment.hpp"
#include "OgreMath.h" #include "OgreMath.h"
#include "OgreVector3.h" #include "OgreVector3.h"
#include "../mwbase/world.hpp"
#include "../mwbase/environment.hpp"
#include <map> #include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
namespace namespace
{ {
@ -299,14 +301,14 @@ namespace MWMechanics
if(!allowShortcuts) if(!allowShortcuts)
{ {
const ESM::Pathgrid *pathGrid = 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 xCell = 0;
float yCell = 0; float yCell = 0;
if (mCell->isExterior()) if (mCell->isExterior())
{ {
xCell = mCell->mCell->mData.mX * ESM::Land::REAL_SIZE; xCell = mCell->getCell()->mData.mX * ESM::Land::REAL_SIZE;
yCell = mCell->mCell->mData.mY * 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 startNode = getClosestPoint(pathGrid, startPoint.mX - xCell, startPoint.mY - yCell,startPoint.mZ);
int endNode = getClosestPoint(pathGrid, endPoint.mX - xCell, endPoint.mY - yCell, endPoint.mZ); int endNode = getClosestPoint(pathGrid, endPoint.mX - xCell, endPoint.mY - yCell, endPoint.mZ);

View file

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

View file

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

View file

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

View file

@ -14,6 +14,7 @@
#include "../mwworld/actionteleport.hpp" #include "../mwworld/actionteleport.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwrender/animation.hpp" #include "../mwrender/animation.hpp"
@ -503,7 +504,7 @@ namespace MWMechanics
MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition); MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition);
if (markedCell) if (markedCell)
{ {
MWWorld::ActionTeleport action(markedCell->isExterior() ? "" : markedCell->mCell->mName, MWWorld::ActionTeleport action(markedCell->isExterior() ? "" : markedCell->getCell()->mName,
markedPosition); markedPosition);
action.execute(target); action.execute(target);
} }

View file

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

View file

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

View file

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

View file

@ -11,18 +11,26 @@
#include <OgreControllerManager.h> #include <OgreControllerManager.h>
#include <OgreStaticGeometry.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 <libs/openengine/ogre/lights.hpp>
#include <extern/shiny/Main/Factory.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include <extern/shiny/Main/Factory.hpp>
#include "../mwmechanics/character.hpp" #include "../mwmechanics/character.hpp"
#include "../mwmechanics/creaturestats.hpp" #include "../mwmechanics/creaturestats.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/fallback.hpp" #include "../mwworld/fallback.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "renderconst.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)); 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") ? bool quadratic = fallback->getFallbackBool("LightAttenuation_OutQuadInLin") ?
!interior : fallback->getFallbackBool("LightAttenuation_UseQuadratic"); !interior : fallback->getFallbackBool("LightAttenuation_UseQuadratic");

View file

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

View file

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

View file

@ -13,12 +13,12 @@
#include <components/esm/loadstat.hpp> #include <components/esm/loadstat.hpp>
#include <components/esm/loadpgrd.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/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwworld/esmstore.hpp"
#include "renderconst.hpp" #include "renderconst.hpp"
@ -230,22 +230,22 @@ void Debugging::togglePathgrid()
void Debugging::enableCellPathgrid(MWWorld::CellStore *store) void Debugging::enableCellPathgrid(MWWorld::CellStore *store)
{ {
const ESM::Pathgrid *pathgrid = 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; if (!pathgrid) return;
Vector3 cellPathGridPos(0, 0, 0); Vector3 cellPathGridPos(0, 0, 0);
if (store->mCell->isExterior()) if (store->getCell()->isExterior())
{ {
cellPathGridPos.x = store->mCell->mData.mX * ESM::Land::REAL_SIZE; cellPathGridPos.x = store->getCell()->mData.mX * ESM::Land::REAL_SIZE;
cellPathGridPos.y = store->mCell->mData.mY * ESM::Land::REAL_SIZE; cellPathGridPos.y = store->getCell()->mData.mY * ESM::Land::REAL_SIZE;
} }
SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos); SceneNode *cellPathGrid = mPathGridRoot->createChildSceneNode(cellPathGridPos);
cellPathGrid->attachObject(createPathgridLines(pathgrid)); cellPathGrid->attachObject(createPathgridLines(pathgrid));
cellPathGrid->attachObject(createPathgridPoints(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 else
{ {
@ -256,10 +256,10 @@ void Debugging::enableCellPathgrid(MWWorld::CellStore *store)
void Debugging::disableCellPathgrid(MWWorld::CellStore *store) void Debugging::disableCellPathgrid(MWWorld::CellStore *store)
{ {
if (store->mCell->isExterior()) if (store->getCell()->isExterior())
{ {
ExteriorPathgridNodes::iterator it = 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()) if (it != mExteriorPathgridNodes.end())
{ {
destroyCellPathgridNode(it->second); destroyCellPathgridNode(it->second);

View file

@ -7,12 +7,13 @@
#include <OgreCamera.h> #include <OgreCamera.h>
#include <OgreTextureManager.h> #include <OgreTextureManager.h>
#include "../mwworld/esmstore.hpp"
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "renderconst.hpp" #include "renderconst.hpp"
#include "renderingmanager.hpp" #include "renderingmanager.hpp"
@ -115,8 +116,8 @@ void LocalMap::requestMap(MWWorld::CellStore* cell, float zMin, float zMax)
mCameraRotNode->setOrientation(Quaternion::IDENTITY); 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))); 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 x = cell->getCell()->getGridX();
int y = cell->mCell->getGridY(); int y = cell->getCell()->getGridY();
std::string name = "Cell_"+coordStr(x, y); 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 segsX = std::ceil( length.x / sSize );
const int segsY = std::ceil( length.y / sSize ); const int segsY = std::ceil( length.y / sSize );
mInteriorName = cell->mCell->mName; mInteriorName = cell->getCell()->mName;
for (int x=0; x<segsX; ++x) for (int x=0; x<segsX; ++x)
{ {
@ -192,7 +193,7 @@ void LocalMap::requestMap(MWWorld::CellStore* cell,
Vector2 newcenter = start + 4096; Vector2 newcenter = start + 4096;
render(newcenter.x - center.x, newcenter.y - center.y, zMin, zMax, sSize, sSize, 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));
} }
} }
} }

View file

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

View file

@ -24,6 +24,7 @@
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/class.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/world.hpp" // these includes can be removed once the static-hack is gone
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
@ -422,9 +423,9 @@ void RenderingManager::postRenderTargetUpdate(const RenderTargetEvent &evt)
void RenderingManager::waterAdded (MWWorld::CellStore *store) 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); mWater->setActive(true);
} }
else else
@ -501,9 +502,9 @@ bool RenderingManager::toggleRenderMode(int mode)
void RenderingManager::configureFog(MWWorld::CellStore &mCell) void RenderingManager::configureFog(MWWorld::CellStore &mCell)
{ {
Ogre::ColourValue color; 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) void RenderingManager::configureFog(const float density, const Ogre::ColourValue& colour)
@ -553,8 +554,8 @@ void RenderingManager::setAmbientMode()
void RenderingManager::configureAmbient(MWWorld::CellStore &mCell) void RenderingManager::configureAmbient(MWWorld::CellStore &mCell)
{ {
if (mCell.mCell->mData.mFlags & ESM::Cell::Interior) if (mCell.getCell()->mData.mFlags & ESM::Cell::Interior)
mAmbientColor.setAsABGR (mCell.mCell->mAmbi.mAmbient); mAmbientColor.setAsABGR (mCell.getCell()->mAmbi.mAmbient);
setAmbientMode(); setAmbientMode();
// Create a "sun" that shines light downwards. It doesn't look // 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 = mRendering.getScene()->createLight();
mSun->setType(Ogre::Light::LT_DIRECTIONAL); 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; Ogre::ColourValue colour;
colour.setAsABGR (mCell.mCell->mAmbi.mSunlight); colour.setAsABGR (mCell.getCell()->mAmbi.mSunlight);
mSun->setDiffuseColour (colour); mSun->setDiffuseColour (colour);
mSun->setDirection(0,-1,0); mSun->setDirection(0,-1,0);
} }
@ -650,12 +651,12 @@ void RenderingManager::setGlare(bool glare)
void RenderingManager::requestMap(MWWorld::CellStore* cell) void RenderingManager::requestMap(MWWorld::CellStore* cell)
{ {
if (cell->mCell->isExterior()) if (cell->getCell()->isExterior())
{ {
assert(mTerrain); assert(mTerrain);
Ogre::AxisAlignedBox dims = mObjects->getDimensions(cell); 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)); dims.merge(mTerrain->getWorldBoundingBox(center));
if (dims.isFinite()) if (dims.isFinite())

View file

@ -13,6 +13,7 @@
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/cellstore.hpp"
#include "interpretercontext.hpp" #include "interpretercontext.hpp"
@ -88,7 +89,7 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
bool interior = bool interior =
!MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->mCell->isExterior(); !MWBase::Environment::get().getWorld()->getPlayerPtr().getCell()->getCell()->isExterior();
runtime.push (interior ? 1 : 0); runtime.push (interior ? 1 : 0);
} }
@ -103,7 +104,7 @@ namespace MWScript
std::string name = runtime.getStringLiteral (runtime[0].mInteger); std::string name = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop(); 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; std::string current = cell->mName;
@ -131,8 +132,8 @@ namespace MWScript
virtual void execute (Interpreter::Runtime& runtime) virtual void execute (Interpreter::Runtime& runtime)
{ {
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(); MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell();
if (cell->mCell->hasWater()) if (cell->getCell()->hasWater())
runtime.push (cell->mWaterLevel); runtime.push (cell->getWaterLevel());
else else
runtime.push (-std::numeric_limits<float>().max()); runtime.push (-std::numeric_limits<float>().max());
} }
@ -148,11 +149,11 @@ namespace MWScript
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(); 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"); throw std::runtime_error("Can't set water level in exterior cell");
cell->mWaterLevel = level; cell->setWaterLevel (level);
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); MWBase::Environment::get().getWorld()->setWaterHeight (cell->getWaterLevel());
} }
}; };
@ -166,11 +167,11 @@ namespace MWScript
MWWorld::CellStore *cell = MWBase::Environment::get().getWorld()->getPlayerPtr().getCell(); 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"); throw std::runtime_error("Can't set water level in exterior cell");
cell->mWaterLevel +=level; cell->setWaterLevel (cell->getWaterLevel()+level);
MWBase::Environment::get().getWorld()->setWaterHeight(cell->mWaterLevel); MWBase::Environment::get().getWorld()->setWaterHeight(cell->getWaterLevel());
} }
}; };

View file

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

View file

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

View file

@ -9,6 +9,7 @@
#include "../mwbase/statemanager.hpp" #include "../mwbase/statemanager.hpp"
#include "../mwworld/esmstore.hpp" #include "../mwworld/esmstore.hpp"
#include "../mwworld/cellstore.hpp"
#include "sound_output.hpp" #include "sound_output.hpp"
#include "sound_decoder.hpp" #include "sound_decoder.hpp"
@ -480,7 +481,7 @@ namespace MWSound
static float sTimePassed = 0.0; static float sTimePassed = 0.0;
MWBase::World *world = MWBase::Environment::get().getWorld(); MWBase::World *world = MWBase::Environment::get().getWorld();
const MWWorld::Ptr player = world->getPlayerPtr(); const MWWorld::Ptr player = world->getPlayerPtr();
const ESM::Cell *cell = player.getCell()->mCell; const ESM::Cell *cell = player.getCell()->getCell();
sTimePassed += duration; sTimePassed += duration;
if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound) if(!cell->isExterior() || sTimePassed < sTimeToNextEnvSound)
@ -548,7 +549,7 @@ namespace MWSound
MWWorld::Ptr player = MWWorld::Ptr player =
MWBase::Environment::get().getWorld()->getPlayerPtr(); MWBase::Environment::get().getWorld()->getPlayerPtr();
const ESM::Cell *cell = player.getCell()->mCell; const ESM::Cell *cell = player.getCell()->getCell();
Environment env = Env_Normal; Environment env = Env_Normal;
if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater) if((cell->mData.mFlags&cell->HasWater) && mListenerPos.z < cell->mWater)

View file

@ -23,6 +23,7 @@
#include "../mwworld/player.hpp" #include "../mwworld/player.hpp"
#include "../mwworld/class.hpp" #include "../mwworld/class.hpp"
#include "../mwworld/cellstore.hpp"
#include "../mwmechanics/npcstats.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(); 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()); MWBase::Environment::get().getWorld()->changeToCell (cellId, ptr.getRefData().getPosition());
} }

View file

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

View file

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

View file

@ -11,6 +11,7 @@
#include "class.hpp" #include "class.hpp"
#include "esmstore.hpp" #include "esmstore.hpp"
#include "containerstore.hpp" #include "containerstore.hpp"
#include "cellstore.hpp"
MWWorld::CellStore *MWWorld::Cells::getCellStore (const ESM::Cell *cell) 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; 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; ESM::CellState cellState;
cell.saveState (cellState); cell.saveState (cellState);
@ -78,17 +82,6 @@ void MWWorld::Cells::writeCell (ESM::ESMWriter& writer, const CellStore& cell) c
writer.endRecord (ESM::REC_CSTA); 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) MWWorld::Cells::Cells (const MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& reader)
: mStore (store), mReader (reader), : mStore (store), mReader (reader),
mIdCache (40, std::pair<std::string, CellStore *> ("", (CellStore*)0)), /// \todo make cache size configurable 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; 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. // Multiple plugin support for landscape data is much easier than for references. The last plugin wins.
result->second.load (mStore, mReader); 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; 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); 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, MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
bool searchInContainers) bool searchInContainers)
{ {
if (cell.mState==CellStore::State_Unloaded) if (cell.getState()==CellStore::State_Unloaded)
cell.preload (mStore, mReader); 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); cell.load (mStore, mReader);
} }
@ -175,65 +168,10 @@ MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, CellStore& cell,
return Ptr(); return Ptr();
} }
if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.mActivators.find (name)) Ptr ptr = cell.search (name);
return Ptr (ref, &cell);
if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.mPotions.find (name)) if (!ptr.isEmpty())
return Ptr (ref, &cell); return ptr;
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);
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 (searchInContainers) if (searchInContainers)
return cell.searchInContainer (name); return cell.searchInContainer (name);
@ -328,12 +266,12 @@ int MWWorld::Cells::countSavedGameRecords() const
for (std::map<std::string, CellStore>::const_iterator iter (mInteriors.begin()); for (std::map<std::string, CellStore>::const_iterator iter (mInteriors.begin());
iter!=mInteriors.end(); ++iter) iter!=mInteriors.end(); ++iter)
if (hasState (iter->second)) if (iter->second.hasState())
++count; ++count;
for (std::map<std::pair<int, int>, CellStore>::const_iterator iter (mExteriors.begin()); for (std::map<std::pair<int, int>, CellStore>::const_iterator iter (mExteriors.begin());
iter!=mExteriors.end(); ++iter) iter!=mExteriors.end(); ++iter)
if (hasState (iter->second)) if (iter->second.hasState())
++count; ++count;
return count; return count;
@ -341,14 +279,14 @@ int MWWorld::Cells::countSavedGameRecords() const
void MWWorld::Cells::write (ESM::ESMWriter& writer) 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) iter!=mExteriors.end(); ++iter)
if (hasState (iter->second)) if (iter->second.hasState())
writeCell (writer, iter->second); 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) iter!=mInteriors.end(); ++iter)
if (hasState (iter->second)) if (iter->second.hasState())
writeCell (writer, iter->second); writeCell (writer, iter->second);
} }
@ -375,7 +313,7 @@ bool MWWorld::Cells::readRecord (ESM::ESMReader& reader, int32_t type,
state.load (reader); state.load (reader);
cellStore->loadState (state); cellStore->loadState (state);
if (cellStore->mState!=CellStore::State_Loaded) if (cellStore->getState()!=CellStore::State_Loaded)
cellStore->load (mStore, mReader); cellStore->load (mStore, mReader);
cellStore->readReferences (reader, contentFileMap); cellStore->readReferences (reader, contentFileMap);

View file

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

View file

@ -1,6 +1,7 @@
#include "cellstore.hpp" #include "cellstore.hpp"
#include <iostream> #include <iostream>
#include <algorithm>
#include <components/esm/cellstate.hpp> #include <components/esm/cellstate.hpp>
#include <components/esm/cellid.hpp> #include <components/esm/cellid.hpp>
@ -140,11 +141,216 @@ namespace MWWorld
} }
CellStore::CellStore (const ESM::Cell *cell) CellStore::CellStore (const ESM::Cell *cell)
: mCell (cell), mState (State_Unloaded) : mCell (cell), mState (State_Unloaded), mHasState (false)
{ {
mWaterLevel = cell->mWater; 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) void CellStore::load (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm)
{ {
if (mState!=State_Loaded) 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 CellStore::searchInContainer (const std::string& id)
{ {
{ bool oldState = mHasState;
Ptr ptr = searchInContainerList (mContainers, id);
if (!ptr.isEmpty()) mHasState = true;
if (Ptr ptr = searchInContainerList (mContainers, id))
return ptr; return ptr;
}
{ if (Ptr ptr = searchInContainerList (mCreatures, id))
Ptr ptr = searchInContainerList (mCreatures, id);
if (!ptr.isEmpty())
return ptr; return ptr;
}
{ if (Ptr ptr = searchInContainerList (mNpcs, id))
Ptr ptr = searchInContainerList (mNpcs, id);
if (!ptr.isEmpty())
return ptr; return ptr;
}
mHasState = oldState;
return Ptr(); return Ptr();
} }
@ -305,6 +510,8 @@ namespace MWWorld
void CellStore::loadState (const ESM::CellState& state) void CellStore::loadState (const ESM::CellState& state)
{ {
mHasState = true;
if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater) if (mCell->mData.mFlags & ESM::Cell::Interior && mCell->mData.mFlags & ESM::Cell::HasWater)
mWaterLevel = state.mWaterLevel; mWaterLevel = state.mWaterLevel;
@ -348,6 +555,8 @@ namespace MWWorld
void CellStore::readReferences (ESM::ESMReader& reader, void CellStore::readReferences (ESM::ESMReader& reader,
const std::map<int, int>& contentFileMap) const std::map<int, int>& contentFileMap)
{ {
mHasState = true;
while (reader.isNextSub ("OBJE")) while (reader.isNextSub ("OBJE"))
{ {
unsigned int id = 0; 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);
}
} }

View file

@ -1,11 +1,12 @@
#ifndef GAME_MWWORLD_CELLSTORE_H #ifndef GAME_MWWORLD_CELLSTORE_H
#define GAME_MWWORLD_CELLSTORE_H #define GAME_MWWORLD_CELLSTORE_H
#include <deque>
#include <algorithm> #include <algorithm>
#include <stdexcept>
#include "livecellref.hpp" #include "livecellref.hpp"
#include "esmstore.hpp" #include "esmstore.hpp"
#include "cellreflist.hpp"
namespace ESM namespace ESM
{ {
@ -14,42 +15,9 @@ namespace ESM
namespace MWWorld namespace MWWorld
{ {
class Ptr;
/// A list of cell references /// \brief Mutable state of a cell
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 lnker, when
// all methods are known.
void load(ESM::CellRef &ref, bool deleted, const MWWorld::ESMStore &esmStore);
LiveRef *find (const std::string& name)
{
for (typename std::list<LiveRef>::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();
}
};
/// A storage struct for one single cell reference.
class CellStore class CellStore
{ {
public: public:
@ -59,15 +27,14 @@ namespace MWWorld
State_Unloaded, State_Preloaded, State_Loaded State_Unloaded, State_Preloaded, State_Loaded
}; };
CellStore (const ESM::Cell *cell_); private:
const ESM::Cell *mCell; const ESM::Cell *mCell;
State mState; State mState;
bool mHasState;
std::vector<std::string> mIds; std::vector<std::string> mIds;
float mWaterLevel; float mWaterLevel;
// Lists for each individual object type
CellRefList<ESM::Activator> mActivators; CellRefList<ESM::Activator> mActivators;
CellRefList<ESM::Potion> mPotions; CellRefList<ESM::Potion> mPotions;
CellRefList<ESM::Apparatus> mAppas; CellRefList<ESM::Apparatus> mAppas;
@ -89,16 +56,51 @@ namespace MWWorld
CellRefList<ESM::Static> mStatics; CellRefList<ESM::Static> mStatics;
CellRefList<ESM::Weapon> mWeapons; 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); 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); 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 /// Call functor (ref) for each reference. functor must return a bool. Returning
/// false will abort the iteration. /// false will abort the iteration.
/// \return Iteration completed? /// \return Iteration completed?
///
/// \note Creatures and NPCs are handled last.
template<class Functor> template<class Functor>
bool forEach (Functor& functor) bool forEach (Functor& functor)
{ {
mHasState = true;
return return
forEachImp (functor, mActivators) && forEachImp (functor, mActivators) &&
forEachImp (functor, mPotions) && forEachImp (functor, mPotions) &&
@ -107,34 +109,22 @@ namespace MWWorld
forEachImp (functor, mBooks) && forEachImp (functor, mBooks) &&
forEachImp (functor, mClothes) && forEachImp (functor, mClothes) &&
forEachImp (functor, mContainers) && forEachImp (functor, mContainers) &&
forEachImp (functor, mCreatures) &&
forEachImp (functor, mDoors) && forEachImp (functor, mDoors) &&
forEachImp (functor, mIngreds) && forEachImp (functor, mIngreds) &&
forEachImp (functor, mCreatureLists) &&
forEachImp (functor, mItemLists) && forEachImp (functor, mItemLists) &&
forEachImp (functor, mLights) && forEachImp (functor, mLights) &&
forEachImp (functor, mLockpicks) && forEachImp (functor, mLockpicks) &&
forEachImp (functor, mMiscItems) && forEachImp (functor, mMiscItems) &&
forEachImp (functor, mNpcs) &&
forEachImp (functor, mProbes) && forEachImp (functor, mProbes) &&
forEachImp (functor, mRepairs) && forEachImp (functor, mRepairs) &&
forEachImp (functor, mStatics) && forEachImp (functor, mStatics) &&
forEachImp (functor, mWeapons); forEachImp (functor, mWeapons) &&
forEachImp (functor, mCreatures) &&
forEachImp (functor, mNpcs) &&
forEachImp (functor, mCreatureLists);
} }
bool operator==(const CellStore &cell) { bool isExterior() const;
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); Ptr searchInContainer (const std::string& id);
@ -146,6 +136,11 @@ namespace MWWorld
void readReferences (ESM::ESMReader& reader, const std::map<int, int>& contentFileMap); 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: private:
template<class Functor, class List> template<class Functor, class List>
@ -172,6 +167,149 @@ namespace MWWorld
/// ///
/// Invalid \a ref objects are silently dropped. /// Invalid \a ref objects are silently dropped.
}; };
template<>
inline CellRefList<ESM::Activator>& CellStore::get<ESM::Activator>()
{
mHasState = true;
return mActivators;
}
template<>
inline CellRefList<ESM::Potion>& CellStore::get<ESM::Potion>()
{
mHasState = true;
return mPotions;
}
template<>
inline CellRefList<ESM::Apparatus>& CellStore::get<ESM::Apparatus>()
{
mHasState = true;
return mAppas;
}
template<>
inline CellRefList<ESM::Armor>& CellStore::get<ESM::Armor>()
{
mHasState = true;
return mArmors;
}
template<>
inline CellRefList<ESM::Book>& CellStore::get<ESM::Book>()
{
mHasState = true;
return mBooks;
}
template<>
inline CellRefList<ESM::Clothing>& CellStore::get<ESM::Clothing>()
{
mHasState = true;
return mClothes;
}
template<>
inline CellRefList<ESM::Container>& CellStore::get<ESM::Container>()
{
mHasState = true;
return mContainers;
}
template<>
inline CellRefList<ESM::Creature>& CellStore::get<ESM::Creature>()
{
mHasState = true;
return mCreatures;
}
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;
}
bool operator== (const CellStore& left, const CellStore& right);
bool operator!= (const CellStore& left, const CellStore& right);
} }
#endif #endif

View file

@ -3,6 +3,19 @@
#include <iterator> #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" #include "ptr.hpp"
namespace ESM namespace ESM

View file

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

View file

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

View file

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

View file

@ -7,19 +7,20 @@
#include <components/esm/esmwriter.hpp> #include <components/esm/esmwriter.hpp>
#include <components/esm/player.hpp> #include <components/esm/player.hpp>
#include <components/esm/defs.hpp> #include <components/esm/defs.hpp>
#include <components/esm/loadbsgn.hpp>
#include "../mwbase/environment.hpp" #include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" #include "../mwbase/world.hpp"
#include "../mwbase/windowmanager.hpp" #include "../mwbase/windowmanager.hpp"
#include "../mwbase/soundmanager.hpp" #include "../mwbase/soundmanager.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/inventorystore.hpp"
#include "../mwmechanics/movement.hpp" #include "../mwmechanics/movement.hpp"
#include "../mwmechanics/npcstats.hpp" #include "../mwmechanics/npcstats.hpp"
#include "class.hpp" #include "class.hpp"
#include "ptr.hpp"
#include "inventorystore.hpp"
#include "cellstore.hpp"
namespace MWWorld namespace MWWorld
{ {
@ -191,7 +192,7 @@ namespace MWWorld
ESM::Player player; ESM::Player player;
mPlayer.save (player.mObject); mPlayer.save (player.mObject);
player.mCellId = mCellStore->mCell->getCellId(); player.mCellId = mCellStore->getCell()->getCellId();
player.mBirthsign = mSign; player.mBirthsign = mSign;
@ -203,7 +204,7 @@ namespace MWWorld
{ {
player.mHasMark = true; player.mHasMark = true;
player.mMarkedPosition = mMarkedPosition; player.mMarkedPosition = mMarkedPosition;
player.mMarkedCell = mMarkedCell->mCell->getCellId(); player.mMarkedCell = mMarkedCell->getCell()->getCellId();
} }
else else
player.mHasMark = false; player.mHasMark = false;

View file

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

View file

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

View file

@ -17,11 +17,68 @@
#include "localscripts.hpp" #include "localscripts.hpp"
#include "esmstore.hpp" #include "esmstore.hpp"
#include "class.hpp" #include "class.hpp"
#include "cellfunctors.hpp" #include "cellfunctors.hpp"
#include "cellstore.hpp"
namespace 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> template<typename T>
void insertCellRefList(MWRender::RenderingManager& rendering, void insertCellRefList(MWRender::RenderingManager& rendering,
@ -97,15 +154,15 @@ namespace MWWorld
} }
} }
if ((*iter)->mCell->isExterior()) if ((*iter)->getCell()->isExterior())
{ {
ESM::Land* land = ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search( MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
(*iter)->mCell->getGridX(), (*iter)->getCell()->getGridX(),
(*iter)->mCell->getGridY() (*iter)->getCell()->getGridY()
); );
if (land) if (land)
mPhysics->removeHeightField( (*iter)->mCell->getGridX(), (*iter)->mCell->getGridY() ); mPhysics->removeHeightField ((*iter)->getCell()->getGridX(), (*iter)->getCell()->getGridY());
} }
mRendering.removeCell(*iter); mRendering.removeCell(*iter);
@ -128,18 +185,18 @@ namespace MWWorld
float worldsize = ESM::Land::REAL_SIZE; float worldsize = ESM::Land::REAL_SIZE;
// Load terrain physics first... // Load terrain physics first...
if (cell->mCell->isExterior()) if (cell->getCell()->isExterior())
{ {
ESM::Land* land = ESM::Land* land =
MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search( MWBase::Environment::get().getWorld()->getStore().get<ESM::Land>().search(
cell->mCell->getGridX(), cell->getCell()->getGridX(),
cell->mCell->getGridY() cell->getCell()->getGridY()
); );
if (land) { if (land) {
mPhysics->addHeightField ( mPhysics->addHeightField (
land->mLandData->mHeights, land->mLandData->mHeights,
cell->mCell->getGridX(), cell->getCell()->getGridX(),
cell->mCell->getGridY(), cell->getCell()->getGridY(),
0, 0,
worldsize / (verts-1), worldsize / (verts-1),
verts) verts)
@ -218,10 +275,10 @@ namespace MWWorld
int numUnload = 0; int numUnload = 0;
while (active!=mActiveCells.end()) while (active!=mActiveCells.end())
{ {
if ((*active)->mCell->isExterior()) if ((*active)->getCell()->isExterior())
{ {
if (std::abs (X-(*active)->mCell->getGridX())<=1 && if (std::abs (X-(*active)->getCell()->getGridX())<=1 &&
std::abs (Y-(*active)->mCell->getGridY())<=1) std::abs (Y-(*active)->getCell()->getGridY())<=1)
{ {
// keep cells within the new 3x3 grid // keep cells within the new 3x3 grid
++active; ++active;
@ -235,10 +292,10 @@ namespace MWWorld
active = mActiveCells.begin(); active = mActiveCells.begin();
while (active!=mActiveCells.end()) while (active!=mActiveCells.end())
{ {
if ((*active)->mCell->isExterior()) if ((*active)->getCell()->isExterior())
{ {
if (std::abs (X-(*active)->mCell->getGridX())<=1 && if (std::abs (X-(*active)->getCell()->getGridX())<=1 &&
std::abs (Y-(*active)->mCell->getGridY())<=1) std::abs (Y-(*active)->getCell()->getGridY())<=1)
{ {
// keep cells within the new 3x3 grid // keep cells within the new 3x3 grid
++active; ++active;
@ -257,17 +314,17 @@ namespace MWWorld
while (iter!=mActiveCells.end()) while (iter!=mActiveCells.end())
{ {
assert ((*iter)->mCell->isExterior()); assert ((*iter)->getCell()->isExterior());
if (x==(*iter)->mCell->getGridX() && if (x==(*iter)->getCell()->getGridX() &&
y==(*iter)->mCell->getGridY()) y==(*iter)->getCell()->getGridY())
break; break;
++iter; ++iter;
} }
if (iter==mActiveCells.end()) 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); loadingListener->setProgressRange(refsToLoad);
@ -280,10 +337,10 @@ namespace MWWorld
while (iter!=mActiveCells.end()) while (iter!=mActiveCells.end())
{ {
assert ((*iter)->mCell->isExterior()); assert ((*iter)->getCell()->isExterior());
if (x==(*iter)->mCell->getGridX() && if (x==(*iter)->getCell()->getGridX() &&
y==(*iter)->mCell->getGridY()) y==(*iter)->getCell()->getGridY())
break; break;
++iter; ++iter;
@ -302,10 +359,10 @@ namespace MWWorld
while (iter!=mActiveCells.end()) while (iter!=mActiveCells.end())
{ {
assert ((*iter)->mCell->isExterior()); assert ((*iter)->getCell()->isExterior());
if (X==(*iter)->mCell->getGridX() && if (X==(*iter)->getCell()->getGridX() &&
Y==(*iter)->mCell->getGridY()) Y==(*iter)->getCell()->getGridY())
break; break;
++iter; ++iter;
@ -403,11 +460,11 @@ namespace MWWorld
++current; ++current;
} }
int refsToLoad = countRefs(*cell); int refsToLoad = cell->count();
loadingListener->setProgressRange(refsToLoad); loadingListener->setProgressRange(refsToLoad);
// Load cell. // Load cell.
std::cout << "cellName: " << cell->mCell->mName << std::endl; std::cout << "cellName: " << cell->getCell()->mName << std::endl;
//Loading Interior loading text //Loading Interior loading text
@ -451,55 +508,10 @@ namespace MWWorld
mCellChanged = false; 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) void Scene::insertCell (CellStore &cell, bool rescale, Loading::Listener* loadingListener)
{ {
// Loop through all references in the cell InsertFunctor functor (cell, rescale, *loadingListener, *mPhysics, mRendering);
insertCellRefList(mRendering, cell.mActivators, cell, *mPhysics, rescale, loadingListener); cell.forEach (functor);
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);
} }
void Scene::addObjectToScene (const Ptr& ptr) void Scene::addObjectToScene (const Ptr& ptr)

View file

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

View file

@ -9,6 +9,7 @@
#include "player.hpp" #include "player.hpp"
#include "esmstore.hpp" #include "esmstore.hpp"
#include "fallback.hpp" #include "fallback.hpp"
#include "cellstore.hpp"
using namespace Ogre; using namespace Ogre;
using namespace MWWorld; using namespace MWWorld;
@ -664,7 +665,7 @@ void WeatherManager::changeWeather(const std::string& region, const unsigned int
mRegionOverrides[Misc::StringUtils::lowerCase(region)] = weather; 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)) if (Misc::StringUtils::ciEqual(region, playerRegion))
setWeather(weather); setWeather(weather);
} }
@ -695,7 +696,7 @@ void WeatherManager::switchToNextWeather(bool instantly)
MWBase::World* world = MWBase::Environment::get().getWorld(); MWBase::World* world = MWBase::Environment::get().getWorld();
if (world->isCellExterior() || world->isCellQuasiExterior()) 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) if (mWeatherUpdateTime <= 0 || regionstr != mCurrentRegion)
{ {

View file

@ -48,27 +48,6 @@
using namespace Ogre; 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 namespace MWWorld
{ {
struct GameContentLoader : public ContentLoader struct GameContentLoader : public ContentLoader
@ -103,52 +82,6 @@ namespace MWWorld
LoadersContainer mLoaders; 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 int World::getDaysPerMonth (int month) const
{ {
switch (month) switch (month)
@ -506,10 +439,10 @@ namespace MWWorld
if (!cell) if (!cell)
cell = mWorldScene->getCurrentCell(); cell = mWorldScene->getCurrentCell();
if (!cell->mCell->isExterior() || !cell->mCell->mName.empty()) if (!cell->getCell()->isExterior() || !cell->getCell()->mName.empty())
return cell->mCell->mName; 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 region->mName;
return getStore().get<ESM::GameSetting>().find ("sDefaultCellname")->mValue.getString(); return getStore().get<ESM::GameSetting>().find ("sDefaultCellname")->mValue.getString();
@ -579,7 +512,7 @@ namespace MWWorld
iter!=mWorldScene->getActiveCells().end(); ++iter) iter!=mWorldScene->getActiveCells().end(); ++iter)
{ {
CellStore* cellstore = *iter; CellStore* cellstore = *iter;
Ptr ptr = getPtrViaHandle (handle, *cellstore); Ptr ptr = cellstore->searchViaHandle (handle);
if (!ptr.isEmpty()) if (!ptr.isEmpty())
return ptr; return ptr;
@ -946,11 +879,11 @@ namespace MWWorld
if (isPlayer) if (isPlayer)
{ {
if (!newCell.isExterior()) if (!newCell.isExterior())
changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.mCell->mName), pos); changeToInteriorCell(Misc::StringUtils::lowerCase(newCell.getCell()->mName), pos);
else else
{ {
int cellX = newCell.mCell->getGridX(); int cellX = newCell.getCell()->getGridX();
int cellY = newCell.mCell->getGridY(); int cellY = newCell.getCell()->getGridY();
mWorldScene->changeCell(cellX, cellY, pos, false); mWorldScene->changeCell(cellX, cellY, pos, false);
} }
addContainerScripts (getPlayerPtr(), &newCell); addContainerScripts (getPlayerPtr(), &newCell);
@ -1465,7 +1398,7 @@ namespace MWWorld
CellStore *currentCell = mWorldScene->getCurrentCell(); CellStore *currentCell = mWorldScene->getCurrentCell();
if (currentCell) if (currentCell)
{ {
return currentCell->mCell->isExterior(); return currentCell->getCell()->isExterior();
} }
return false; return false;
} }
@ -1475,7 +1408,7 @@ namespace MWWorld
CellStore *currentCell = mWorldScene->getCurrentCell(); CellStore *currentCell = mWorldScene->getCurrentCell();
if (currentCell) if (currentCell)
{ {
if (!(currentCell->mCell->mData.mFlags & ESM::Cell::QuasiEx)) if (!(currentCell->getCell()->mData.mFlags & ESM::Cell::QuasiEx))
return false; return false;
else else
return true; return true;
@ -1505,7 +1438,7 @@ namespace MWWorld
Ogre::Vector2 World::getNorthVector (CellStore* cell) 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"); MWWorld::LiveCellRef<ESM::Static>* ref = statics.find("northmarker");
if (!ref) if (!ref)
return Vector2(0, 1); return Vector2(0, 1);
@ -1517,7 +1450,7 @@ namespace MWWorld
void World::getDoorMarkers (CellStore* cell, std::vector<World::DoorMarker>& out) 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; CellRefList<ESM::Door>::List& refList = doors.mList;
for (CellRefList<ESM::Door>::List::iterator it = refList.begin(); it != refList.end(); ++it) for (CellRefList<ESM::Door>::List::iterator it = refList.begin(); it != refList.end(); ++it)
{ {
@ -1757,10 +1690,10 @@ namespace MWWorld
bool bool
World::isUnderwater(const MWWorld::CellStore* cell, const Ogre::Vector3 &pos) const 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 false;
} }
return pos.z < cell->mWaterLevel; return pos.z < cell->getWaterLevel();
} }
bool World::isOnGround(const MWWorld::Ptr &ptr) const bool World::isOnGround(const MWWorld::Ptr &ptr) const
@ -1816,7 +1749,7 @@ namespace MWWorld
const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle()); const OEngine::Physic::PhysicActor *physactor = mPhysEngine->getCharacter(refdata.getHandle());
if((!physactor->getOnGround()&&physactor->getCollisionMode()) || isUnderwater(currentCell, playerPos)) if((!physactor->getOnGround()&&physactor->getCollisionMode()) || isUnderwater(currentCell, playerPos))
return 2; return 2;
if((currentCell->mCell->mData.mFlags&ESM::Cell::NoSleep) || if((currentCell->getCell()->mData.mFlags&ESM::Cell::NoSleep) ||
Class::get(player).getNpcStats(player).isWerewolf()) Class::get(player).getNpcStats(player).isWerewolf())
return 1; return 1;
@ -1900,7 +1833,7 @@ namespace MWWorld
const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells(); const Scene::CellStoreCollection& collection = mWorldScene->getActiveCells();
for (Scene::CellStoreCollection::const_iterator cellIt = collection.begin(); cellIt != collection.end(); ++cellIt) 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; CellRefList<ESM::Container>::List& refList = containers.mList;
for (CellRefList<ESM::Container>::List::iterator container = refList.begin(); container != refList.end(); ++container) for (CellRefList<ESM::Container>::List::iterator container = refList.begin(); container != refList.end(); ++container)
{ {
@ -1972,7 +1905,7 @@ namespace MWWorld
if (0 == cellStore) { if (0 == cellStore) {
return false; 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) { for (DoorList::const_iterator it = doors.begin(); it != doors.end(); ++it) {
if (!it->mRef.mTeleport) { if (!it->mRef.mTeleport) {
continue; continue;
@ -1994,7 +1927,7 @@ namespace MWWorld
if (0 != source) { if (0 != source) {
// Find door leading to our current teleport door // Find door leading to our current teleport door
// and use it destination to position inside cell. // 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) { for (DoorList::const_iterator jt = doors.begin(); jt != doors.end(); ++jt) {
if (it->mRef.mTeleport && if (it->mRef.mTeleport &&
Misc::StringUtils::ciEqual(name, jt->mRef.mDestCell)) Misc::StringUtils::ciEqual(name, jt->mRef.mDestCell))
@ -2402,7 +2335,7 @@ namespace MWWorld
{ {
if (cell->isExterior()) if (cell->isExterior())
return false; 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; CellRefList<ESM::Door>::List& refList = doors.mList;
// Check if any door in the cell leads to an exterior directly // Check if any door in the cell leads to an exterior directly

View file

@ -24,3 +24,14 @@ void ESM::CellId::save (ESMWriter &esm) const
if (mPaged) if (mPaged)
esm.writeHNT ("CIDX", mIndex, 8); 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);
}

View file

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