mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 14:36:39 +00:00
encapsulated reference collections
This commit is contained in:
parent
367919200f
commit
83ded18af0
25 changed files with 374 additions and 197 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -680,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
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1253,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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -58,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -38,6 +38,16 @@ namespace MWWorld
|
||||||
mList.push_back(item);
|
mList.push_back(item);
|
||||||
return mList.back();
|
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;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -233,6 +233,71 @@ namespace MWWorld
|
||||||
return Ptr();
|
return Ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ptr CellStore::searchViaHandle (const std::string& handle)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
return Ptr();
|
||||||
|
}
|
||||||
|
|
||||||
float CellStore::getWaterLevel() const
|
float CellStore::getWaterLevel() const
|
||||||
{
|
{
|
||||||
return mWaterLevel;
|
return mWaterLevel;
|
||||||
|
@ -243,6 +308,31 @@ namespace MWWorld
|
||||||
mWaterLevel = level;
|
mWaterLevel = level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "livecellref.hpp"
|
#include "livecellref.hpp"
|
||||||
#include "esmstore.hpp"
|
#include "esmstore.hpp"
|
||||||
|
@ -34,27 +35,6 @@ namespace MWWorld
|
||||||
std::vector<std::string> mIds;
|
std::vector<std::string> mIds;
|
||||||
float mWaterLevel;
|
float mWaterLevel;
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
CellStore (const ESM::Cell *cell_);
|
|
||||||
|
|
||||||
const ESM::Cell *getCell() const;
|
|
||||||
|
|
||||||
State getState() const;
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
float getWaterLevel() const;
|
|
||||||
|
|
||||||
void setWaterLevel (float level);
|
|
||||||
|
|
||||||
// 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;
|
||||||
|
@ -76,6 +56,33 @@ 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 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);
|
||||||
|
|
||||||
void preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
|
void preload (const MWWorld::ESMStore &store, std::vector<ESM::ESMReader> &esm);
|
||||||
|
@ -83,6 +90,8 @@ namespace MWWorld
|
||||||
/// 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)
|
||||||
{
|
{
|
||||||
|
@ -94,19 +103,19 @@ 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 operator==(const CellStore &cell) {
|
||||||
|
@ -133,6 +142,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>
|
||||||
|
@ -159,6 +173,126 @@ 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>()
|
||||||
|
{
|
||||||
|
return mActivators;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Potion>& CellStore::get<ESM::Potion>()
|
||||||
|
{
|
||||||
|
return mPotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Apparatus>& CellStore::get<ESM::Apparatus>()
|
||||||
|
{
|
||||||
|
return mAppas;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Armor>& CellStore::get<ESM::Armor>()
|
||||||
|
{
|
||||||
|
return mArmors;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Book>& CellStore::get<ESM::Book>()
|
||||||
|
{
|
||||||
|
return mBooks;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Clothing>& CellStore::get<ESM::Clothing>()
|
||||||
|
{
|
||||||
|
return mClothes;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Container>& CellStore::get<ESM::Container>()
|
||||||
|
{
|
||||||
|
return mContainers;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Creature>& CellStore::get<ESM::Creature>()
|
||||||
|
{
|
||||||
|
return mCreatures;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Door>& CellStore::get<ESM::Door>()
|
||||||
|
{
|
||||||
|
return mDoors;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Ingredient>& CellStore::get<ESM::Ingredient>()
|
||||||
|
{
|
||||||
|
return mIngreds;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::CreatureLevList>& CellStore::get<ESM::CreatureLevList>()
|
||||||
|
{
|
||||||
|
return mCreatureLists;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::ItemLevList>& CellStore::get<ESM::ItemLevList>()
|
||||||
|
{
|
||||||
|
return mItemLists;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Light>& CellStore::get<ESM::Light>()
|
||||||
|
{
|
||||||
|
return mLights;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Lockpick>& CellStore::get<ESM::Lockpick>()
|
||||||
|
{
|
||||||
|
return mLockpicks;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Miscellaneous>& CellStore::get<ESM::Miscellaneous>()
|
||||||
|
{
|
||||||
|
return mMiscItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::NPC>& CellStore::get<ESM::NPC>()
|
||||||
|
{
|
||||||
|
return mNpcs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Probe>& CellStore::get<ESM::Probe>()
|
||||||
|
{
|
||||||
|
return mProbes;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Repair>& CellStore::get<ESM::Repair>()
|
||||||
|
{
|
||||||
|
return mRepairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Static>& CellStore::get<ESM::Static>()
|
||||||
|
{
|
||||||
|
return mStatics;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
inline CellRefList<ESM::Weapon>& CellStore::get<ESM::Weapon>()
|
||||||
|
{
|
||||||
|
return mWeapons;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -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()
|
||||||
|
|
|
@ -22,6 +22,63 @@
|
||||||
|
|
||||||
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,
|
||||||
|
@ -267,7 +324,7 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
@ -403,7 +460,7 @@ namespace MWWorld
|
||||||
++current;
|
++current;
|
||||||
}
|
}
|
||||||
|
|
||||||
int refsToLoad = countRefs(*cell);
|
int refsToLoad = cell->count();
|
||||||
loadingListener->setProgressRange(refsToLoad);
|
loadingListener->setProgressRange(refsToLoad);
|
||||||
|
|
||||||
// Load cell.
|
// Load cell.
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -63,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);
|
||||||
|
|
|
@ -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)
|
||||||
|
@ -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;
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue