From 929fade8befa9ad985d8b037cf20ad5aacc48af9 Mon Sep 17 00:00:00 2001 From: Petr Mikheev Date: Sun, 5 Mar 2023 18:45:53 +0100 Subject: [PATCH] Merge duplicated `public:` and `private:` sections in cellstore.hpp --- apps/openmw/mwworld/cellstore.hpp | 147 +++++++++++++++--------------- 1 file changed, 72 insertions(+), 75 deletions(-) diff --git a/apps/openmw/mwworld/cellstore.hpp b/apps/openmw/mwworld/cellstore.hpp index eab25c21b8..51aea9129a 100644 --- a/apps/openmw/mwworld/cellstore.hpp +++ b/apps/openmw/mwworld/cellstore.hpp @@ -79,8 +79,6 @@ namespace MWWorld /// \brief Mutable state of a cell class CellStore { - friend struct CellStoreImp; - public: enum State { @@ -89,78 +87,6 @@ namespace MWWorld State_Loaded }; - private: - const MWWorld::ESMStore& mStore; - ESM::ReadersCache& mReaders; - - // Even though fog actually belongs to the player and not cells, - // it makes sense to store it here since we need it once for each cell. - // Note this is nullptr until the cell is explored to save some memory - std::unique_ptr mFogState; - - MWWorld::Cell mCellVariant; - State mState; - bool mHasState; - std::vector mIds; - float mWaterLevel; - - MWWorld::TimeStamp mLastRespawn; - - 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. - // - MovedRefTracker mMovedHere; - // References owned by this cell that have been moved to another cell. - // - MovedRefTracker mMovedToAnotherCell; - - // Merged list of ref's currently in this cell - i.e. with added refs from mMovedHere, removed refs from - // mMovedToAnotherCell - std::vector mMergedRefs; - - // Get the Ptr for the given ref which originated from this cell (possibly moved to another cell at this point). - Ptr getCurrentPtr(MWWorld::LiveCellRefBase* ref); - - /// Moves object from the given cell to this cell. - void moveFrom(const MWWorld::Ptr& object, MWWorld::CellStore* from); - - /// Repopulate mMergedRefs. - void updateMergedRefs(); - - // (item, max charge) - typedef std::vector> TRechargingItems; - TRechargingItems mRechargingItems; - - bool mRechargingItemsUpToDate; - - void updateRechargingItems(); - void rechargeItems(float duration); - void checkItem(const Ptr& ptr); - - public: /// Should this reference be accessible to the outside world (i.e. to scripts / game logic)? /// Determined based on the deletion flags. By default, objects deleted by content files are never accessible; /// objects deleted by setCount(0) are still accessible *if* they came from a content file (needed for vanilla @@ -364,7 +290,6 @@ namespace MWWorld struct GetCellStoreCallback { - public: ///@note must return nullptr if the cell is not found virtual CellStore* getCellStore(const ESM::CellId& cellId) = 0; virtual ~GetCellStoreCallback() = default; @@ -383,6 +308,78 @@ namespace MWWorld bool operator==(const CellStore& right) const; private: + friend struct CellStoreImp; + + const MWWorld::ESMStore& mStore; + ESM::ReadersCache& mReaders; + + // Even though fog actually belongs to the player and not cells, + // it makes sense to store it here since we need it once for each cell. + // Note this is nullptr until the cell is explored to save some memory + std::unique_ptr mFogState; + + MWWorld::Cell mCellVariant; + State mState; + bool mHasState; + std::vector mIds; + float mWaterLevel; + + MWWorld::TimeStamp mLastRespawn; + + 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. + // + MovedRefTracker mMovedHere; + // References owned by this cell that have been moved to another cell. + // + MovedRefTracker mMovedToAnotherCell; + + // Merged list of ref's currently in this cell - i.e. with added refs from mMovedHere, removed refs from + // mMovedToAnotherCell + std::vector mMergedRefs; + + // Get the Ptr for the given ref which originated from this cell (possibly moved to another cell at this point). + Ptr getCurrentPtr(MWWorld::LiveCellRefBase* ref); + + /// Moves object from the given cell to this cell. + void moveFrom(const MWWorld::Ptr& object, MWWorld::CellStore* from); + + /// Repopulate mMergedRefs. + void updateMergedRefs(); + + // (item, max charge) + typedef std::vector> TRechargingItems; + TRechargingItems mRechargingItems; + + bool mRechargingItemsUpToDate; + + void updateRechargingItems(); + void rechargeItems(float duration); + void checkItem(const Ptr& ptr); + /// Run through references and store IDs void listRefs(const ESM::Cell& cell); void listRefs(const ESM4::Cell& cell);