diff --git a/src/game/MotionMaster.cpp b/src/game/MotionMaster.cpp index b2f99f968..ce20d5cd7 100644 --- a/src/game/MotionMaster.cpp +++ b/src/game/MotionMaster.cpp @@ -43,8 +43,8 @@ MotionMaster::Initialize() while(!empty()) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -66,8 +66,8 @@ MotionMaster::~MotionMaster() while(!empty()) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -117,8 +117,8 @@ MotionMaster::DirectClean(bool reset) while( !empty() && size() > 1 ) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + curr->Finalize(*i_owner); if( !isStatic( curr ) ) delete curr; } @@ -142,8 +142,8 @@ MotionMaster::DelayedClean() while( !empty() && size() > 1 ) { MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + curr->Finalize(*i_owner); if( !isStatic( curr ) ) m_expList->push_back(curr); } @@ -156,23 +156,26 @@ MotionMaster::DirectExpire(bool reset) return; MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); + // also drop stored under top() targeted motions + while( !empty() && top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE ) + { + MovementGenerator *temp = top(); + pop(); + temp ->Finalize(*i_owner); + delete temp; + } + + // it can add another motions instead + curr->Finalize(*i_owner); + if( !isStatic(curr) ) delete curr; - assert( !empty() ); - while( !empty() && top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE ) - { - // Should check if target is still valid? If not valid it will crash. - curr = top(); - curr->Finalize(*i_owner); - pop(); - delete curr; - } if( empty() ) Initialize(); + if (reset) top()->Reset(*i_owner); } @@ -183,23 +186,24 @@ MotionMaster::DelayedExpire() return; MovementGenerator *curr = top(); - curr->Finalize(*i_owner); pop(); if(!m_expList) m_expList = new ExpireList(); - if( !isStatic(curr) ) - m_expList->push_back(curr); - + // also drop stored under top() targeted motions while( !empty() && top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE ) { - // Should check if target is still valid? If not valid it will crash. - curr = top(); - curr->Finalize(*i_owner); + MovementGenerator *temp = top(); pop(); - m_expList->push_back(curr); + temp ->Finalize(*i_owner); + m_expList->push_back(temp ); } + + curr->Finalize(*i_owner); + + if( !isStatic(curr) ) + m_expList->push_back(curr); } void MotionMaster::MoveIdle() diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index e13fce7d4..de966162a 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 "7458" + #define REVISION_NR "7459" #endif // __REVISION_NR_H__