diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 5acd9a683..c99eb9d46 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -261,6 +261,8 @@ void CNpcEnemy::init() setCollisionCentreOffset( 0, -( ofs.vy >> 1 ) ); + m_positionHistory = NULL; + switch ( m_data[this->m_type].initFunc ) { case NPC_INIT_DEFAULT: @@ -521,8 +523,27 @@ void CNpcEnemy::init() void CNpcEnemy::shutdown() { + // remove waypoints + m_npcPath.removeAllWaypoints(); + // remove position history + + CNpcPositionHistory *currentPosition; + CNpcPositionHistory *oldPosition; + + currentPosition = m_positionHistory; + + while( currentPosition ) + { + oldPosition = currentPosition; + currentPosition = currentPosition->next; + + delete oldPosition; + } + + m_positionHistory = NULL; + // temporary TPFree( m_actorTPage ); CEnemyThing::shutdown();