Core/AreaTriggers: Fixed crashes caused by areatrigger OnUnitEnter/OnUnitExit scripts teleporting players to other maps

This commit is contained in:
Shauren
2026-02-24 00:23:21 +01:00
parent 4a3cb9c76b
commit d649427edc

View File

@@ -895,8 +895,8 @@ void AreaTrigger::HandleUnitEnter(Unit* unit)
_ai->OnUnitEnter(unit);
// OnUnitEnter script can despawn this areatrigger
if (!IsInWorld())
// OnUnitEnter script can despawn this areatrigger or teleport player to a different map
if (!IsInWorld() || !IsInMap(unit))
return;
// Register areatrigger in Unit after actions/scripts to allow them to determine
@@ -925,10 +925,11 @@ void AreaTrigger::HandleUnitExitInternal(Unit* unit, AreaTriggerExitReason exitM
UndoActions(unit);
// OnUnitExit script can teleport player to another map, causing it to attempt to exit the areatrigger again (from Unit::ExitAllAreaTriggers)
unit->ExitAreaTrigger(this);
if (canTriggerOnExit)
_ai->OnUnitExit(unit, exitMode);
unit->ExitAreaTrigger(this);
}
void AreaTrigger::HandleUnitExit(Unit* unit)