Skip to content

Commit

Permalink
[7459] Support case when movegen at own Finilize add another movegen.
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirMangos committed Mar 14, 2009
1 parent 3ae8d3d commit 32b551f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
46 changes: 25 additions & 21 deletions src/game/MotionMaster.cpp
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand All @@ -156,23 +156,26 @@ MotionMaster::DirectExpire(bool reset)
return;

MovementGenerator *curr = top();
curr->Finalize(*i_owner);
pop();

if( !isStatic(curr) )
delete curr;

assert( !empty() );
// 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();
delete curr;
temp ->Finalize(*i_owner);
delete temp;
}

// it can add another motions instead
curr->Finalize(*i_owner);

if( !isStatic(curr) )
delete curr;

if( empty() )
Initialize();

if (reset) top()->Reset(*i_owner);
}

Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion 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__

0 comments on commit 32b551f

Please sign in to comment.