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

#include "GridObjectLoader.h"

Public Member Functions

 GridObjectLoader (MapGridType &grid, Map *map)
 
void LoadAllCellsInGrid ()
 

Private Member Functions

template<class T >
void AddObjectHelper (Map *map, T *obj)
 
void LoadCreatures (CellGuidSet const &guid_set, Map *map)
 
void LoadGameObjects (CellGuidSet const &guid_set, Map *map)
 

Private Attributes

MapGridType_grid
 
Map_map
 

Detailed Description

Constructor & Destructor Documentation

◆ GridObjectLoader()

GridObjectLoader::GridObjectLoader ( MapGridType grid,
Map map 
)
inline
30 : _grid(grid), _map(map) { }
Map * _map
Definition GridObjectLoader.h:42
MapGridType & _grid
Definition GridObjectLoader.h:41

Member Function Documentation

◆ AddObjectHelper()

template<class T >
void GridObjectLoader::AddObjectHelper ( Map map,
T *  obj 
)
private
32{
33 CellCoord cellCoord = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
34 Cell cell(cellCoord);
35
36 map->AddToGrid<T>(obj, cell);
37 obj->AddToWorld();
38}
void AddToGrid(T *object, Cell const &cell)
Definition Map.cpp:116
CellCoord ComputeCellCoord(float x, float y)
Definition GridDefines.h:197
Definition Cell.h:45

References Map::AddToGrid(), and Acore::ComputeCellCoord().

◆ LoadAllCellsInGrid()

void GridObjectLoader::LoadAllCellsInGrid ( )
117{
118 CellObjectGuids const& cell_guids = sObjectMgr->GetGridObjectGuids(_map->GetId(), _map->GetSpawnMode(), _grid.GetId());
119 LoadGameObjects(cell_guids.gameobjects, _map);
120 LoadCreatures(cell_guids.creatures, _map);
121
122 if (std::unordered_set<Corpse*> const* corpses = _map->GetCorpsesInGrid(_grid.GetId()))
123 {
124 for (Corpse* corpse : *corpses)
125 {
126 if (corpse->IsInGrid())
127 continue;
128
129 AddObjectHelper<Corpse>(_map, corpse);
130 }
131 }
132}
#define sObjectMgr
Definition ObjectMgr.h:1730
Definition Corpse.h:49
void LoadCreatures(CellGuidSet const &guid_set, Map *map)
Definition GridObjectLoader.cpp:40
void LoadGameObjects(CellGuidSet const &guid_set, Map *map)
Definition GridObjectLoader.cpp:78
uint32 GetId() const
Definition MapGrid.h:41
std::unordered_set< Corpse * > const * GetCorpsesInGrid(uint32 gridId) const
Definition Map.h:366
uint8 GetSpawnMode() const
Definition Map.h:271
uint32 GetId() const
Definition Map.h:234
Definition ObjectMgr.h:481
CellGuidSet gameobjects
Definition ObjectMgr.h:483
CellGuidSet creatures
Definition ObjectMgr.h:482

