aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Maps/Map.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-01-03 20:04:19 +0100
committerShauren <shauren.trinity@gmail.com>2021-05-16 21:56:01 +0200
commit34c7810fe507eca1b8b9389630db5d5d26d92e77 (patch)
treee05653a0adaf4c4f5c406649f1bfe6573cbb22ff /src/server/game/Maps/Map.cpp
parent5158136ee8a77046e37bafa192481b8b61d4a116 (diff)
Core: Combat/threat system rewrite (PR #19930)
- PvE combat is now always mutual. UNIT_FLAG_IN_COMBAT is backed by actual references to the units we're in combat with. - PvP combat is now also tracked, and almost always mutual; spells like Vanish and Feign Death can break this rule. That means we can easily determine a list of players we're fighting. - By extension, IsInCombatWith now has sensible behavior when invoked on nonplayers. - Threat and combat systems are no longer the same. - They still have an enforced relationship (threat implies combat - clearing combat clears threat)... - ...but we can have combat without threat. A creature (with threat list) isn't considered to be engaged until it has an entry on its threat list... - ...which means we can now faithfully replicate retail engage behavior. Combat on projectile launch - engagement start on projectile impact. Yay for progress! - AI method refactor, as already ported in 6113b9d - `JustEngagedWith`, `JustEnteredCombat` and `JustExitedCombat`. - Vehicle threat is now properly pooled on the main vehicle body (fixes #16542). - Various edge case bug fixes for threat redirects (Misdirection "cancelling" Vigilance and similar). - Target re-selection is now significantly faster. - Fixed a ton of other smaller edge case bugs, probably. Closes #7951 and #19998. (cherry picked from commit 532ab1c7f8653d1a2e48aa1f1f8a9ba1041d4bb7)
Diffstat (limited to 'src/server/game/Maps/Map.cpp')
-rw-r--r--src/server/game/Maps/Map.cpp21
1 files changed, 5 insertions, 16 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 91138fc043e..8d6d2e8f663 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -875,21 +875,10 @@ 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<Creature*> updateList;
- HostileReference* ref = player->getHostileRefManager().getFirst();
-
- while (ref)
- {
- if (Unit* unit = ref->GetSource()->GetOwner())
- if (unit->ToCreature() && unit->GetMapId() == player->GetMapId() && !unit->IsWithinDistInMap(player, GetVisibilityRange(), false))
- updateList.push_back(unit->ToCreature());
-
- ref = ref->next();
- }
-
- // Process deferred update list for player
- for (Creature* c : updateList)
- VisitNearbyCellsOf(c, grid_object_update, world_object_update);
+ 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);
}
}
@@ -1040,7 +1029,7 @@ void Map::RemovePlayerFromMap(Player* player, bool remove)
player->UpdateZone(MAP_INVALID_ZONE, 0);
sScriptMgr->OnPlayerLeaveMap(this, player);
- player->getHostileRefManager().deleteReferences(); // multithreading crashfix
+ player->CombatStop();
bool const inWorld = player->IsInWorld();
player->RemoveFromWorld();