diff --git a/apps/openmw/mwclass/activator.cpp b/apps/openmw/mwclass/activator.cpp index fdbff026f..17757cb6b 100644 --- a/apps/openmw/mwclass/activator.cpp +++ b/apps/openmw/mwclass/activator.cpp @@ -130,7 +130,6 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } } diff --git a/apps/openmw/mwclass/apparatus.cpp b/apps/openmw/mwclass/apparatus.cpp index 06eea2c24..07bf25086 100644 --- a/apps/openmw/mwclass/apparatus.cpp +++ b/apps/openmw/mwclass/apparatus.cpp @@ -147,9 +147,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } bool Apparatus::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 9ad28a537..631ddd912 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -381,9 +381,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } int Armor::getEnchantmentPoints (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/book.cpp b/apps/openmw/mwclass/book.cpp index cfa2508c4..9ea9e659b 100644 --- a/apps/openmw/mwclass/book.cpp +++ b/apps/openmw/mwclass/book.cpp @@ -186,9 +186,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } int Book::getEnchantmentPoints (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index 8bd3fd2e6..7250e1837 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -275,9 +275,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } int Clothing::getEnchantmentPoints (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/container.cpp b/apps/openmw/mwclass/container.cpp index b82dff706..9e8c018cd 100644 --- a/apps/openmw/mwclass/container.cpp +++ b/apps/openmw/mwclass/container.cpp @@ -292,9 +292,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } void Container::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state) const diff --git a/apps/openmw/mwclass/creature.cpp b/apps/openmw/mwclass/creature.cpp index 7f43f8677..e5a98c889 100644 --- a/apps/openmw/mwclass/creature.cpp +++ b/apps/openmw/mwclass/creature.cpp @@ -599,9 +599,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } bool Creature::isBipedal(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index cb9f59e96..d0448f7ec 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -309,9 +309,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } void Door::ensureCustomData(const MWWorld::Ptr &ptr) const diff --git a/apps/openmw/mwclass/ingredient.cpp b/apps/openmw/mwclass/ingredient.cpp index 0b6724c6c..db2f2410b 100644 --- a/apps/openmw/mwclass/ingredient.cpp +++ b/apps/openmw/mwclass/ingredient.cpp @@ -184,9 +184,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } bool Ingredient::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 0442fd2e0..fe5149077 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -216,9 +216,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } bool Light::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index bd17a527b..63f75a845 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -165,9 +165,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } bool Lockpick::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/misc.cpp b/apps/openmw/mwclass/misc.cpp index 16d926f5e..a14ab3330 100644 --- a/apps/openmw/mwclass/misc.cpp +++ b/apps/openmw/mwclass/misc.cpp @@ -194,7 +194,6 @@ namespace MWClass { MWWorld::Ptr newPtr; - /* const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore(); @@ -216,15 +215,15 @@ namespace MWClass MWWorld::ManualRef newRef(store, base); MWWorld::LiveCellRef *ref = newRef.getPtr().get(); - newPtr = MWWorld::Ptr(&cell.get().insert(*ref), &cell); + + newPtr = MWWorld::Ptr(cell.insert(ref), &cell); newPtr.getCellRef().setGoldValue(goldAmount); newPtr.getRefData().setCount(1); } else { MWWorld::LiveCellRef *ref = ptr.get(); - newPtr = MWWorld::Ptr(&cell.get().insert(*ref), &cell); + newPtr = MWWorld::Ptr(cell.insert(ref), &cell); } - */ return newPtr; } diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index b5f2b52f3..7ab95bffa 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -1129,9 +1129,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } int Npc::getSkill(const MWWorld::Ptr& ptr, int skill) const diff --git a/apps/openmw/mwclass/potion.cpp b/apps/openmw/mwclass/potion.cpp index 0f449fa92..20a849019 100644 --- a/apps/openmw/mwclass/potion.cpp +++ b/apps/openmw/mwclass/potion.cpp @@ -177,9 +177,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } bool Potion::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 80825466a..79f423b30 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -164,9 +164,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } bool Probe::canSell (const MWWorld::Ptr& item, int npcServices) const diff --git a/apps/openmw/mwclass/repair.cpp b/apps/openmw/mwclass/repair.cpp index 993c39aa2..78ec2adcc 100644 --- a/apps/openmw/mwclass/repair.cpp +++ b/apps/openmw/mwclass/repair.cpp @@ -159,9 +159,8 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } boost::shared_ptr Repair::use (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwclass/static.cpp b/apps/openmw/mwclass/static.cpp index ae0b5d3dd..86019a5ad 100644 --- a/apps/openmw/mwclass/static.cpp +++ b/apps/openmw/mwclass/static.cpp @@ -59,8 +59,7 @@ namespace MWClass { MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } } diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index 15c0039a4..5665bf1c4 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -417,8 +417,7 @@ namespace MWClass MWWorld::LiveCellRef *ref = ptr.get(); - return MWWorld::Ptr(); - //return MWWorld::Ptr(&cell.get().insert(*ref), &cell); + return MWWorld::Ptr(cell.insert(ref), &cell); } int Weapon::getEnchantmentPoints (const MWWorld::Ptr& ptr) const diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 89b200262..8bf4d0ae9 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -97,6 +97,9 @@ namespace MWWorld public: + template + LiveCellRefBase* insert(const LiveCellRef* ref); + CellStore (const ESM::Cell *cell_); const ESM::Cell *getCell() const; @@ -234,6 +237,128 @@ namespace MWWorld MWMechanics::PathgridGraph mPathgridGraph; }; + + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mActivators.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mPotions.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mAppas.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mArmors.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mBooks.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mClothes.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mContainers.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mCreatures.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mDoors.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mIngreds.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mCreatureLists.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mItemLists.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mLights.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mLockpicks.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mMiscItems.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mNpcs.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mProbes.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mRepairs.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mStatics.insert(*ref); + } + template<> + inline LiveCellRefBase* CellStore::insert(const LiveCellRef* ref) + { + mHasState = true; + return &mWeapons.insert(*ref); + } + bool operator== (const CellStore& left, const CellStore& right); bool operator!= (const CellStore& left, const CellStore& right); }