From 9f1409c557c4ef6edc2bb9b54c6ad0463beb20db Mon Sep 17 00:00:00 2001 From: megamage Date: Sat, 17 Jan 2009 17:46:28 -0600 Subject: *Fix a crash bug caused by motionmaster. *Fix charge movement. --HG-- branch : trunk --- src/game/MotionMaster.cpp | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'src/game/MotionMaster.cpp') diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index 5d9059b468d..afc1940f89b 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -46,8 +46,10 @@ MotionMaster::Initialize() while(!empty()) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + if(!curr) + continue; + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -69,8 +71,10 @@ MotionMaster::~MotionMaster() while(!empty()) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + if(!curr) + continue; + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -92,8 +96,10 @@ MotionMaster::Clear(bool reset) while( !empty() && size() > 1 ) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + if(!curr) + continue; + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -268,6 +274,26 @@ MotionMaster::MovePoint(uint32 id, float x, float y, float z) } } +void +MotionMaster::MoveCharge(float x, float y, float z) +{ + if(Impl[MOTION_SLOT_CONTROLLED] && Impl[MOTION_SLOT_CONTROLLED]->GetMovementGeneratorType() != DISTRACT_MOTION_TYPE) + return; + + i_owner->addUnitState(UNIT_STAT_CHARGING); + if(i_owner->GetTypeId()==TYPEID_PLAYER) + { + DEBUG_LOG("Player (GUID: %u) charge point (X: %f Y: %f Z: %f)", i_owner->GetGUIDLow(), x, y, z ); + Mutate(new PointMovementGenerator(0,x,y,z), MOTION_SLOT_CONTROLLED); + } + else + { + DEBUG_LOG("Creature (Entry: %u GUID: %u) charge point (X: %f Y: %f Z: %f)", + i_owner->GetEntry(), i_owner->GetGUIDLow(), x, y, z ); + Mutate(new PointMovementGenerator(0,x,y,z), MOTION_SLOT_CONTROLLED); + } +} + void MotionMaster::MoveFleeing(Unit* enemy) { @@ -366,14 +392,14 @@ void MotionMaster::MovePath(uint32 path_id, bool repeatable) return; //We set waypoint movement as new default movement generator // clear ALL movement generators (including default) - while(!empty()) + /*while(!empty()) { MovementGenerator *curr = top(); curr->Finalize(*i_owner); pop(); if( !isStatic( curr ) ) delete curr; - } + }*/ //i_owner->GetTypeId()==TYPEID_PLAYER ? //Mutate(new WaypointMovementGenerator(path_id, repeatable)): -- cgit v1.2.3