References _grid, _map, CellObjectGuids::creatures, CellObjectGuids::gameobjects, Map::GetCorpsesInGrid(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::GetId(), Map::GetId(), Map::GetSpawnMode(), LoadCreatures(), LoadGameObjects(), and sObjectMgr.

Referenced by MapGridManager::LoadGrid().

◆ LoadCreatures()

void GridObjectLoader::LoadCreatures ( CellGuidSet const &  guid_set,
Map map 
)
private
41{
42 for (ObjectGuid::LowType const& guid : guid_set)
43 {
44 // Skip spawns whose spawn group is not active on this map
45 CreatureData const* cData = sObjectMgr->GetCreatureData(guid);
46 if (cData && !map->IsSpawnGroupActive(cData->spawnGroupId))
47 continue;
48
49 // Skip pool members this map's pool state has not rolled as spawned
50 if (cData && cData->poolId && !map->GetPoolData().IsSpawnedObject<Creature>(guid))
51 continue;
52
53 Creature* obj = new Creature();
54 if (!obj->LoadFromDB(guid, map))
55 {
56 delete obj;
57 continue;
58 }
59
60 AddObjectHelper<Creature>(map, obj);
61
62 // Grid load bypasses Map::AddToMap, so seat accessories here.
63 if (Vehicle* vehicle = obj->GetVehicleKit())
64 vehicle->Reset();
65
67 {
69 {
70 // call MoveInLineOfSight for nearby grid creatures
71 Acore::AIRelocationNotifier notifier(*obj);
72 Cell::VisitObjects(obj, notifier, 60.f);
73 }
74 }
75 }
76}
@ IDLE_MOTION_TYPE
Definition MotionMaster.h:39
@ NOTIFY_AI_RELOCATION
Definition Object.h:70
@ NOTIFY_VISIBILITY_CHANGED
Definition Object.h:71
@ UNIT_STATE_SIGHTLESS
Definition UnitDefines.h:220
@ REACT_AGGRESSIVE
Definition Unit.h:569
Definition Creature.h:47
bool HasReactState(ReactStates state) const
Definition Creature.h:102
bool IsMoveInLineOfSightDisabled()
Definition Creature.h:282
MovementGeneratorType GetDefaultMovementType() const override
-------—End of Pet responses methods-------—
Definition Creature.h:91
bool LoadFromDB(ObjectGuid::LowType guid, Map *map, bool allowDuplicate=false)
Definition Creature.h:223
bool IsSpawnGroupActive(uint32 groupId) const
Definition Map.cpp:2596
SpawnedPoolData & GetPoolData()
Definition Map.h:384
uint32 LowType
Definition ObjectGuid.h:125
bool IsSpawnedObject(uint32 db_guid_or_pool_id) const
bool IsAlive() const
Definition Unit.h:1793
bool IsImmuneToNPC() const
Definition Unit.h:930
bool HasUnitState(const uint32 f) const
Definition Unit.h:737
Vehicle * GetVehicleKit() const
Definition Unit.h:1925
Definition Vehicle.h:28
bool isNeedNotify(uint16 f) const
Definition Object.h:671
Definition GridNotifiers.h:91
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165
Definition CreatureData.h:370
uint32 spawnGroupId
Definition SpawnData.h:78
uint32 poolId
Definition SpawnData.h:79

References Creature::GetDefaultMovementType(), Map::GetPoolData(), Unit::GetVehicleKit(), Creature::HasReactState(), Unit::HasUnitState(), IDLE_MOTION_TYPE, Unit::IsAlive(), Unit::IsImmuneToNPC(), Creature::IsMoveInLineOfSightDisabled(), WorldObject::isNeedNotify(), SpawnedPoolData::IsSpawnedObject(), Map::IsSpawnGroupActive(), Creature::LoadFromDB(), NOTIFY_AI_RELOCATION, NOTIFY_VISIBILITY_CHANGED, SpawnData::poolId, REACT_AGGRESSIVE, sObjectMgr, SpawnData::spawnGroupId, UNIT_STATE_SIGHTLESS, and Cell::VisitObjects().

Referenced by LoadAllCellsInGrid().

◆ LoadGameObjects()

void GridObjectLoader::LoadGameObjects ( CellGuidSet const &  guid_set,
Map map 
)
private
79{
80 for (ObjectGuid::LowType const& guid : guid_set)
81 {
82 GameObjectData const* data = sObjectMgr->GetGameObjectData(guid);
83
84 // Skip spawns whose spawn group is not active on this map
85 if (data && !map->IsSpawnGroupActive(data->spawnGroupId))
86 continue;
87
88 // Skip pool members this map's pool state has not rolled as spawned
89 if (data && data->poolId && !map->GetPoolData().IsSpawnedObject<GameObject>(guid))
90 continue;
91
92 if (data && sObjectMgr->IsGameObjectStaticTransport(data->id))
93 {
94 StaticTransport* transport = new StaticTransport();
95
96 // Special case for static transports - we are loaded via grids
97 // but we do not want to actually be stored in the grid
98 if (!transport->LoadGameObjectFromDB(guid, map, true))
99 delete transport;
100 }
101 else
102 {
103 GameObject* obj = new GameObject();
104
105 if (!obj->LoadFromDB(guid, map))
106 {
107 delete obj;
108 continue;
109 }
110
111 AddObjectHelper<GameObject>(map, obj);
112 }
113 }
114}
Definition GameObject.h:120
virtual bool LoadFromDB(ObjectGuid::LowType guid, Map *map)
Definition GameObject.h:159
Definition Transport.h:120
bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true) override
Definition Transport.cpp:799
Definition GameObjectData.h:715
uint32 id
Definition GameObjectData.h:717

References Map::GetPoolData(), GameObjectData::id, SpawnedPoolData::IsSpawnedObject(), Map::IsSpawnGroupActive(), GameObject::LoadFromDB(), StaticTransport::LoadGameObjectFromDB(), SpawnData::poolId, sObjectMgr, and SpawnData::spawnGroupId.

Referenced by LoadAllCellsInGrid().

Member Data Documentation

◆ _grid

MapGridType& GridObjectLoader::_grid
private

Referenced by LoadAllCellsInGrid().

◆ _map

Map* GridObjectLoader::_map
private

Referenced by LoadAllCellsInGrid().


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