Core/AreaTrigger: Fix crashes happening if areatrigger is despawned in OnUnitEnter script

Closes #31340
This commit is contained in:
Shauren
2025-10-04 12:13:23 +02:00
parent afc613fb63
commit 9827685634

View File

@@ -894,6 +894,14 @@ void AreaTrigger::HandleUnitEnter(Unit* unit)
DoActions(unit);
_ai->OnUnitEnter(unit);
// OnUnitEnter script can despawn this areatrigger
if (!IsInWorld())
return;
// Register areatrigger in Unit after actions/scripts to allow them to determine
// if the unit is in one or more areatriggers with the same id
// without forcing every script to have additional logic excluding this areatrigger
unit->EnterAreaTrigger(this);
}