diff --git a/source/projectl/projectl.cpp b/source/projectl/projectl.cpp index 14e504e69..1d29b4863 100644 --- a/source/projectl/projectl.cpp +++ b/source/projectl/projectl.cpp @@ -92,14 +92,14 @@ void CProjectile::init( DVECTOR initPos, s16 initHeading, PROJECTILE_MOVEMENT_TY void CProjectile::shutdown() { - if ( !m_isShuttingDown ) - { - m_isShuttingDown = true; + m_spriteBank->dump(); delete m_spriteBank; - m_spriteBank->dump(); delete m_spriteBank; + CEnemyProjectileThing::shutdown(); +} - CEnemyProjectileThing::shutdown(); - } +void CProjectile::setToShutdown() +{ + m_isShuttingDown = true; } bool CProjectile::processTargetSeek( int _frames, DVECTOR targetPos ) @@ -242,7 +242,7 @@ void CProjectile::think(int _frames) { if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) { - shutdown(); + setToShutdown(); } else { @@ -302,7 +302,7 @@ void CProjectile::think(int _frames) { if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) { - shutdown(); + setToShutdown(); } else { @@ -320,7 +320,7 @@ void CProjectile::think(int _frames) if ( m_lifetime <= 0 ) { - shutdown(); + setToShutdown(); } } } @@ -375,7 +375,7 @@ void CProjectile::collidedWith(CThing *_thisThing) if ( m_lifetimeType != PROJECTILE_INFINITE_LIFE ) { - shutdown(); + setToShutdown(); } break; @@ -437,14 +437,14 @@ void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTIL void CPlayerProjectile::shutdown() { - if ( !m_isShuttingDown ) - { - m_isShuttingDown = true; + m_spriteBank->dump(); delete m_spriteBank; - m_spriteBank->dump(); delete m_spriteBank; + CPlayerProjectileThing::shutdown(); +} - CPlayerProjectileThing::shutdown(); - } +void CPlayerProjectile::setToShutdown() +{ + m_isShuttingDown = true; } void CPlayerProjectile::setMovementType( PLAYER_PROJECTILE_MOVEMENT_TYPE moveType ) @@ -485,7 +485,7 @@ void CPlayerProjectile::think(int _frames) { if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) { - shutdown(); + setToShutdown(); } else { @@ -503,7 +503,7 @@ void CPlayerProjectile::think(int _frames) if ( m_lifetime <= 0 ) { - shutdown(); + setToShutdown(); } } } diff --git a/source/projectl/projectl.h b/source/projectl/projectl.h index 9d54fb0bb..485d159e2 100644 --- a/source/projectl/projectl.h +++ b/source/projectl/projectl.h @@ -48,6 +48,8 @@ public: void init( DVECTOR initPos, s16 initHeading, PROJECTILE_MOVEMENT_TYPE initMoveType, PROJECTILE_LIFETIME_TYPE initLifeType ); void init( DVECTOR initPos, s16 initHeading, PROJECTILE_MOVEMENT_TYPE initMoveType, PROJECTILE_LIFETIME_TYPE initLifeType, s32 initLifetime ); void shutdown(); + void setToShutdown(); + u8 isSetToShutdown() {return( m_isShuttingDown );} void think(int _frames); virtual void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); @@ -99,6 +101,8 @@ public: void init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType ); void init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTILE_MOVEMENT_TYPE initMoveType, PLAYER_PROJECTILE_LIFETIME_TYPE initLifeType, s32 initLifetime ); void shutdown(); + void setToShutdown(); + u8 isSetToShutdown() {return( m_isShuttingDown );} void think(int _frames); virtual void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index 16b4762a6..665a2dcbf 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -254,6 +254,23 @@ void CThingManager::thinkAllThings(int _frames) thing1 = thing1->m_nextThing; } + for(i=0;im_nextThing; + + if ( thing->isSetToShutdown() ) + { + thing->shutdown(); + delete thing; + } + + thing = nextThing; + } + } } /*---------------------------------------------------------------------- diff --git a/source/thing/thing.h b/source/thing/thing.h index d208fd99d..b6a0ba30c 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -101,6 +101,7 @@ public: virtual void shutdown(); virtual void think(int _frames); virtual void render(); + virtual u8 isSetToShutdown() {return( false );} // Linkage void addChild(CThing *Child);