fix(Core): Crashfix. (#14667)

This commit is contained in:
UltraNix
2023-01-28 10:58:58 +01:00
committed by GitHub
parent d25ca1f963
commit 7d65250414
@@ -134,6 +134,11 @@ void RandomMovementGenerator<Creature>::_setRandomLocation(Creature* creature)
} }
else // ground else // ground
{ {
if (!_pathGenerator)
_pathGenerator = new PathGenerator(creature);
else
_pathGenerator->Clear();
bool result = _pathGenerator->CalculatePath(x, y, levelZ, false); bool result = _pathGenerator->CalculatePath(x, y, levelZ, false);
if (result && !(_pathGenerator->GetPathType() & PATHFIND_NOPATH)) if (result && !(_pathGenerator->GetPathType() & PATHFIND_NOPATH))
{ {
@@ -252,8 +257,6 @@ void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
} }
} }
if (!_pathGenerator)
_pathGenerator = new PathGenerator(creature);
creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE); creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
} }