Core/Phasing: Implemented db spawns in personal phases (#26345)

Co-authored-by: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
Matan Shukry
2021-12-28 14:24:10 +02:00
committed by GitHub
parent 1aad7f8ddd
commit 8fabe5a3aa
24 changed files with 574 additions and 81 deletions

View File

@@ -564,12 +564,15 @@ void Map::EnsureGridCreated_i(GridCoord const& p)
}
//Load NGrid and make it active
void Map::EnsureGridLoadedForActiveObject(Cell const& cell, WorldObject* object)
void Map::EnsureGridLoadedForActiveObject(Cell const& cell, WorldObject const* object)
{
EnsureGridLoaded(cell);
NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
ASSERT(grid != nullptr);
if (object->IsPlayer())
GetMultiPersonalPhaseTracker().LoadGrid(object->GetPhaseShift(), *grid, this, cell);
// refresh grid state & timer
if (grid->GetGridState() != GRID_STATE_ACTIVE)
{
@@ -635,6 +638,11 @@ void Map::LoadGrid(float x, float y)
EnsureGridLoaded(Cell(x, y));
}
void Map::LoadGridForActiveObject(float x, float y, WorldObject const* object)
{
EnsureGridLoadedForActiveObject(Cell(x, y), object);
}
bool Map::AddPlayerToMap(Player* player, bool initPlayer /*= true*/)
{
CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
@@ -671,6 +679,12 @@ bool Map::AddPlayerToMap(Player* player, bool initPlayer /*= true*/)
return true;
}
void Map::UpdatePersonalPhasesForPlayer(Player const* player)
{
Cell cell(player->GetPositionX(), player->GetPositionY());
GetMultiPersonalPhaseTracker().OnOwnerPhaseChanged(player, getNGrid(cell.GridX(), cell.GridY()), this, cell);
}
template<class T>
void Map::InitializeObject(T* /*obj*/) { }
@@ -939,6 +953,9 @@ void Map::Update(uint32 t_diff)
_weatherUpdateTimer.Reset();
}
// update phase shift objects
GetMultiPersonalPhaseTracker().Update(this, t_diff);
MoveAllCreaturesInMoveList();
MoveAllGameObjectsInMoveList();
MoveAllAreaTriggersInMoveList();
@@ -1044,6 +1061,8 @@ void Map::RemovePlayerFromMap(Player* player, bool remove)
player->UpdateZone(MAP_INVALID_ZONE, 0);
sScriptMgr->OnPlayerLeaveMap(this, player);
GetMultiPersonalPhaseTracker().MarkAllPhasesForDeletion(player->GetGUID());
player->CombatStop();
bool const inWorld = player->IsInWorld();
@@ -1070,6 +1089,8 @@ void Map::RemoveFromMap(T *obj, bool remove)
if (obj->isActiveObject())
RemoveFromActive(obj);
GetMultiPersonalPhaseTracker().UnregisterTrackedObject(obj);
if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
obj->DestroyForNearbyPlayers(); // previous obj->UpdateObjectVisibility(true)
@@ -1735,6 +1756,9 @@ bool Map::UnloadGrid(NGridType& ngrid, bool unloadAll)
RemoveAllObjectsInRemoveList();
// After removing all objects from the map, purge empty tracked phases
GetMultiPersonalPhaseTracker().UnloadGrid(ngrid);
{
ObjectGridUnloader worker;
TypeContainerVisitor<ObjectGridUnloader, GridTypeMapContainer> visitor(worker);