[7459] Support case when movegen at own Finilize add another movegen.

This commit is contained in:
VladimirMangos 2009-03-14 23:28:38 +03:00
parent 9b1216f21c
commit e4a5a47178
2 changed files with 27 additions and 23 deletions

View file

@ -43,8 +43,8 @@ MotionMaster::Initialize()
while(!empty()) while(!empty())
{ {
MovementGenerator *curr = top(); MovementGenerator *curr = top();
curr->Finalize(*i_owner);
pop(); pop();
curr->Finalize(*i_owner);
if( !isStatic( curr ) ) if( !isStatic( curr ) )
delete curr; delete curr;
} }
@ -66,8 +66,8 @@ MotionMaster::~MotionMaster()
while(!empty()) while(!empty())
{ {
MovementGenerator *curr = top(); MovementGenerator *curr = top();
curr->Finalize(*i_owner);
pop(); pop();
curr->Finalize(*i_owner);
if( !isStatic( curr ) ) if( !isStatic( curr ) )
delete curr; delete curr;
} }
@ -117,8 +117,8 @@ MotionMaster::DirectClean(bool reset)
while( !empty() && size() > 1 ) while( !empty() && size() > 1 )
{ {
MovementGenerator *curr = top(); MovementGenerator *curr = top();
curr->Finalize(*i_owner);
pop(); pop();
curr->Finalize(*i_owner);
if( !isStatic( curr ) ) if( !isStatic( curr ) )
delete curr; delete curr;
} }
@ -142,8 +142,8 @@ MotionMaster::DelayedClean()
while( !empty() && size() > 1 ) while( !empty() && size() > 1 )
{ {
MovementGenerator *curr = top(); MovementGenerator *curr = top();
curr->Finalize(*i_owner);
pop(); pop();
curr->Finalize(*i_owner);
if( !isStatic( curr ) ) if( !isStatic( curr ) )
m_expList->push_back(curr); m_expList->push_back(curr);
} }
@ -156,23 +156,26 @@ MotionMaster::DirectExpire(bool reset)
return; return;
MovementGenerator *curr = top(); MovementGenerator *curr = top();
curr->Finalize(*i_owner);
pop(); 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) ) if( !isStatic(curr) )
delete 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() ) if( empty() )
Initialize(); Initialize();
if (reset) top()->Reset(*i_owner); if (reset) top()->Reset(*i_owner);
} }
@ -183,23 +186,24 @@ MotionMaster::DelayedExpire()
return; return;
MovementGenerator *curr = top(); MovementGenerator *curr = top();
curr->Finalize(*i_owner);
pop(); pop();
if(!m_expList) if(!m_expList)
m_expList = new ExpireList(); m_expList = new ExpireList();
if( !isStatic(curr) ) // also drop stored under top() targeted motions
m_expList->push_back(curr);
while( !empty() && top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE ) while( !empty() && top()->GetMovementGeneratorType() == TARGETED_MOTION_TYPE )
{ {
// Should check if target is still valid? If not valid it will crash. MovementGenerator *temp = top();
curr = top();
curr->Finalize(*i_owner);
pop(); 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() void MotionMaster::MoveIdle()

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "7458" #define REVISION_NR "7459"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__