AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
ObjectGridLoader Class Reference

#include "ObjectGridLoader.h"

Public Member Functions

 ObjectGridLoader (NGridType &grid, Map *map, const Cell &cell)
 
void Visit (GameObjectMapType &m)
 
void Visit (CreatureMapType &m)
 
void Visit (CorpseMapType &) const
 
void Visit (DynamicObjectMapType &) const
 
void LoadN (void)
 
template<>
void SetObjectCell (Creature *obj, CellCoord const &cellCoord)
 
template<>
void SetObjectCell (GameObject *obj, CellCoord const &cellCoord)
 

Static Public Member Functions

template<class T >
static void SetObjectCell (T *obj, CellCoord const &cellCoord)
 

Private Attributes

Cell i_cell
 
NGridTypei_grid
 
Mapi_map
 
uint32 i_gameObjects
 
uint32 i_creatures
 
uint32 i_corpses
 

Friends

class ObjectWorldLoader
 

Detailed Description

Constructor & Destructor Documentation

◆ ObjectGridLoader()

ObjectGridLoader::ObjectGridLoader ( NGridType grid,
Map map,
const Cell cell 
)
inline
35 : i_cell(cell), i_grid(grid), i_map(map), i_gameObjects(0), i_creatures(0), i_corpses (0)
36 {}
Cell i_cell
Definition: ObjectGridLoader.h:48
uint32 i_creatures
Definition: ObjectGridLoader.h:52
Map * i_map
Definition: ObjectGridLoader.h:50
uint32 i_corpses
Definition: ObjectGridLoader.h:53
uint32 i_gameObjects
Definition: ObjectGridLoader.h:51
NGridType & i_grid
Definition: ObjectGridLoader.h:49

Member Function Documentation

◆ LoadN()

void ObjectGridLoader::LoadN ( void  )
170{
171 i_gameObjects = 0;
172 i_creatures = 0;
173 i_corpses = 0;
175 for (uint32 x = 0; x < MAX_NUMBER_OF_CELLS; ++x)
176 {
178 for (uint32 y = 0; y < MAX_NUMBER_OF_CELLS; ++y)
179 {
181
182 //Load creatures and game objects
183 {
185 i_grid.VisitGrid(x, y, visitor);
186 }
187
188 //Load corpses (not bones)
189 {
190 ObjectWorldLoader worker(*this);
192 i_grid.VisitGrid(x, y, visitor);
193 }
194 }
195 }
196 LOG_DEBUG("maps", "{} GameObjects, {} Creatures, and {} Corpses/Bones loaded for grid {} on map {}", i_gameObjects, i_creatures, i_corpses, i_grid.GetGridId(), i_map->GetId());
197}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
#define MAX_NUMBER_OF_CELLS
Definition: GridDefines.h:35
Definition: TypeContainerVisitor.h:85
struct Cell::@277::@278 Part
unsigned cell_y
Definition: Cell.h:99
unsigned cell_x
Definition: Cell.h:98
union Cell::@277 data
uint32 GetGridId() const
Definition: NGrid.h:57
void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition: NGrid.h:101
Definition: ObjectGridLoader.cpp:32
uint32 GetId() const
Definition: Map.h:378

References Cell::cell_x, Cell::cell_y, Cell::data, NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::GetGridId(), Map::GetId(), i_cell, i_corpses, i_creatures, i_gameObjects, i_grid, i_map, LOG_DEBUG, MAX_NUMBER_OF_CELLS, Cell::Part, and NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::VisitGrid().

Referenced by Map::EnsureGridLoaded().

◆ SetObjectCell() [1/3]

template<>
void ObjectGridLoader::SetObjectCell ( Creature obj,
CellCoord const &  cellCoord 
)
55{
56 Cell cell(cellCoord);
57 obj->SetCurrentCell(cell);
58}
void SetCurrentCell(Cell const &cell)
Definition: Object.h:386
Definition: Cell.h:46

References MovableMapObject::SetCurrentCell().

◆ SetObjectCell() [2/3]

template<>
void ObjectGridLoader::SetObjectCell ( GameObject obj,
CellCoord const &  cellCoord 
)
61{
62 Cell cell(cellCoord);
63 obj->SetCurrentCell(cell);
64}

References MovableMapObject::SetCurrentCell().

◆ SetObjectCell() [3/3]

template<class T >
void ObjectGridLoader::SetObjectCell ( T *  obj,
CellCoord const &  cellCoord 
)
static
51{
52}

Referenced by AddObjectHelper().

◆ Visit() [1/4]

void ObjectGridLoader::Visit ( CorpseMapType ) const
inline
40{}

◆ Visit() [2/4]

void ObjectGridLoader::Visit ( CreatureMapType m)
144{
145 CellCoord cellCoord = i_cell.GetCellCoord();
146 CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cellCoord.GetId());
147 LoadHelper(cell_guids.creatures, cellCoord, m, i_creatures, i_map);
148}
#define sObjectMgr
Definition: ObjectMgr.h:1640
void LoadHelper(CellGuidSet const &guid_set, CellCoord &cell, GridRefMgr< T > &m, uint32 &count, Map *map)
Definition: ObjectGridLoader.cpp:100
Definition: ObjectMgr.h:479
CellGuidSet creatures
Definition: ObjectMgr.h:480
CellCoord GetCellCoord() const
Definition: Cell.h:77
uint32 GetId() const
Definition: GridDefines.h:148
uint8 GetSpawnMode() const
Definition: Map.h:419

References CellObjectGuids::creatures, Cell::GetCellCoord(), CoordPair< LIMIT >::GetId(), Map::GetId(), Map::GetSpawnMode(), i_cell, i_creatures, i_map, LoadHelper(), and sObjectMgr.

◆ Visit() [3/4]

void ObjectGridLoader::Visit ( DynamicObjectMapType ) const
inline
41{}

◆ Visit() [4/4]

void ObjectGridLoader::Visit ( GameObjectMapType m)
137{
138 CellCoord cellCoord = i_cell.GetCellCoord();
139 CellObjectGuids const& cell_guids = sObjectMgr->GetCellObjectGuids(i_map->GetId(), i_map->GetSpawnMode(), cellCoord.GetId());
140 LoadHelper(cell_guids.gameobjects, cellCoord, m, i_gameObjects, i_map);
141}
CellGuidSet gameobjects
Definition: ObjectMgr.h:481

References CellObjectGuids::gameobjects, Cell::GetCellCoord(), CoordPair< LIMIT >::GetId(), Map::GetId(), Map::GetSpawnMode(), i_cell, i_gameObjects, i_map, LoadHelper(), and sObjectMgr.

Friends And Related Function Documentation

◆ ObjectWorldLoader

friend class ObjectWorldLoader
friend

Member Data Documentation

◆ i_cell

Cell ObjectGridLoader::i_cell
private

Referenced by LoadN(), and Visit().

◆ i_corpses

uint32 ObjectGridLoader::i_corpses
private

Referenced by LoadN().

◆ i_creatures

uint32 ObjectGridLoader::i_creatures
private

Referenced by LoadN(), and Visit().

◆ i_gameObjects

uint32 ObjectGridLoader::i_gameObjects
private

Referenced by LoadN(), and Visit().

◆ i_grid

NGridType& ObjectGridLoader::i_grid
private

Referenced by LoadN().

◆ i_map

Map* ObjectGridLoader::i_map
private

Referenced by LoadN(), and Visit().