diff --git a/src/framework/GameSystem/Grid.h b/src/framework/GameSystem/Grid.h index c03361f55..bfd7934f9 100644 --- a/src/framework/GameSystem/Grid.h +++ b/src/framework/GameSystem/Grid.h @@ -58,23 +58,18 @@ class MANGOS_DLL_DECL Grid /** an object of interested enters the grid */ - template bool AddWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template bool AddWorldObject(SPECIFIC_OBJECT *obj) { - return i_objects.template insert(hdl, obj); + return i_objects.template insert(obj); } /** an object of interested exits the grid */ - template bool RemoveWorldObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template bool RemoveWorldObject(SPECIFIC_OBJECT *obj) { - return i_objects.template remove(obj, hdl); + return i_objects.template remove(obj); } - /** Accessors: Returns a specific type of object in the WORDL_OBJECT_TYPES - */ - template const SPECIFIC_OBJECT* GetWorldObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT* fake) const { return i_objects.template find(hdl); } - template SPECIFIC_OBJECT* GetWorldObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake) { return i_objects.template find(hdl, fake); } - /** Refreshes/update the grid. This required for remote grids. */ void RefreshGrid(void) { /* TBI */} @@ -105,27 +100,22 @@ class MANGOS_DLL_DECL Grid */ unsigned int ActiveObjectsInGrid(void) const { return m_activeGridObjects.size()+i_objects.template Count(); } - /** Accessors: Returns a specific type of object in the GRID_OBJECT_TYPES - */ - template const SPECIFIC_OBJECT* GetGridObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake) const { return i_container.template find(hdl, fake); } - template SPECIFIC_OBJECT* GetGridObject(OBJECT_HANDLE hdl, SPECIFIC_OBJECT *fake) { return i_container.template find(hdl, fake); } - /** Inserts a container type object into the grid. */ - template bool AddGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template bool AddGridObject(SPECIFIC_OBJECT *obj) { if(obj->isActiveObject()) m_activeGridObjects.insert(obj); - return i_container.template insert(hdl, obj); + return i_container.template insert(obj); } /** Removes a containter type object from the grid */ - template bool RemoveGridObject(SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template bool RemoveGridObject(SPECIFIC_OBJECT *obj) { if(obj->isActiveObject()) m_activeGridObjects.erase(obj); - return i_container.template remove(obj, hdl); + return i_container.template remove(obj); } private: diff --git a/src/framework/GameSystem/NGrid.h b/src/framework/GameSystem/NGrid.h index 97eda7962..d19b495f1 100644 --- a/src/framework/GameSystem/NGrid.h +++ b/src/framework/GameSystem/NGrid.h @@ -117,14 +117,14 @@ class MANGOS_DLL_DECL NGrid void ResetTimeTracker(time_t interval) { i_GridInfo.ResetTimeTracker(interval); } void UpdateTimeTracker(time_t diff) { i_GridInfo.UpdateTimeTracker(diff); } - template void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template void AddWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - getGridType(x, y).AddWorldObject(obj, hdl); + getGridType(x, y).AddWorldObject(obj); } - template void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) + template void RemoveWorldObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - getGridType(x, y).RemoveWorldObject(obj, hdl); + getGridType(x, y).RemoveWorldObject(obj); } template void Visit(TypeContainerVisitor > &visitor) @@ -148,24 +148,14 @@ class MANGOS_DLL_DECL NGrid return count; } - template const SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl) const + template bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - return getGridType(x, y).template GetGridObject(hdl); + return getGridType(x, y).AddGridObject(obj); } - template SPECIFIC_OBJECT* GetGridObject(const uint32 x, const uint32 y, OBJECT_HANDLE hdl) + template bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj) { - return getGridType(x, y).template GetGridObject(hdl); - } - - template bool AddGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) - { - return getGridType(x, y).AddGridObject(hdl, obj); - } - - template bool RemoveGridObject(const uint32 x, const uint32 y, SPECIFIC_OBJECT *obj, OBJECT_HANDLE hdl) - { - return getGridType(x, y).RemoveGridObject(obj, hdl); + return getGridType(x, y).RemoveGridObject(obj); } private: diff --git a/src/framework/GameSystem/TypeContainer.h b/src/framework/GameSystem/TypeContainer.h index 313f84af0..8b7bcdea7 100644 --- a/src/framework/GameSystem/TypeContainer.h +++ b/src/framework/GameSystem/TypeContainer.h @@ -143,7 +143,6 @@ class TypeUnorderedMapContainer */ template struct ContainerMapList { - //std::map _element; GridRefManager _element; }; @@ -156,40 +155,6 @@ template struct ContainerMapList > ContainerMapList _TailElements; }; -/* - * @class ContaierArrayList is a multi-type container for - * array of elements. - */ -template struct ContainerArrayList -{ - std::vector _element; -}; - -// termination condition -template<> struct ContainerArrayList {}; -// recursion -template struct ContainerArrayList > -{ - ContainerArrayList _elements; - ContainerArrayList _TailElements; -}; - -/* - * @class ContainerList is a simple list of different types of elements - * - */ -template struct ContainerList -{ - OBJECT _element; -}; - -/* TypeNull is underfined */ -template<> struct ContainerList {}; -template struct ContainerList > -{ - ContainerList _elements; - ContainerMapList _TailElements; -}; #include "TypeContainerFunctions.h" @@ -206,22 +171,17 @@ class MANGOS_DLL_DECL TypeMapContainer public: template size_t Count() const { return MaNGOS::Count(i_elements, (SPECIFIC_TYPE*)NULL); } - template SPECIFIC_TYPE* find(OBJECT_HANDLE hdl, SPECIFIC_TYPE *fake) { return MaNGOS::Find(i_elements, hdl,fake); } - - /// find a specific type of object in the container - template const SPECIFIC_TYPE* find(OBJECT_HANDLE hdl, SPECIFIC_TYPE *fake) const { return MaNGOS::Find(i_elements, hdl,fake); } - /// inserts a specific object into the container - template bool insert(OBJECT_HANDLE hdl, SPECIFIC_TYPE *obj) + template bool insert(SPECIFIC_TYPE *obj) { - SPECIFIC_TYPE* t = MaNGOS::Insert(i_elements, obj, hdl); + SPECIFIC_TYPE* t = MaNGOS::Insert(i_elements, obj); return (t != NULL); } /// Removes the object from the container, and returns the removed object - template bool remove(SPECIFIC_TYPE* obj, OBJECT_HANDLE hdl) + template bool remove(SPECIFIC_TYPE* obj) { - SPECIFIC_TYPE* t = MaNGOS::Remove(i_elements, obj, hdl); + SPECIFIC_TYPE* t = MaNGOS::Remove(i_elements, obj); return (t != NULL); } diff --git a/src/framework/GameSystem/TypeContainerFunctions.h b/src/framework/GameSystem/TypeContainerFunctions.h index 29d386435..35a9170ec 100644 --- a/src/framework/GameSystem/TypeContainerFunctions.h +++ b/src/framework/GameSystem/TypeContainerFunctions.h @@ -58,114 +58,55 @@ namespace MaNGOS return Count(elements._TailElements, fake); } - // non-const find functions - template SPECIFIC_TYPE* Find(ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) - { - //typename std::map::iterator iter = elements._element.find(hdl); - //return (iter == elements._element.end() ? NULL : iter->second); - return NULL; - }; - - template SPECIFIC_TYPE* Find(ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) - { - return NULL; // terminate recursion - } - - template SPECIFIC_TYPE* Find(ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) - { - return NULL; // this is a missed - } - - template SPECIFIC_TYPE* Find(ContainerMapList >&/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) - { - //SPECIFIC_TYPE* t = Find(elements._elements, hdl,fake); - //return (t != NULL ? t :Find(elements._TailElements, hdl,fake)); - return NULL; - } - - // const find functions - template const SPECIFIC_TYPE* Find(const ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) - { - //typename SPECIFIC_TYPE::iterator iter = elements._element.find(hdl); - //return (iter == elements._element.end() ? NULL : iter->second); - return NULL; - }; - - template const SPECIFIC_TYPE* Find(const ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) - { - return NULL; - } - - template const SPECIFIC_TYPE* Find(const ContainerMapList &/*elements*/, OBJECT_HANDLE /*hdl*/, SPECIFIC_TYPE* /*fake*/) - { - return NULL; - } - - template SPECIFIC_TYPE* Find(const ContainerMapList >&elements, OBJECT_HANDLE hdl, SPECIFIC_TYPE* fake) - { - SPECIFIC_TYPE* t = Find(elements._elements, hdl,fake); - if( t) - return t; - - return Find(elements._TailElement, hdl,fake); - } - // non-const insert functions - template SPECIFIC_TYPE* Insert(ContainerMapList &elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE /*hdl*/) + template SPECIFIC_TYPE* Insert(ContainerMapList &elements, SPECIFIC_TYPE *obj) { //elements._element[hdl] = obj; obj->GetGridRef().link(&elements._element, obj); return obj; }; - template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) + template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; } // this is a missed - template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) + template SPECIFIC_TYPE* Insert(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; // a missed } // Recursion - template SPECIFIC_TYPE* Insert(ContainerMapList >&elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE hdl) + template SPECIFIC_TYPE* Insert(ContainerMapList >&elements, SPECIFIC_TYPE *obj) { - SPECIFIC_TYPE* t= Insert(elements._elements, obj, hdl); - return (t != NULL ? t : Insert(elements._TailElements, obj, hdl)); + SPECIFIC_TYPE* t= Insert(elements._elements, obj); + return (t != NULL ? t : Insert(elements._TailElements, obj)); } // non-const remove method - template SPECIFIC_TYPE* Remove(ContainerMapList & /*elements*/, SPECIFIC_TYPE *obj, OBJECT_HANDLE /*hdl*/) + template SPECIFIC_TYPE* Remove(ContainerMapList & /*elements*/, SPECIFIC_TYPE *obj) { - /*typename std::map::iterator iter = elements._element.find(hdl); - if( iter != elements._element.end() ) - { - SPECIFIC_TYPE* t = iter->second; - elements._element.erase(iter); - return t; - }*/ obj->GetGridRef().unlink(); return obj; } - template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) + template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; } // this is a missed - template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/, OBJECT_HANDLE /*hdl*/) + template SPECIFIC_TYPE* Remove(ContainerMapList &/*elements*/, SPECIFIC_TYPE * /*obj*/) { return NULL; // a missed } - template SPECIFIC_TYPE* Remove(ContainerMapList > &elements, SPECIFIC_TYPE *obj, OBJECT_HANDLE hdl) + template SPECIFIC_TYPE* Remove(ContainerMapList > &elements, SPECIFIC_TYPE *obj) { // The head element is bad - SPECIFIC_TYPE* t = Remove(elements._elements, obj, hdl); - return ( t != NULL ? t : Remove(elements._TailElements, obj, hdl) ); + SPECIFIC_TYPE* t = Remove(elements._elements, obj); + return ( t != NULL ? t : Remove(elements._TailElements, obj) ); } } diff --git a/src/framework/GameSystem/TypeContainerVisitor.h b/src/framework/GameSystem/TypeContainerVisitor.h index 516ecedf2..346eb393e 100644 --- a/src/framework/GameSystem/TypeContainerVisitor.h +++ b/src/framework/GameSystem/TypeContainerVisitor.h @@ -21,7 +21,7 @@ /* * @class TypeContainerVisitor is implemented as a visitor pattern. It is - * a visitor to the TypeContainerList or TypeContainerMapList. The visitor has + * a visitor to the TypeMapContainer or ContainerMapList. The visitor has * to overload its types as a visit method is called. */ @@ -37,23 +37,6 @@ template void VisitorHelper(VISITOR &v, TYP v.Visit(c); }; -// terminate condition for container list -template void VisitorHelper(VISITOR &v, ContainerList &c) -{ -} - -template void VisitorHelper(VISITOR &v, ContainerList &c) -{ - v.Visit(c._element); -} - -// recursion for container list -template void VisitorHelper(VISITOR &v, ContainerList > &c) -{ - VisitorHelper(v, c._elements); - VisitorHelper(v, c._TailElements); -} - // terminate condition container map list template void VisitorHelper(VISITOR &/*v*/, ContainerMapList &/*c*/) { @@ -71,23 +54,6 @@ template void VisitorHelper(VISITOR &v, Contain VisitorHelper(v, c._TailElements); } -// array list -template void VisitorHelper(VISITOR &v, ContainerArrayList &c) -{ - v.Visit(c._element); -} - -template void VisitorHelper(VISITOR &/*v*/, ContainerArrayList &/*c*/) -{ -} - -// recursion -template void VisitorHelper(VISITOR &v, ContainerArrayList > &c) -{ - VisitorHelper(v, c._elements); - VisitorHelper(v, c._TailElements); -} - // for TypeMapContainer template void VisitorHelper(VISITOR &v, TypeMapContainer &c) { diff --git a/src/game/GridNotifiers.h b/src/game/GridNotifiers.h index 5c132e624..d3586a374 100644 --- a/src/game/GridNotifiers.h +++ b/src/game/GridNotifiers.h @@ -141,33 +141,6 @@ namespace MaNGOS void Visit(CreatureMapType &); }; - template - struct MANGOS_DLL_DECL ObjectAccessorNotifier - { - T *& i_object; - - uint64 i_id; - ObjectAccessorNotifier(T * &obj, uint64 id) : i_object(obj), i_id(id) - { - i_object = NULL; - } - - void Visit(GridRefManager &m ) - { - if( i_object == NULL ) - { - GridRefManager *iter = m.find(i_id); - if( iter != m.end() ) - { - assert( iter->second != NULL ); - i_object = iter->second; - } - } - } - - template void Visit(GridRefManager &) {} - }; - struct MANGOS_DLL_DECL PlayerRelocationNotifier { Player &i_player; diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 2ec80c8f5..47eae2804 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -234,13 +234,13 @@ void Map::InitVisibilityDistance() template void Map::AddToGrid(T* obj, NGridType *grid, Cell const& cell) { - (*grid)(cell.CellX(), cell.CellY()).template AddGridObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).template AddGridObject(obj); } template<> void Map::AddToGrid(Player* obj, NGridType *grid, Cell const& cell) { - (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); } template<> @@ -249,12 +249,12 @@ void Map::AddToGrid(Corpse *obj, NGridType *grid, Cell const& cell) // add to world object registry in grid if(obj->GetType()!=CORPSE_BONES) { - (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); } // add to grid object store else { - (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj); } } @@ -264,13 +264,13 @@ void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) // add to world object registry in grid if(obj->isPet() || obj->isVehicle()) { - (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).AddWorldObject(obj); obj->SetCurrentCell(cell); } // add to grid object store else { - (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).AddGridObject(obj); obj->SetCurrentCell(cell); } } @@ -278,13 +278,13 @@ void Map::AddToGrid(Creature* obj, NGridType *grid, Cell const& cell) template void Map::RemoveFromGrid(T* obj, NGridType *grid, Cell const& cell) { - (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).template RemoveGridObject(obj); } template<> void Map::RemoveFromGrid(Player* obj, NGridType *grid, Cell const& cell) { - (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj); } template<> @@ -293,12 +293,12 @@ void Map::RemoveFromGrid(Corpse *obj, NGridType *grid, Cell const& cell) // remove from world object registry in grid if(obj->GetType()!=CORPSE_BONES) { - (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj); } // remove from grid object store else { - (*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj); } } @@ -308,12 +308,12 @@ void Map::RemoveFromGrid(Creature* obj, NGridType *grid, Cell const& cell) // remove from world object registry in grid if(obj->isPet() || obj->isVehicle()) { - (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).RemoveWorldObject(obj); } // remove from grid object store else { - (*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj, obj->GetGUID()); + (*grid)(cell.CellX(), cell.CellY()).RemoveGridObject(obj); } } diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index af35512e4..864b01c15 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -223,12 +223,12 @@ ObjectAccessor::AddCorpsesToGrid(GridPair const& gridpair,GridType& grid,Map* ma { if (iter->second->GetInstanceId() == map->GetInstanceId()) { - grid.AddWorldObject(iter->second, iter->second->GetGUID()); + grid.AddWorldObject(iter->second); } } else { - grid.AddWorldObject(iter->second, iter->second->GetGUID()); + grid.AddWorldObject(iter->second); } } } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index af2593a0e..1ba847847 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9306" + #define REVISION_NR "9307" #endif // __REVISION_NR_H__