diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 6c41608a8..dca716bbc 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -779,38 +779,40 @@ void CNpcEnemy::reinit() void CNpcEnemy::shutdown() { - if ( !m_isShuttingDown ) + if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank; + // remove waypoints + + m_npcPath.removeAllWaypoints(); + + // remove position history + + CNpcPositionHistory *currentPosition; + CNpcPositionHistory *oldPosition; + + currentPosition = m_positionHistory; + + while( currentPosition ) { - m_isShuttingDown = true; + oldPosition = currentPosition; + currentPosition = currentPosition->next; - if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank; - // 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; - - if (m_actorGfx) delete m_actorGfx; - - deleteAllChild(); - - CEnemyThing::shutdown(); + delete oldPosition; } + + m_positionHistory = NULL; + + if (m_actorGfx) delete m_actorGfx; + + deleteAllChild(); + + CEnemyThing::shutdown(); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void CNpcEnemy::setToShutdown() +{ + m_isShuttingDown = true; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1283,7 +1285,7 @@ void CNpcEnemy::processShot() } else { - shutdown(); + setToShutdown(); } } @@ -1479,7 +1481,7 @@ void CNpcEnemy::caughtWithNet() } else { - shutdown(); + setToShutdown(); } } diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 08d6bc442..0566f4839 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -182,6 +182,8 @@ public: virtual int canCollide(); + void setToShutdown(); + u8 isSetToShutdown() {return( m_isShuttingDown );} protected: class CLayerCollision *m_layerCollision; diff --git a/source/platform/pfishhk.cpp b/source/platform/pfishhk.cpp index e49dea3c6..ff08f4d4f 100644 --- a/source/platform/pfishhk.cpp +++ b/source/platform/pfishhk.cpp @@ -17,6 +17,14 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcFishHookPlatform::postInit() +{ + m_isMoving = false; + m_isShuttingDown = false; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcFishHookPlatform::processLifetime( int _frames ) { if ( m_contact ) @@ -27,6 +35,13 @@ void CNpcFishHookPlatform::processLifetime( int _frames ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CNpcFishHookPlatform::setToShutdown() +{ + m_isShuttingDown = true; +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcFishHookPlatform::processMovement( int _frames ) { if ( m_isMoving ) diff --git a/source/platform/pfishhk.h b/source/platform/pfishhk.h index 8eff71fc7..36cdb1bb8 100644 --- a/source/platform/pfishhk.h +++ b/source/platform/pfishhk.h @@ -21,12 +21,15 @@ class CNpcFishHookPlatform : public CNpcPlatform { public: - virtual void postInit() {m_isMoving = false;} + virtual void postInit(); + void setToShutdown(); + u8 isSetToShutdown() {return( m_isShuttingDown );} protected: virtual void processLifetime( int _frames ); virtual void processMovement( int _frames ); - bool m_isMoving; + u8 m_isMoving; + u8 m_isShuttingDown; }; #endif \ No newline at end of file