From f47f5a1debc69e12f95443558f19cb7b81fc4dff Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 22 Feb 2010 20:29:32 +0300 Subject: [PATCH] [9434] Prevent crash at script call that modify movegen list at MovementInform call. --- src/game/WaypointMovementGenerator.cpp | 11 +++++++++++ src/game/WaypointMovementGenerator.h | 4 ++-- src/shared/revision_nr.h | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp index e703210ed..d8832cb70 100644 --- a/src/game/WaypointMovementGenerator.cpp +++ b/src/game/WaypointMovementGenerator.cpp @@ -206,6 +206,17 @@ bool WaypointMovementGenerator::Update(Creature &creature, const uint3 i_hasDone[idx] = true; MovementInform(creature); + + // force stop processing (script change movegen list) + if (creature.GetMotionMaster()->empty() || creature.GetMotionMaster()->top() != this) + return true; // not expire now, but already lost + + // prevent a crash at empty waypoint path. + if (!i_path || i_path->empty()) + { + creature.clearUnitState(UNIT_STAT_ROAMING_MOVE); + return true; + } } // HasDone == false } // i_creature.IsStopped() diff --git a/src/game/WaypointMovementGenerator.h b/src/game/WaypointMovementGenerator.h index 52b8b8174..9fcbf4cbd 100644 --- a/src/game/WaypointMovementGenerator.h +++ b/src/game/WaypointMovementGenerator.h @@ -71,7 +71,7 @@ class MANGOS_DLL_SPEC WaypointMovementGenerator; template<> class MANGOS_DLL_SPEC WaypointMovementGenerator : public MovementGeneratorMedium< Creature, WaypointMovementGenerator >, -public PathMovementBase +public PathMovementBase { public: WaypointMovementGenerator(Creature &) : i_nextMoveTime(0), b_StoppedByPlayer(false) {} @@ -95,7 +95,7 @@ public PathMovementBase void SetStoppedByPlayer(bool val) { b_StoppedByPlayer = val; } // allow use for overwrite empty implementation - bool GetDestination(float& x, float& y, float& z) const { return PathMovementBase::GetDestination(x,y,z); } + bool GetDestination(float& x, float& y, float& z) const { return PathMovementBase::GetDestination(x,y,z); } private: void ClearWaypoints(); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index bbd05258e..456391338 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9433" + #define REVISION_NR "9434" #endif // __REVISION_NR_H__