diff --git a/apps/openmw/mwworld/cellreflist.hpp b/apps/openmw/mwworld/cellreflist.hpp index 30be4a6610..9d6d63fb4f 100644 --- a/apps/openmw/mwworld/cellreflist.hpp +++ b/apps/openmw/mwworld/cellreflist.hpp @@ -7,9 +7,11 @@ namespace MWWorld { + struct CellRefListBase {}; + /// \brief Collection of references of one type template - struct CellRefList + struct CellRefList : public CellRefListBase { typedef LiveCellRef LiveRef; typedef std::list List; diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 951b1ab6fe..88679bf3f6 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -233,6 +233,22 @@ namespace namespace MWWorld { + struct CellStoreImp + { + CellStoreTuple mRefLists; + + template + static void assignStoreToIndex(CellStore& stores, CellRefList& refList) + { + const std::size_t storeIndex = CellStore::getTypeIndex(); + if (stores.mCellRefLists.size() <= storeIndex) + stores.mCellRefLists.resize(storeIndex + 1); + + assert(&store == &std::get>(stores.mCellStoreImp->mRefLists)); + + stores.mCellRefLists[storeIndex] = &refList; + } + }; template void CellRefList::load(ESM::CellRef &ref, bool deleted, const MWWorld::ESMStore &esmStore) @@ -397,10 +413,15 @@ namespace MWWorld , mHasState(false) , mLastRespawn(0, 0) , mRechargingItemsUpToDate(false) + , mCellStoreImp(std::make_unique()) { + std::apply([this](auto& ...x) {(CellStoreImp::assignStoreToIndex(*this, x), ...); }, mCellStoreImp->mRefLists); mWaterLevel = cell->mWater; } + CellStore::~CellStore() = default; + CellStore::CellStore(CellStore&&) = default; + const ESM::Cell *CellStore::getCell() const { return mCell; @@ -466,10 +487,10 @@ namespace MWWorld Ptr CellStore::searchViaActorId (int id) { - if (Ptr ptr = ::searchViaActorId (mNpcs, id, this, mMovedToAnotherCell)) + if (Ptr ptr = ::searchViaActorId (get(), id, this, mMovedToAnotherCell)) return ptr; - if (Ptr ptr = ::searchViaActorId (mCreatures, id, this, mMovedToAnotherCell)) + if (Ptr ptr = ::searchViaActorId (get(), id, this, mMovedToAnotherCell)) return ptr; for (const auto& [base, _] : mMovedHere) @@ -683,13 +704,13 @@ namespace MWWorld mHasState = true; - if (Ptr ptr = searchInContainerList (mContainers, id)) + if (Ptr ptr = searchInContainerList (get(), id)) return ptr; - if (Ptr ptr = searchInContainerList (mCreatures, id)) + if (Ptr ptr = searchInContainerList (get(), id)) return ptr; - if (Ptr ptr = searchInContainerList (mNpcs, id)) + if (Ptr ptr = searchInContainerList (get(), id)) return ptr; mHasState = oldState; @@ -711,27 +732,27 @@ namespace MWWorld // refID was modified, make sure we don't end up with duplicated refs switch (store.find(it->second)) { - case ESM::REC_ACTI: mActivators.remove(ref.mRefNum); break; - case ESM::REC_ALCH: mPotions.remove(ref.mRefNum); break; - case ESM::REC_APPA: mAppas.remove(ref.mRefNum); break; - case ESM::REC_ARMO: mArmors.remove(ref.mRefNum); break; - case ESM::REC_BOOK: mBooks.remove(ref.mRefNum); break; - case ESM::REC_CLOT: mClothes.remove(ref.mRefNum); break; - case ESM::REC_CONT: mContainers.remove(ref.mRefNum); break; - case ESM::REC_CREA: mCreatures.remove(ref.mRefNum); break; - case ESM::REC_DOOR: mDoors.remove(ref.mRefNum); break; - case ESM::REC_INGR: mIngreds.remove(ref.mRefNum); break; - case ESM::REC_LEVC: mCreatureLists.remove(ref.mRefNum); break; - case ESM::REC_LEVI: mItemLists.remove(ref.mRefNum); break; - case ESM::REC_LIGH: mLights.remove(ref.mRefNum); break; - case ESM::REC_LOCK: mLockpicks.remove(ref.mRefNum); break; - case ESM::REC_MISC: mMiscItems.remove(ref.mRefNum); break; - case ESM::REC_NPC_: mNpcs.remove(ref.mRefNum); break; - case ESM::REC_PROB: mProbes.remove(ref.mRefNum); break; - case ESM::REC_REPA: mRepairs.remove(ref.mRefNum); break; - case ESM::REC_STAT: mStatics.remove(ref.mRefNum); break; - case ESM::REC_WEAP: mWeapons.remove(ref.mRefNum); break; - case ESM::REC_BODY: mBodyParts.remove(ref.mRefNum); break; + case ESM::REC_ACTI: get().remove(ref.mRefNum); break; + case ESM::REC_ALCH: get().remove(ref.mRefNum); break; + case ESM::REC_APPA: get().remove(ref.mRefNum); break; + case ESM::REC_ARMO: get().remove(ref.mRefNum); break; + case ESM::REC_BOOK: get().remove(ref.mRefNum); break; + case ESM::REC_CLOT: get().remove(ref.mRefNum); break; + case ESM::REC_CONT: get().remove(ref.mRefNum); break; + case ESM::REC_CREA: get().remove(ref.mRefNum); break; + case ESM::REC_DOOR: get().remove(ref.mRefNum); break; + case ESM::REC_INGR: get().remove(ref.mRefNum); break; + case ESM::REC_LEVC: get().remove(ref.mRefNum); break; + case ESM::REC_LEVI: get().remove(ref.mRefNum); break; + case ESM::REC_LIGH: get().remove(ref.mRefNum); break; + case ESM::REC_LOCK: get().remove(ref.mRefNum); break; + case ESM::REC_MISC: get().remove(ref.mRefNum); break; + case ESM::REC_NPC_: get().remove(ref.mRefNum); break; + case ESM::REC_PROB: get().remove(ref.mRefNum); break; + case ESM::REC_REPA: get().remove(ref.mRefNum); break; + case ESM::REC_STAT: get().remove(ref.mRefNum); break; + case ESM::REC_WEAP: get().remove(ref.mRefNum); break; + case ESM::REC_BODY: get().remove(ref.mRefNum); break; default: break; } @@ -740,27 +761,27 @@ namespace MWWorld switch (store.find (ref.mRefID)) { - case ESM::REC_ACTI: mActivators.load(ref, deleted, store); break; - case ESM::REC_ALCH: mPotions.load(ref, deleted,store); break; - case ESM::REC_APPA: mAppas.load(ref, deleted, store); break; - case ESM::REC_ARMO: mArmors.load(ref, deleted, store); break; - case ESM::REC_BOOK: mBooks.load(ref, deleted, store); break; - case ESM::REC_CLOT: mClothes.load(ref, deleted, store); break; - case ESM::REC_CONT: mContainers.load(ref, deleted, store); break; - case ESM::REC_CREA: mCreatures.load(ref, deleted, store); break; - case ESM::REC_DOOR: mDoors.load(ref, deleted, store); break; - case ESM::REC_INGR: mIngreds.load(ref, deleted, store); break; - case ESM::REC_LEVC: mCreatureLists.load(ref, deleted, store); break; - case ESM::REC_LEVI: mItemLists.load(ref, deleted, store); break; - case ESM::REC_LIGH: mLights.load(ref, deleted, store); break; - case ESM::REC_LOCK: mLockpicks.load(ref, deleted, store); break; - case ESM::REC_MISC: mMiscItems.load(ref, deleted, store); break; - case ESM::REC_NPC_: mNpcs.load(ref, deleted, store); break; - case ESM::REC_PROB: mProbes.load(ref, deleted, store); break; - case ESM::REC_REPA: mRepairs.load(ref, deleted, store); break; - case ESM::REC_STAT: mStatics.load(ref, deleted, store); break; - case ESM::REC_WEAP: mWeapons.load(ref, deleted, store); break; - case ESM::REC_BODY: mBodyParts.load(ref, deleted, store); break; + case ESM::REC_ACTI: get().load(ref, deleted, store); break; + case ESM::REC_ALCH: get().load(ref, deleted,store); break; + case ESM::REC_APPA: get().load(ref, deleted, store); break; + case ESM::REC_ARMO: get().load(ref, deleted, store); break; + case ESM::REC_BOOK: get().load(ref, deleted, store); break; + case ESM::REC_CLOT: get().load(ref, deleted, store); break; + case ESM::REC_CONT: get().load(ref, deleted, store); break; + case ESM::REC_CREA: get().load(ref, deleted, store); break; + case ESM::REC_DOOR: get().load(ref, deleted, store); break; + case ESM::REC_INGR: get().load(ref, deleted, store); break; + case ESM::REC_LEVC: get().load(ref, deleted, store); break; + case ESM::REC_LEVI: get().load(ref, deleted, store); break; + case ESM::REC_LIGH: get().load(ref, deleted, store); break; + case ESM::REC_LOCK: get().load(ref, deleted, store); break; + case ESM::REC_MISC: get().load(ref, deleted, store); break; + case ESM::REC_NPC_: get().load(ref, deleted, store); break; + case ESM::REC_PROB: get().load(ref, deleted, store); break; + case ESM::REC_REPA: get().load(ref, deleted, store); break; + case ESM::REC_STAT: get().load(ref, deleted, store); break; + case ESM::REC_WEAP: get().load(ref, deleted, store); break; + case ESM::REC_BODY: get().load(ref, deleted, store); break; case 0: Log(Debug::Error) << "Cell reference '" + ref.mRefID + "' not found!"; return; @@ -809,27 +830,27 @@ namespace MWWorld void CellStore::writeReferences (ESM::ESMWriter& writer) const { - writeReferenceCollection (writer, mActivators); - writeReferenceCollection (writer, mPotions); - writeReferenceCollection (writer, mAppas); - writeReferenceCollection (writer, mArmors); - writeReferenceCollection (writer, mBooks); - writeReferenceCollection (writer, mClothes); - writeReferenceCollection (writer, mContainers); - writeReferenceCollection (writer, mCreatures); - writeReferenceCollection (writer, mDoors); - writeReferenceCollection (writer, mIngreds); - writeReferenceCollection (writer, mCreatureLists); - writeReferenceCollection (writer, mItemLists); - writeReferenceCollection (writer, mLights); - writeReferenceCollection (writer, mLockpicks); - writeReferenceCollection (writer, mMiscItems); - writeReferenceCollection (writer, mNpcs); - writeReferenceCollection (writer, mProbes); - writeReferenceCollection (writer, mRepairs); - writeReferenceCollection (writer, mStatics); - writeReferenceCollection (writer, mWeapons); - writeReferenceCollection (writer, mBodyParts); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); + writeReferenceCollection (writer, get()); for (const auto& [base, store] : mMovedToAnotherCell) { @@ -871,107 +892,107 @@ namespace MWWorld { case ESM::REC_ACTI: - readReferenceCollection (reader, mActivators, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_ALCH: - readReferenceCollection (reader, mPotions, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_APPA: - readReferenceCollection (reader, mAppas, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_ARMO: - readReferenceCollection (reader, mArmors, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_BOOK: - readReferenceCollection (reader, mBooks, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_CLOT: - readReferenceCollection (reader, mClothes, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_CONT: - readReferenceCollection (reader, mContainers, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_CREA: - readReferenceCollection (reader, mCreatures, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_DOOR: - readReferenceCollection (reader, mDoors, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_INGR: - readReferenceCollection (reader, mIngreds, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_LEVC: - readReferenceCollection (reader, mCreatureLists, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_LEVI: - readReferenceCollection (reader, mItemLists, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_LIGH: - readReferenceCollection (reader, mLights, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_LOCK: - readReferenceCollection (reader, mLockpicks, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_MISC: - readReferenceCollection (reader, mMiscItems, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_NPC_: - readReferenceCollection (reader, mNpcs, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_PROB: - readReferenceCollection (reader, mProbes, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_REPA: - readReferenceCollection (reader, mRepairs, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_STAT: - readReferenceCollection (reader, mStatics, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_WEAP: - readReferenceCollection (reader, mWeapons, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; case ESM::REC_BODY: - readReferenceCollection (reader, mBodyParts, cref, contentFileMap, this); + readReferenceCollection (reader, get(), cref, contentFileMap, this); break; default: @@ -1067,7 +1088,7 @@ namespace MWWorld { if (mState == State_Loaded) { - for (CellRefList::List::iterator it (mCreatures.mList.begin()); it!=mCreatures.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) @@ -1075,7 +1096,7 @@ namespace MWWorld MWBase::Environment::get().getMechanicsManager()->restoreDynamicStats(ptr, hours, true); } } - for (CellRefList::List::iterator it (mNpcs.mList.begin()); it!=mNpcs.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) @@ -1093,7 +1114,7 @@ namespace MWWorld if (mState == State_Loaded) { - for (CellRefList::List::iterator it (mCreatures.mList.begin()); it!=mCreatures.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) @@ -1101,7 +1122,7 @@ namespace MWWorld ptr.getClass().getContainerStore(ptr).rechargeItems(duration); } } - for (CellRefList::List::iterator it (mNpcs.mList.begin()); it!=mNpcs.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) @@ -1109,7 +1130,7 @@ namespace MWWorld ptr.getClass().getContainerStore(ptr).rechargeItems(duration); } } - for (CellRefList::List::iterator it (mContainers.mList.begin()); it!=mContainers.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); if (!ptr.isEmpty() && ptr.getRefData().getCustomData() != nullptr && ptr.getRefData().getCount() > 0 @@ -1131,29 +1152,29 @@ namespace MWWorld if (MWBase::Environment::get().getWorld()->getTimeStamp() - mLastRespawn > 24*30*iMonthsToRespawn) { mLastRespawn = MWBase::Environment::get().getWorld()->getTimeStamp(); - for (CellRefList::List::iterator it (mContainers.mList.begin()); it!=mContainers.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); ptr.getClass().respawn(ptr); } } - for (CellRefList::List::iterator it (mCreatures.mList.begin()); it!=mCreatures.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); clearCorpse(ptr); ptr.getClass().respawn(ptr); } - for (CellRefList::List::iterator it (mNpcs.mList.begin()); it!=mNpcs.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); clearCorpse(ptr); ptr.getClass().respawn(ptr); } - for (CellRefList::List::iterator it (mCreatureLists.mList.begin()); it!=mCreatureLists.mList.end(); ++it) + for (CellRefList::List::iterator it (get().mList.begin()); it!=get().mList.end(); ++it) { Ptr ptr = getCurrentPtr(&*it); - // no need to clearCorpse, handled as part of mCreatures + // no need to clearCorpse, handled as part of get() ptr.getClass().respawn(ptr); } } @@ -1188,10 +1209,10 @@ namespace MWWorld } }; - update(mWeapons.mList); - update(mArmors.mList); - update(mClothes.mList); - update(mBooks.mList); + update(get().mList); + update(get().mList); + update(get().mList); + update(get().mList); } void MWWorld::CellStore::checkItem(const Ptr& ptr) diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index 72d17b40dd..4076357ee5 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -2,16 +2,19 @@ #define GAME_MWWORLD_CELLSTORE_H #include +#include #include #include #include #include #include #include +#include #include "livecellref.hpp" #include "cellreflist.hpp" +#include #include #include #include @@ -44,15 +47,61 @@ namespace ESM struct CellState; struct CellId; struct RefNum; + struct Activator; + struct Potion; + struct Apparatus; + struct Armor; + struct Book; + struct Clothing; + struct Container; + struct Creature; + struct Door; + struct Ingredient; + struct CreatureLevList; + struct ItemLevList; + struct Light; + struct Lockpick; + struct Miscellaneous; + struct NPC; + struct Probe; + struct Repair; + struct Static; + struct Weapon; + struct BodyPart; } namespace MWWorld { class ESMStore; + struct CellStoreImp; + + using CellStoreTuple = std::tuple < + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList, + CellRefList>; /// \brief Mutable state of a cell class CellStore { + friend struct CellStoreImp; public: enum State @@ -78,28 +127,29 @@ namespace MWWorld MWWorld::TimeStamp mLastRespawn; - // List of refs owned by this cell - CellRefList mActivators; - CellRefList mPotions; - CellRefList mAppas; - CellRefList mArmors; - CellRefList mBooks; - CellRefList mClothes; - CellRefList mContainers; - CellRefList mCreatures; - CellRefList mDoors; - CellRefList mIngreds; - CellRefList mCreatureLists; - CellRefList mItemLists; - CellRefList mLights; - CellRefList mLockpicks; - CellRefList mMiscItems; - CellRefList mNpcs; - CellRefList mProbes; - CellRefList mRepairs; - CellRefList mStatics; - CellRefList mWeapons; - CellRefList mBodyParts; + template + static constexpr std::size_t getTypeIndex() + { + static_assert(Misc::TupleHasType, CellStoreTuple>::value); + return Misc::TupleTypeIndex, CellStoreTuple>::value; + } + + std::unique_ptr mCellStoreImp; + std::vector mCellRefLists; + + + template + CellRefList& get() + { + mHasState = true; + return static_cast&>(*mCellRefLists[getTypeIndex()]); + } + + template + const CellRefList& get() const + { + return static_cast&>(*mCellRefLists[getTypeIndex()]); + } typedef std::map MovedRefTracker; // References owned by a different cell that have been moved here. @@ -151,34 +201,29 @@ namespace MWWorld bool forEachInternal (Visitor& visitor) { return - forEachImp (visitor, mActivators) && - forEachImp (visitor, mPotions) && - forEachImp (visitor, mAppas) && - forEachImp (visitor, mArmors) && - forEachImp (visitor, mBooks) && - forEachImp (visitor, mClothes) && - forEachImp (visitor, mContainers) && - forEachImp (visitor, mDoors) && - forEachImp (visitor, mIngreds) && - forEachImp (visitor, mItemLists) && - forEachImp (visitor, mLights) && - forEachImp (visitor, mLockpicks) && - forEachImp (visitor, mMiscItems) && - forEachImp (visitor, mProbes) && - forEachImp (visitor, mRepairs) && - forEachImp (visitor, mStatics) && - forEachImp (visitor, mWeapons) && - forEachImp (visitor, mBodyParts) && - forEachImp (visitor, mCreatures) && - forEachImp (visitor, mNpcs) && - forEachImp (visitor, mCreatureLists); + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()) && + forEachImp (visitor, get()); } - /// @note If you get a linker error here, this means the given type can not be stored in a cell. The supported types are - /// defined at the bottom of this file. - template - CellRefList& get(); - public: /// Should this reference be accessible to the outside world (i.e. to scripts / game logic)? @@ -214,6 +259,8 @@ namespace MWWorld /// @param readerList The readers to use for loading of the cell on-demand. CellStore(const ESM::Cell* cell, const MWWorld::ESMStore& store, ESM::ReadersCache& readers); + CellStore(CellStore&&); + ~CellStore(); const ESM::Cell *getCell() const; @@ -362,11 +409,11 @@ namespace MWWorld // Should be phased out when we have const version of forEach inline const CellRefList& getReadOnlyDoors() const { - return mDoors; + return get(); } inline const CellRefList& getReadOnlyStatics() const { - return mStatics; + return get(); } bool isExterior() const; @@ -414,153 +461,6 @@ namespace MWWorld /// Invalid \a ref objects are silently dropped. }; - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mActivators; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mPotions; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mAppas; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mArmors; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mBooks; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mClothes; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mContainers; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mCreatures; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mDoors; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mIngreds; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mCreatureLists; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mItemLists; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mLights; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mLockpicks; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mMiscItems; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mNpcs; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mProbes; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mRepairs; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mStatics; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mWeapons; - } - - template<> - inline CellRefList& CellStore::get() - { - mHasState = true; - return mBodyParts; - } - bool operator== (const CellStore& left, const CellStore& right); bool operator!= (const CellStore& left, const CellStore& right); }