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

#include "MapGridManager.h"

Public Member Functions

 MapGridManager (Map *map)
 
void CreateGrid (uint16 const x, uint16 const y)
 
bool LoadGrid (uint16 const x, uint16 const y)
 
void UnloadGrid (uint16 const x, uint16 const y)
 
bool IsGridCreated (uint16 const x, uint16 const y) const
 
bool IsGridLoaded (uint16 const x, uint16 const y) const
 
MapGridTypeGetGrid (uint16 const x, uint16 const y)
 
uint32 GetCreatedGridsCount ()
 
uint32 GetLoadedGridsCount ()
 
uint32 GetCreatedCellsInGridCount (uint16 const x, uint16 const y)
 
uint32 GetCreatedCellsInMapCount ()
 
bool IsGridsFullyCreated () const
 
bool IsGridsFullyLoaded () const
 

Static Public Member Functions

static bool IsValidGridCoordinates (uint16 const x, uint16 const y)
 

Private Attributes

Map_map
 
uint32 _createdGridsCount
 
uint32 _loadedGridsCount
 
std::mutex _gridLock
 
std::unique_ptr< MapGridType_mapGrid [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 

Detailed Description

Constructor & Destructor Documentation

◆ MapGridManager()

MapGridManager::MapGridManager ( Map map)
inline
Map * _map
Definition MapGridManager.h:53
uint32 _loadedGridsCount
Definition MapGridManager.h:56
uint32 _createdGridsCount
Definition MapGridManager.h:55

Member Function Documentation

◆ CreateGrid()

void MapGridManager::CreateGrid ( uint16 const  x,
uint16 const  y 
)
6{
7 std::lock_guard<std::mutex> guard(_gridLock);
8 if (IsGridCreated(x, y))
9 return;
10
11 std::unique_ptr<MapGridType> grid = std::make_unique<MapGridType>(x, y);
12 grid->link(_map);
13
14 GridTerrainLoader loader(*grid, _map);
15 loader.LoadTerrain();
16
17 _mapGrid[x][y] = std::move(grid);
18
20}
Definition GridTerrainLoader.h:24
bool IsGridCreated(uint16 const x, uint16 const y) const
Definition MapGridManager.cpp:64
std::mutex _gridLock
Definition MapGridManager.h:58
std::unique_ptr< MapGridType > _mapGrid[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition MapGridManager.h:59

References _createdGridsCount, _gridLock, _map, _mapGrid, IsGridCreated(), and GridTerrainLoader::LoadTerrain().

Referenced by Map::EnsureGridCreated().

◆ GetCreatedCellsInGridCount()

uint32 MapGridManager::GetCreatedCellsInGridCount ( uint16 const  x,
uint16 const  y 
)
99{
100 MapGridType* grid = GetGrid(x, y);
101 if (grid)
102 return grid->GetCreatedCellsCount();
103
104 return 0;
105}
MapGridType * GetGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:80
Definition MapGrid.h:32
uint32 GetCreatedCellsCount()
Definition MapGrid.h:104

References MapGrid< WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::GetCreatedCellsCount(), and GetGrid().

Referenced by Map::GetCreatedCellsInGridCount().

◆ GetCreatedCellsInMapCount()

uint32 MapGridManager::GetCreatedCellsInMapCount ( )
108{
109 uint32 count = 0;
110 for (uint32 gridX = 0; gridX < MAX_NUMBER_OF_GRIDS; ++gridX)
111 {
112 for (uint32 gridY = 0; gridY < MAX_NUMBER_OF_GRIDS; ++gridY)
113 {
114 if (MapGridType* grid = GetGrid(gridX, gridY))
115 count += grid->GetCreatedCellsCount();
116 }
117 }
118 return count;
119}
std::uint32_t uint32
Definition Define.h:107
#define MAX_NUMBER_OF_GRIDS
Definition MapDefines.h:24

References GetGrid(), and MAX_NUMBER_OF_GRIDS.

Referenced by Map::GetCreatedCellsInMapCount().

◆ GetCreatedGridsCount()

uint32 MapGridManager::GetCreatedGridsCount ( )
89{
90 return _createdGridsCount;
91}

References _createdGridsCount.

Referenced by Map::GetCreatedGridsCount().

◆ GetGrid()

MapGridType * MapGridManager::GetGrid ( uint16 const  x,
uint16 const  y 
)
81{
83 return nullptr;
84
85 return _mapGrid[x][y].get();
86}
static bool IsValidGridCoordinates(uint16 const x, uint16 const y)
Definition MapGridManager.h:42

References _mapGrid, and IsValidGridCoordinates().

Referenced by GetCreatedCellsInGridCount(), GetCreatedCellsInMapCount(), Map::GetGridTerrainData(), Map::GetGridTerrainDataSharedPtr(), Map::GetMapGrid(), LoadGrid(), and UnloadGrid().

◆ GetLoadedGridsCount()

uint32 MapGridManager::GetLoadedGridsCount ( )
94{
95 return _loadedGridsCount;
96}

References _loadedGridsCount.

Referenced by Map::GetLoadedGridsCount().

◆ IsGridCreated()

bool MapGridManager::IsGridCreated ( uint16 const  x,
uint16 const  y 
) const
65{
67 return false;
68
69 return _mapGrid[x][y].get();
70}

References _mapGrid, and IsValidGridCoordinates().

Referenced by CreateGrid(), and Map::IsGridCreated().

◆ IsGridLoaded()

bool MapGridManager::IsGridLoaded ( uint16 const  x,
uint16 const  y 
) const
73{
75 return false;
76
77 return _mapGrid[x][y].get() && _mapGrid[x][y]->IsObjectDataLoaded();
78}

References _mapGrid, and IsValidGridCoordinates().

Referenced by Map::IsGridLoaded().

◆ IsGridsFullyCreated()

bool MapGridManager::IsGridsFullyCreated ( ) const

◆ IsGridsFullyLoaded()

bool MapGridManager::IsGridsFullyLoaded ( ) const

◆ IsValidGridCoordinates()

static bool MapGridManager::IsValidGridCoordinates ( uint16 const  x,
uint16 const  y 
)
inlinestatic

◆ LoadGrid()

bool MapGridManager::LoadGrid ( uint16 const  x,
uint16 const  y 
)
23{
24 MapGridType* grid = GetGrid(x, y);
25 if (!grid || grid->IsObjectDataLoaded())
26 return false;
27
28 // Must mark as loaded first, as GridObjectLoader spawning objects can attempt to recursively load the grid
29 grid->SetObjectDataLoaded();
30
31 GridObjectLoader loader(*grid, _map);
32 loader.LoadAllCellsInGrid();
33
35 return true;
36}
Definition GridObjectLoader.h:27
void SetObjectDataLoaded()
Definition MapGrid.h:46
bool IsObjectDataLoaded() const
Definition MapGrid.h:45

References _loadedGridsCount, _map, GetGrid(), MapGrid< WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::IsObjectDataLoaded(), GridObjectLoader::LoadAllCellsInGrid(), and MapGrid< WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::SetObjectDataLoaded().

Referenced by Map::EnsureGridLoaded().

◆ UnloadGrid()

void MapGridManager::UnloadGrid ( uint16 const  x,
uint16 const  y 
)
39{
40 MapGridType* grid = GetGrid(x, y);
41 if (!grid)
42 return;
43
44 {
45 GridObjectCleaner worker;
47 grid->VisitAllCells(visitor);
48 }
49
51
52 {
53 GridObjectUnloader worker;
55 grid->VisitAllCells(visitor);
56 }
57
58 GridTerrainUnloader terrainUnloader(*grid, _map);
59 terrainUnloader.UnloadTerrain();
60
61 _mapGrid[x][y] = nullptr;
62}
Definition GridObjectLoader.h:47
Definition GridObjectLoader.h:54
Definition GridTerrainLoader.h:44
void VisitAllCells(TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition MapGrid.h:70
void RemoveAllObjectsInRemoveList()
Definition Map.cpp:1860
Definition TypeContainerVisitor.h:84

References _map, _mapGrid, GetGrid(), Map::RemoveAllObjectsInRemoveList(), GridTerrainUnloader::UnloadTerrain(), and MapGrid< WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::VisitAllCells().

Referenced by Map::UnloadGrid().

Member Data Documentation

◆ _createdGridsCount

uint32 MapGridManager::_createdGridsCount
private

◆ _gridLock

std::mutex MapGridManager::_gridLock
private

Referenced by CreateGrid().

◆ _loadedGridsCount

uint32 MapGridManager::_loadedGridsCount
private

◆ _map

Map* MapGridManager::_map
private

Referenced by CreateGrid(), LoadGrid(), and UnloadGrid().

◆ _mapGrid

std::unique_ptr<MapGridType> MapGridManager::_mapGrid[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
private

The documentation for this class was generated from the following files: