diff options
author | Shauren <shauren.trinity@gmail.com> | 2023-01-07 22:38:21 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2023-01-07 22:38:21 +0100 |
commit | 92ed5e8af1f8b1aac085fd9b0ea93afb2b6795d4 (patch) | |
tree | f141fe0afd8ff11a7037329ffd75f070d73d6e70 /src/server/game/Grids | |
parent | a53e4a57565d3375a978effbbc32d3eed6aac7e3 (diff) |
Core/Misc: Include cleanup, 2023 edition
Diffstat (limited to 'src/server/game/Grids')
-rw-r--r-- | src/server/game/Grids/Dynamic/TypeContainer.h | 167 | ||||
-rw-r--r-- | src/server/game/Grids/GridDefines.h | 6 | ||||
-rw-r--r-- | src/server/game/Grids/NGrid.cpp | 7 |
3 files changed, 135 insertions, 45 deletions
diff --git a/src/server/game/Grids/Dynamic/TypeContainer.h b/src/server/game/Grids/Dynamic/TypeContainer.h index 0776bde32e0..f1d57735cef 100644 --- a/src/server/game/Grids/Dynamic/TypeContainer.h +++ b/src/server/game/Grids/Dynamic/TypeContainer.h @@ -36,7 +36,6 @@ template<class OBJECT> struct ContainerMapList { - //std::map<OBJECT_HANDLE, OBJECT *> _element; GridRefManager<OBJECT> _element; }; @@ -82,67 +81,145 @@ struct ContainerUnorderedMap<TypeList<H, T>, KEY_TYPE> template<class OBJECT_TYPES> class TypeMapContainer { - public: - template<class SPECIFIC_TYPE> size_t Count() const { return Trinity::Count(i_elements, (SPECIFIC_TYPE*)nullptr); } - - /// inserts a specific object into the container - template<class SPECIFIC_TYPE> - bool insert(SPECIFIC_TYPE *obj) - { - SPECIFIC_TYPE* t = Trinity::Insert(i_elements, obj); - return (t != nullptr); - } - - /// Removes the object from the container, and returns the removed object - //template<class SPECIFIC_TYPE> - //bool remove(SPECIFIC_TYPE* obj) - //{ - // SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj); - // return (t != nullptr); - //} - - ContainerMapList<OBJECT_TYPES> & GetElements(void) { return i_elements; } - const ContainerMapList<OBJECT_TYPES> & GetElements(void) const { return i_elements;} - - private: - ContainerMapList<OBJECT_TYPES> i_elements; +public: + TypeMapContainer(); + TypeMapContainer(TypeMapContainer const&) = default; + TypeMapContainer(TypeMapContainer&&) noexcept = default; + TypeMapContainer& operator=(TypeMapContainer const&) = default; + TypeMapContainer& operator=(TypeMapContainer&&) noexcept = default; + ~TypeMapContainer(); + + template<class SPECIFIC_TYPE> + size_t Count() const; + + /// inserts a specific object into the container + template<class SPECIFIC_TYPE> + bool insert(SPECIFIC_TYPE *obj); + + /// Removes the object from the container, and returns the removed object + //template<class SPECIFIC_TYPE> + //bool remove(SPECIFIC_TYPE* obj) + //{ + // SPECIFIC_TYPE* t = Trinity::Remove(i_elements, obj); + // return (t != nullptr); + //} + + ContainerMapList<OBJECT_TYPES>& GetElements(void); + const ContainerMapList<OBJECT_TYPES>& GetElements(void) const; + +private: + ContainerMapList<OBJECT_TYPES> i_elements; }; +template <class OBJECT_TYPES> +TypeMapContainer<OBJECT_TYPES>::TypeMapContainer() = default; + +template <class OBJECT_TYPES> +TypeMapContainer<OBJECT_TYPES>::~TypeMapContainer() = default; + +template <class OBJECT_TYPES> +template <class SPECIFIC_TYPE> +size_t TypeMapContainer<OBJECT_TYPES>::Count() const +{ + return Trinity::Count(i_elements, (SPECIFIC_TYPE*)nullptr); +} + +template <class OBJECT_TYPES> +template <class SPECIFIC_TYPE> +bool TypeMapContainer<OBJECT_TYPES>::insert(SPECIFIC_TYPE* obj) +{ + SPECIFIC_TYPE* t = Trinity::Insert(i_elements, obj); + return (t != nullptr); +} + +template <class OBJECT_TYPES> +ContainerMapList<OBJECT_TYPES>& TypeMapContainer<OBJECT_TYPES>::GetElements() +{ + return i_elements; +} + +template <class OBJECT_TYPES> +const ContainerMapList<OBJECT_TYPES>& TypeMapContainer<OBJECT_TYPES>::GetElements() const +{ + return i_elements; +} + template<class OBJECT_TYPES, class KEY_TYPE> class TypeUnorderedMapContainer { public: + TypeUnorderedMapContainer(); + TypeUnorderedMapContainer(TypeUnorderedMapContainer const&) = default; + TypeUnorderedMapContainer(TypeUnorderedMapContainer&&) noexcept = default; + TypeUnorderedMapContainer& operator=(TypeUnorderedMapContainer const&) = default; + TypeUnorderedMapContainer& operator=(TypeUnorderedMapContainer&&) noexcept = default; + ~TypeUnorderedMapContainer(); + template<class SPECIFIC_TYPE> - bool Insert(KEY_TYPE const& handle, SPECIFIC_TYPE* obj) - { - return Trinity::Insert(_elements, handle, obj); - } + bool Insert(KEY_TYPE const& handle, SPECIFIC_TYPE* obj); template<class SPECIFIC_TYPE> - bool Remove(KEY_TYPE const& handle) - { - return Trinity::Remove(_elements, handle, (SPECIFIC_TYPE*)nullptr); - } + bool Remove(KEY_TYPE const& handle); template<class SPECIFIC_TYPE> - SPECIFIC_TYPE* Find(KEY_TYPE const& handle) - { - return Trinity::Find(_elements, handle, (SPECIFIC_TYPE*)nullptr); - } + SPECIFIC_TYPE* Find(KEY_TYPE const& handle); template<class SPECIFIC_TYPE> - std::size_t Size() const - { - std::size_t size = 0; - Trinity::Size(_elements, &size, (SPECIFIC_TYPE*)nullptr); - return size; - } + std::size_t Size() const; - ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE>& GetElements() { return _elements; } - ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> const& GetElements() const { return _elements; } + ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE>& GetElements(); + ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> const& GetElements() const; private: ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> _elements; }; +template <class OBJECT_TYPES, class KEY_TYPE> +TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::TypeUnorderedMapContainer() = default; + +template <class OBJECT_TYPES, class KEY_TYPE> +TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::~TypeUnorderedMapContainer() = default; + +template <class OBJECT_TYPES, class KEY_TYPE> +template <class SPECIFIC_TYPE> +bool TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::Insert(KEY_TYPE const& handle, SPECIFIC_TYPE* obj) +{ + return Trinity::Insert(_elements, handle, obj); +} + +template <class OBJECT_TYPES, class KEY_TYPE> +template <class SPECIFIC_TYPE> +bool TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::Remove(KEY_TYPE const& handle) +{ + return Trinity::Remove(_elements, handle, (SPECIFIC_TYPE*)nullptr); +} + +template <class OBJECT_TYPES, class KEY_TYPE> +template <class SPECIFIC_TYPE> +SPECIFIC_TYPE* TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::Find(KEY_TYPE const& handle) +{ + return Trinity::Find(_elements, handle, (SPECIFIC_TYPE*)nullptr); +} + +template <class OBJECT_TYPES, class KEY_TYPE> +template <class SPECIFIC_TYPE> +std::size_t TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::Size() const +{ + std::size_t size = 0; + Trinity::Size(_elements, &size, (SPECIFIC_TYPE*)nullptr); + return size; +} + +template <class OBJECT_TYPES, class KEY_TYPE> +ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE>& TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::GetElements() +{ + return _elements; +} + +template <class OBJECT_TYPES, class KEY_TYPE> +ContainerUnorderedMap<OBJECT_TYPES, KEY_TYPE> const& TypeUnorderedMapContainer<OBJECT_TYPES, KEY_TYPE>::GetElements() const +{ + return _elements; +} + #endif diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h index d9d13e562bf..32a81b968fb 100644 --- a/src/server/game/Grids/GridDefines.h +++ b/src/server/game/Grids/GridDefines.h @@ -89,6 +89,12 @@ enum GridMapTypeMask GRID_MAP_TYPE_MASK_ALL = 0xFF }; +extern template class Grid<Player, AllWorldObjectTypes, AllGridObjectTypes>; +extern template class NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes>; + +extern template class TypeMapContainer<AllGridObjectTypes>; +extern template class TypeMapContainer<AllWorldObjectTypes>; + typedef Grid<Player, AllWorldObjectTypes, AllGridObjectTypes> GridType; typedef NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes> NGridType; diff --git a/src/server/game/Grids/NGrid.cpp b/src/server/game/Grids/NGrid.cpp index 2e7c7890c9d..b9530c684a2 100644 --- a/src/server/game/Grids/NGrid.cpp +++ b/src/server/game/Grids/NGrid.cpp @@ -16,6 +16,7 @@ */ #include "NGrid.h" +#include "GridDefines.h" #include "Random.h" GridInfo::GridInfo() : i_timer(0), vis_Update(0, irand(0, DEFAULT_VISIBILITY_NOTIFY_PERIOD)), @@ -27,3 +28,9 @@ GridInfo::GridInfo(time_t expiry, bool unload /*= true */) : i_timer(expiry), vi i_unloadActiveLockCount(0), i_unloadExplicitLock(!unload) { } + +template class Grid<Player, AllWorldObjectTypes, AllGridObjectTypes>; +template class NGrid<MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes>; + +template class TC_GAME_API TypeMapContainer<AllGridObjectTypes>; +template class TC_GAME_API TypeMapContainer<AllWorldObjectTypes>; |