Core/Map: Fix a crash that could happen if a player moved very far away from a creature they were in combat with. Closes #21177.

This commit is contained in:
Treeston
2018-01-04 15:19:37 +01:00
committed by Ovahlord
parent d82abd8256
commit c1237c788b
2 changed files with 6 additions and 3 deletions

View File

@@ -894,10 +894,13 @@ void Map::Update(uint32 t_diff)
// Handle updates for creatures in combat with player and are more than 60 yards away
if (player->IsInCombat())
{
std::vector<Unit*> toVisit;
for (auto const& pair : player->GetCombatManager().GetPvECombatRefs())
if (Creature* unit = pair.second->GetOther(player)->ToCreature())
if (unit->GetMapId() == player->GetMapId() && !unit->IsWithinDistInMap(player, GetVisibilityRange(), false))
VisitNearbyCellsOf(unit, grid_object_update, world_object_update);
toVisit.push_back(unit);
for (Unit* unit : toVisit)
VisitNearbyCellsOf(unit, grid_object_update, world_object_update);
}
{ // Update any creatures that own auras the player has applications of

View File

@@ -926,12 +926,12 @@ public:
for (auto const& ref : target->GetCombatManager().GetPvPCombatRefs())
{
Unit* unit = ref.second->GetOther(target);
handler->PSendSysMessage("[PvP] %s (DBGUID %u)", unit->GetName().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0);
handler->PSendSysMessage("[PvP] %s (SpawnID %u)", unit->GetName().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0);
}
for (auto const& ref : target->GetCombatManager().GetPvECombatRefs())
{
Unit* unit = ref.second->GetOther(target);
handler->PSendSysMessage("[PvE] %s (DBGUID %u)", unit->GetName().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0);
handler->PSendSysMessage("[PvE] %s (SpawnID %u)", unit->GetName().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0);
}
return true;
}