From fa5105d7832082332155ddca1f40f2b0d4ac5b6d Mon Sep 17 00:00:00 2001 From: Daveo Date: Fri, 25 May 2001 18:43:47 +0000 Subject: [PATCH] --- source/enemy/nanemone.cpp | 14 +-- source/enemy/nbblob.cpp | 2 +- source/enemy/nbuttfly.cpp | 2 +- source/enemy/ndogfish.cpp | 3 +- source/enemy/ndustdev.cpp | 10 +- source/enemy/neyeball.cpp | 4 +- source/enemy/nfdutch.cpp | 1 - source/enemy/ngary.cpp | 6 +- source/enemy/ngen.cpp | 1 - source/enemy/ngeneric.cpp | 15 ++- source/enemy/ngpirate.cpp | 1 - source/enemy/nhcrab.cpp | 6 +- source/enemy/nmjfish.cpp | 1 - source/enemy/npbug.cpp | 6 +- source/enemy/npc.cpp | 59 ++--------- source/enemy/npc.h | 12 +-- source/enemy/nscrab.cpp | 10 +- source/enemy/nsdart.cpp | 4 +- source/enemy/nshell.cpp | 3 +- source/enemy/nshrkman.cpp | 4 +- source/enemy/nsj2back.cpp | 2 +- source/enemy/nsjback.cpp | 2 +- source/enemy/nsjfish.cpp | 3 +- source/enemy/nsshark.cpp | 1 - source/enemy/nsstomp.cpp | 2 +- source/enemy/nworm.cpp | 1 - source/friend/fgary.cpp | 6 +- source/friend/fplnkton.cpp | 13 +-- source/friend/fplnkton.h | 1 - source/friend/friend.cpp | 13 +-- source/friend/friend.h | 10 +- source/fx/fx.cpp | 8 +- source/fx/fx.h | 7 +- source/fx/fxbaseanim.cpp | 6 +- source/fx/fxbasetrail.cpp | 5 +- source/fx/fxjfish.cpp | 3 +- source/game/game.cpp | 11 +- source/game/game.h | 12 +++ source/gfx/actor.cpp | 6 +- source/gfx/bubicles.cpp | 14 +-- source/gfx/bubicles.h | 2 - source/gfx/prim.cpp | 1 - source/gfx/sprbank.cpp | 1 + source/gui/gui.cpp | 14 ++- source/hazard/hazard.cpp | 13 ++- source/hazard/hazard.h | 7 +- source/hazard/hbarrel.cpp | 8 +- source/hazard/hboat.cpp | 6 +- source/hazard/hdbarrel.cpp | 7 +- source/hazard/hfalling.cpp | 2 +- source/hazard/hmasher.cpp | 4 +- source/hazard/hrckshrd.cpp | 2 +- source/hazard/hrrock.cpp | 8 +- source/jellfish/jellfish.cpp | 40 ++++++-- source/level/layerback.cpp | 1 - source/level/layercollision.cpp | 2 +- source/level/layertile.cpp | 2 +- source/map/map.cpp | 13 +-- source/map/map.h | 2 - source/pickups/pballoon.cpp | 7 +- source/pickups/pbubmix.cpp | 7 +- source/pickups/pglasses.cpp | 7 +- source/pickups/phealth.cpp | 7 +- source/pickups/phelmet.cpp | 7 +- source/pickups/pickup.cpp | 13 +-- source/pickups/pickup.h | 7 +- source/pickups/pjlammo.cpp | 7 +- source/pickups/plife.cpp | 7 +- source/pickups/pquest.cpp | 7 +- source/pickups/pshoes.cpp | 7 +- source/pickups/pspatula.cpp | 9 +- source/platform/pbaloon.cpp | 5 +- source/platform/pbaloon.h | 1 - source/platform/pbgeyser.cpp | 1 - source/platform/pcart.cpp | 6 +- source/platform/pfalling.cpp | 2 +- source/platform/pfallnor.cpp | 4 +- source/platform/pfgen.cpp | 2 - source/platform/platform.cpp | 16 +-- source/platform/platform.h | 12 ++- source/platform/pleaf.cpp | 2 +- source/platform/praft.cpp | 8 +- source/platform/psbarrel.cpp | 4 +- source/player/player.cpp | 52 +++++----- source/player/player.h | 6 -- source/player/pmbubble.cpp | 3 +- source/player/pmcoral.cpp | 4 +- source/player/pmjelly.cpp | 7 +- source/player/pmnet.cpp | 4 +- source/player/pmodes.cpp | 7 +- source/projectl/prnpcspr.cpp | 10 +- source/projectl/projectl.cpp | 30 ++---- source/projectl/projectl.h | 18 ++-- source/system/main.cpp | 5 +- source/thing/thing.cpp | 172 +++++++++++++++++++++++++++++--- source/thing/thing.h | 58 ++++++++--- 96 files changed, 550 insertions(+), 406 deletions(-) diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index 49cecb849..4f6ee17ea 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -215,7 +215,6 @@ void CNpcAnemone1Enemy::processClose( int _frames ) CProjectile *projectile; projectile = new( "test projectile" ) CProjectile; projectile->init( Pos, m_heading ); - projectile->setLayerCollision( m_layerCollision ); m_controlFunc = NPC_CONTROL_MOVEMENT; m_timerTimer = GameState::getOneSecondInFrames(); @@ -240,9 +239,6 @@ void CNpcAnemone2Enemy::postInit() m_scaleY = ONE; m_radius = 0; - - m_spriteBank=new ("projectile sprites") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -435,7 +431,6 @@ void CNpcAnemone2Enemy::processClose( int _frames ) projectile = new( "anemone lev2 projectile" ) CProjectile; projectile->init( spikePos, heading, CProjectile::PROJECTILE_DUMBFIRE, CProjectile::PROJECTILE_FINITE_LIFE ); - projectile->setLayerCollision( m_layerCollision ); projectile->setState( CProjectile::PROJECTILE_ATTACK ); projectile->setSpeed( 5 ); } @@ -527,16 +522,16 @@ void CNpcAnemone2Enemy::render() int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); - int spriteWidth = m_spriteBank->getFrameWidth(FRM__SPIKE); - int spriteHeight = m_spriteBank->getFrameHeight(FRM__SPIKE); + int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth(FRM__SPIKE); + int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight(FRM__SPIKE); offset = CLevel::getCameraPos(); x = spikePos.vx - offset.vx; y = spikePos.vy - offset.vy; - frameHdr = m_spriteBank->getFrameHeader( FRM__SPIKE ); - m_spriteBank->printRotatedScaledSprite( frameHdr, x, y, 4096, 4096, heading, 10 ); + frameHdr = CGameScene::getSpriteBank()->getFrameHeader( FRM__SPIKE ); + CGameScene::getSpriteBank()->printRotatedScaledSprite( frameHdr, x, y, 4096, 4096, heading, 10 ); } DVECTOR &renderPos=getRenderPos(); @@ -576,7 +571,6 @@ void CNpcAnemone3Enemy::processClose( int _frames ) CProjectile::PROJECTILE_GAS_CLOUD, CProjectile::PROJECTILE_FINITE_LIFE, lifetime * GameState::getOneSecondInFrames() ); - projectile->setLayerCollision( m_layerCollision ); m_controlFunc = NPC_CONTROL_MOVEMENT; m_timerFunc = NPC_TIMER_ATTACK_DONE; diff --git a/source/enemy/nbblob.cpp b/source/enemy/nbblob.cpp index 2bde67238..1edc242e7 100644 --- a/source/enemy/nbblob.cpp +++ b/source/enemy/nbblob.cpp @@ -69,7 +69,7 @@ void CNpcBallBlobEnemy::processMovement( int _frames ) moveY = ( m_velocity.vy >> 8 ) * _frames; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); if ( groundHeight < 0 ) { diff --git a/source/enemy/nbuttfly.cpp b/source/enemy/nbuttfly.cpp index f2a6d0ac0..63858c199 100644 --- a/source/enemy/nbuttfly.cpp +++ b/source/enemy/nbuttfly.cpp @@ -51,7 +51,7 @@ void CNpcButterflyBackgroundEnemy::render() { DVECTOR &renderPos=getRenderPos(); - SprFrame = m_spriteBank->printFT4(FRM_BUTTERFLY_FLAP01 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,!m_reversed,0,15); + SprFrame = CGameScene::getSpriteBank()->printFT4(FRM_BUTTERFLY_FLAP01 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,!m_reversed,0,15); setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) // get xmax, xmin, ymax, ymin diff --git a/source/enemy/ndogfish.cpp b/source/enemy/ndogfish.cpp index e062d1cec..c0b5fd079 100644 --- a/source/enemy/ndogfish.cpp +++ b/source/enemy/ndogfish.cpp @@ -133,7 +133,7 @@ void CNpcIronDogfishEnemy::processWalkToUser( int _frames, int speed ) s32 fallSpeed = 3; s8 yMovement = fallSpeed * _frames; - s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -208,7 +208,6 @@ void CNpcIronDogfishEnemy::processStandardIronDogfishAttack( int _frames ) DVECTOR startPos = Pos; startPos.vy -= 20; projectile->init( startPos, headingToPlayer ); - projectile->setLayerCollision( m_layerCollision ); m_state++; diff --git a/source/enemy/ndustdev.cpp b/source/enemy/ndustdev.cpp index 5306197fd..ef48eb13b 100644 --- a/source/enemy/ndustdev.cpp +++ b/source/enemy/ndustdev.cpp @@ -69,7 +69,7 @@ void CNpcDustDevilEnemy::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -91,7 +91,7 @@ void CNpcDustDevilEnemy::processMovement( int _frames ) distX = distX / abs( distX ); - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -101,7 +101,7 @@ void CNpcDustDevilEnemy::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -135,8 +135,8 @@ void CNpcDustDevilEnemy::processMovementModifier( int _frames, s32 distX, s32 di testPos1.vx -= 10; testPos2.vx += 10; - testPos1.vy += m_layerCollision->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); - testPos2.vy += m_layerCollision->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); + testPos1.vy += CGameScene::getCollision()->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); + testPos2.vy += CGameScene::getCollision()->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); s32 xDist = testPos2.vx - testPos1.vx; s32 yDist = testPos2.vy - testPos1.vy; diff --git a/source/enemy/neyeball.cpp b/source/enemy/neyeball.cpp index 5b14b8ad2..ff77c14dc 100644 --- a/source/enemy/neyeball.cpp +++ b/source/enemy/neyeball.cpp @@ -62,7 +62,6 @@ void CNpcEyeballEnemy::postInit() CProjectile *projectile; projectile = new ( "eyeball projectile" ) CProjectile; projectile->init( eyeballPos, m_fireHeading, CProjectile::PROJECTILE_FIXED, CProjectile::PROJECTILE_INFINITE_LIFE ); - projectile->setLayerCollision( m_layerCollision ); projectile->setGraphic( FRM_EYEBALL_STATIC ); addChild( projectile ); @@ -133,7 +132,6 @@ CThing *Next=getNext(); CProjectile *projectile; projectile = new ( "eyeball projectile" ) CProjectile; projectile->init( eyeballPos, m_fireHeading, CProjectile::PROJECTILE_USER_SEEK, CProjectile::PROJECTILE_INFINITE_LIFE ); - projectile->setLayerCollision( m_layerCollision ); projectile->setGraphic( FRM_EYEBALL_STATIC ); projectile->setState( CProjectile::PROJECTILE_ATTACK ); @@ -159,7 +157,7 @@ void CNpcEyeballEnemy::render() { DVECTOR &renderPos=getRenderPos(); - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_EYEBALL_STALK, renderPos.vx, renderPos.vy, 4096, 4096, m_drawRotation, 10); + SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM_EYEBALL_STALK, renderPos.vx, renderPos.vy, 4096, 4096, m_drawRotation, 10); // get xmax, xmin, ymax, ymin diff --git a/source/enemy/nfdutch.cpp b/source/enemy/nfdutch.cpp index b5b374709..d5440fbfa 100644 --- a/source/enemy/nfdutch.cpp +++ b/source/enemy/nfdutch.cpp @@ -167,7 +167,6 @@ void CNpcFlyingDutchmanEnemy::processClose( int _frames ) CProjectile *projectile; projectile = new( "test projectile" ) CProjectile; projectile->init( Pos, heading ); - projectile->setLayerCollision( m_layerCollision ); m_controlFunc = NPC_CONTROL_MOVEMENT; m_movementTimer = GameState::getOneSecondInFrames() * 3; diff --git a/source/enemy/ngary.cpp b/source/enemy/ngary.cpp index f5f8ede7b..673541910 100644 --- a/source/enemy/ngary.cpp +++ b/source/enemy/ngary.cpp @@ -30,7 +30,7 @@ void CNpcFriend::processGaryMovement( int _frames ) // check vertical collision - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= 0 ) { @@ -38,7 +38,7 @@ void CNpcFriend::processGaryMovement( int _frames ) // check horizontal collision - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) { // reverse direction @@ -63,7 +63,7 @@ void CNpcFriend::processGaryMovement( int _frames ) Pos.vy += groundHeight; - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) { // reverse direction diff --git a/source/enemy/ngen.cpp b/source/enemy/ngen.cpp index b7e799dec..1ecc48144 100644 --- a/source/enemy/ngen.cpp +++ b/source/enemy/ngen.cpp @@ -52,7 +52,6 @@ void CNpcEnemyGenerator::think(int _frames) ASSERT(enemy); enemy->setType( CNpcEnemy::NPC_SPIDER_CRAB ); enemy->init(); - enemy->setLayerCollision( m_layerCollision ); enemy->setStartPos( Pos.vx >> 4, Pos.vy >> 4 ); CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); diff --git a/source/enemy/ngeneric.cpp b/source/enemy/ngeneric.cpp index 429aa393f..325d3ae57 100644 --- a/source/enemy/ngeneric.cpp +++ b/source/enemy/ngeneric.cpp @@ -144,18 +144,18 @@ bool CNpcEnemy::processGroundCollisionReverse( s32 *moveX, s32 *moveY ) // check for collision with ground - if ( m_layerCollision->Get( ( Pos.vx + *moveX ) >> 4, ( Pos.vy + *moveY ) >> 4 ) ) + if ( CGameScene::getCollision()->Get( ( Pos.vx + *moveX ) >> 4, ( Pos.vy + *moveY ) >> 4 ) ) { // destination point is below ground, check in individual directions - if ( m_layerCollision->Get( ( Pos.vx + *moveX ) >> 4, Pos.vy >> 4 ) ) + if ( CGameScene::getCollision()->Get( ( Pos.vx + *moveX ) >> 4, Pos.vy >> 4 ) ) { // X direction is blocked xBlocked = true; } - if ( m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + *moveY ) >> 4 ) ) + if ( CGameScene::getCollision()->Get( Pos.vx >> 4, ( Pos.vy + *moveY ) >> 4 ) ) { yBlocked = true; } @@ -325,7 +325,7 @@ void CNpcEnemy::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -346,7 +346,7 @@ void CNpcEnemy::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY distX = distX / abs( distX ); - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -356,7 +356,7 @@ void CNpcEnemy::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -377,6 +377,5 @@ void CNpcEnemy::processGenericFixedPathWalk( int _frames, s32 *moveX, s32 *moveY bool CNpcEnemy::isCollisionWithGround() { - ASSERT(m_layerCollision); - return m_layerCollision->Get( Pos.vx >> 4, ( Pos.vy + 1 ) >> 4 ) ? 16:0; + return CGameScene::getCollision()->Get( Pos.vx >> 4, ( Pos.vy + 1 ) >> 4 ) ? 16:0; } diff --git a/source/enemy/ngpirate.cpp b/source/enemy/ngpirate.cpp index 968992cd8..734095446 100644 --- a/source/enemy/ngpirate.cpp +++ b/source/enemy/ngpirate.cpp @@ -104,7 +104,6 @@ void CNpcGhostPirateEnemy::processClose( int _frames ) projectile = new( "test projectile" ) CProjectile; projectile->init( Pos, heading ); - projectile->setLayerCollision( m_layerCollision ); } } else if ( m_extendDir == EXTEND_DOWN ) diff --git a/source/enemy/nhcrab.cpp b/source/enemy/nhcrab.cpp index 909dbdd35..4f2533d27 100644 --- a/source/enemy/nhcrab.cpp +++ b/source/enemy/nhcrab.cpp @@ -204,7 +204,7 @@ void CNpcHermitCrabEnemy::processClose( int _frames ) } else { - groundHeight = m_layerCollision->getHeightFromGround( newX, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( newX, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -247,8 +247,8 @@ void CNpcHermitCrabEnemy::processMovementModifier( int _frames, s32 distX, s32 d testPos1.vx -= 10; testPos2.vx += 10; - testPos1.vy += m_layerCollision->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); - testPos2.vy += m_layerCollision->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); + testPos1.vy += CGameScene::getCollision()->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); + testPos2.vy += CGameScene::getCollision()->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); s32 xDist = testPos2.vx - testPos1.vx; s32 yDist = testPos2.vy - testPos1.vy; diff --git a/source/enemy/nmjfish.cpp b/source/enemy/nmjfish.cpp index 3a26990cc..3a477a841 100644 --- a/source/enemy/nmjfish.cpp +++ b/source/enemy/nmjfish.cpp @@ -335,7 +335,6 @@ void CNpcMotherJellyfishEnemy::spawnJellyfish( int _frames ) ASSERT(enemy); enemy->setType( CNpcEnemy::NPC_PROJECTILE_JELLYFISH ); enemy->init(); - enemy->setLayerCollision( m_layerCollision ); enemy->setStartPos( Pos.vx >> 4, ( Pos.vy + 20 ) >> 4 ); CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); diff --git a/source/enemy/npbug.cpp b/source/enemy/npbug.cpp index 7616b159a..3503c42b1 100644 --- a/source/enemy/npbug.cpp +++ b/source/enemy/npbug.cpp @@ -19,6 +19,8 @@ #include "level\layercollision.h" #endif +#include "game/game.h" + void CNpcPricklyBugEnemy::processMovementModifier( int _frames, s32 distX, s32 distY, s32 dist, s16 headingChange ) { Pos.vx += distX; @@ -32,8 +34,8 @@ void CNpcPricklyBugEnemy::processMovementModifier( int _frames, s32 distX, s32 d testPos1.vx -= 10; testPos2.vx += 10; - testPos1.vy += m_layerCollision->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); - testPos2.vy += m_layerCollision->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); + testPos1.vy += CGameScene::getCollision()->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); + testPos2.vy += CGameScene::getCollision()->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); s32 xDist = testPos2.vx - testPos1.vx; s32 yDist = testPos2.vy - testPos1.vy; diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index 88dc7e6b9..98f048f75 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -214,75 +214,67 @@ CNpcEnemy *CNpcEnemy::Create(sThingActor *ThisActor) NPC_UNIT_TYPE enemyType = CNpcEnemy::getTypeFromMapEdit( ThisActor->Type ); + enemy = (CNpcEnemy*)CThingManager::GetThing(TYPE_ENEMY,enemyType); + if (!enemy) switch( enemyType ) { case CNpcEnemy::NPC_SMALL_JELLYFISH_1: case CNpcEnemy::NPC_SMALL_JELLYFISH_2: { - printf("JFish\n"); enemy = new ("small jellyfish") CNpcSmallJellyfishEnemy; break; } case CNpcEnemy::NPC_HERMIT_CRAB: { - printf("NPC_HERMIT_CRAB\n"); enemy = new ("hermit crab") CNpcHermitCrabEnemy; break; } case CNpcEnemy::NPC_SPIDER_CRAB: { - printf("NPC_SPIDER_CRAB\n"); enemy = new ("spider crab") CNpcSpiderCrabEnemy; break; } case CNpcEnemy::NPC_SPIDER_CRAB_SPAWNER: { - printf("NPC_SPIDER_CRAB_SPAWNER\n"); enemy = new ("spider crab spawner") CNpcEnemyGenerator; break; } case CNpcEnemy::NPC_ANEMONE_1: { - printf("NPC_ANEMONE_1\n"); enemy = new ("anemone 1") CNpcAnemone1Enemy; break; } case CNpcEnemy::NPC_ANEMONE_2: { - printf("NPC_ANEMONE_2\n"); enemy = new ("anemone 2") CNpcAnemone2Enemy; break; } case CNpcEnemy::NPC_ANEMONE_3: { - printf("NPC_ANEMONE_3\n"); enemy = new ("anemone 3") CNpcAnemone3Enemy; break; } case CNpcEnemy::NPC_CLAM_JUMP: { - printf("NPC_CLAM_JUMP\n"); enemy = new ("jumping clam") CNpcJumpingClamEnemy; break; } case CNpcEnemy::NPC_CLAM_STATIC: { - printf("NPC_CLAM_STATIC\n"); enemy = new ("static clam") CNpcStaticClamEnemy; break; } case CNpcEnemy::NPC_BABY_OCTOPUS: { - printf("NPC_BABY_OCTOPUS\n"); enemy = new ("baby octopus") CNpcBabyOctopusEnemy; break; } @@ -290,157 +282,126 @@ CNpcEnemy *CNpcEnemy::Create(sThingActor *ThisActor) case CNpcEnemy::NPC_FISH_FOLK: case CNpcEnemy::NPC_ZOMBIE_FISH_FOLK: { - printf("NPC_FISH_FOLK\n"); enemy = new ("fish folk") CNpcFishFolk; break; } case CNpcEnemy::NPC_BALL_BLOB: { - printf("NPC_BALL_BLOB\n"); enemy = new ("ball blob") CNpcBallBlobEnemy; break; } case CNpcEnemy::NPC_GHOST_PIRATE: { - printf("NPC_GHOST_PIRATE\n"); enemy = new ("ghost pirate") CNpcGhostPirateEnemy; break; } case CNpcEnemy::NPC_PUFFA_FISH: { - printf("NPC_PUFFA_FISH\n"); enemy = new ("puffa fish") CNpcPuffaFishEnemy; break; } case CNpcEnemy::NPC_SHARK_MAN: { - printf("NPC_SHARK_MAN\n"); enemy = new ("shark man") CNpcSharkManEnemy; break; } case CNpcEnemy::NPC_SKELETAL_FISH: { - printf("NPC_SKELETAL_FISH\n"); enemy = new ("skeletal fish") CNpcSkeletalFishEnemy; break; } case CNpcEnemy::NPC_EYEBALL: { - printf("NPC_EYEBALL\n"); enemy = new ("eyeball") CNpcEyeballEnemy; break; } case CNpcEnemy::NPC_FLAMING_SKULL: { - printf("NPC_FLAMING_SKULL\n"); enemy = new ("flaming skull") CNpcFlamingSkullEnemy; break; } case CNpcEnemy::NPC_SKULL_STOMPER: { - printf("NPC_SKULL_STOMPER\n"); enemy = new ("skull stomper") CNpcSkullStomperEnemy; break; } case CNpcEnemy::NPC_BOOGER_MONSTER: { - printf("NPC_BOOGER_MONSTER\n"); enemy = new ("booger monster") CNpcBoogerMonsterEnemy; break; } case CNpcEnemy::NPC_MOTHER_JELLYFISH: { - printf("NPC_MOTHER_JELLYFISH\n"); - - /*if ( CLevel::getCurrentChapterLevel() == 4 ) - { - enemy = new ("mother jellyfish background") CNpcMotherJellyfishBackground; - enemyType = NPC_MOTHER_JELLYFISH_BACKGROUND; - } - else*/ - { - enemy = new ("mother jellyfish") CNpcMotherJellyfishEnemy; - } - + enemy = new ("mother jellyfish") CNpcMotherJellyfishEnemy; break; } case CNpcEnemy::NPC_SUB_SHARK: { - printf("NPC_SUB_SHARK\n"); enemy = new ("sub shark") CNpcSubSharkEnemy; break; } case CNpcEnemy::NPC_PARASITIC_WORM: { - printf("NPC_PARASITIC_WORM\n"); enemy = new ("parasitic worm") CNpcParasiticWormEnemy; break; } case CNpcEnemy::NPC_FLYING_DUTCHMAN: { - printf("NPC_FLYING_DUTCHMAN\n"); enemy = new ("flying dutchman") CNpcFlyingDutchmanEnemy; break; } case CNpcEnemy::NPC_IRON_DOGFISH: { - printf("NPC_IRON_DOGFISH\n"); enemy = new ("iron dogfish") CNpcIronDogfishEnemy; break; } /*case CNpcEnemy::NPC_FALLING_ITEM: { - printf("NPC_FALLING_ITEM\n"); enemy = new ("falling item") CNpcFallingItemHazard; break; }*/ /*case CNpcEnemy::NPC_FISH_HOOK: { - printf("NPC_FISH_HOOK\n"); enemy = new ("fish hook") CNpcFishHookHazard; break; }*/ /*case CNpcEnemy::NPC_PENDULUM: { - printf("NPC_PENDULUM\n"); enemy = new ("pendulum") CNpcPendulumHazard; break; }*/ /*case CNpcEnemy::NPC_FIREBALL: { - printf("NPC_FIREBALL\n"); enemy = new ("fireball") CNpcFireballHazard; break; }*/ /*case CNpcEnemy::NPC_SAW_BLADE: { - printf("NPC_SAW_BLADE\n"); enemy = new ("saw blade") CNpcReturningHazard; break; }*/ case CNpcEnemy::NPC_DUST_DEVIL: { - printf("NPC_DUST_DEVIL\n"); enemy = new ("dust devil") CNpcDustDevilEnemy; break; } @@ -501,7 +462,7 @@ CNpcEnemy *CNpcEnemy::Create(sThingActor *ThisActor) default: { - printf("UNKNOWN %i\n",enemyType); + SYSTEM_DBGMSG("UNKNOWN %i\n",enemyType); enemy = new ("npc enemy") CNpcEnemy; ASSERT(0); break; @@ -511,6 +472,8 @@ CNpcEnemy *CNpcEnemy::Create(sThingActor *ThisActor) ASSERT(enemy); enemy->setType( enemyType ); + enemy->setThingSubType(enemyType); + enemy->init(); return(enemy); @@ -589,13 +552,10 @@ void CNpcEnemy::init() if (m_data[m_type].skelType) { m_actorGfx=CActorPool::GetActor((FileEquate)m_data[m_type].skelType); - m_spriteBank=0; } else { m_actorGfx=0; - m_spriteBank=new ("enemy sprites") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); } m_animPlaying = true; @@ -674,9 +634,6 @@ void CNpcEnemy::reinit() void CNpcEnemy::shutdown() { - if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank; - // remove waypoints - m_npcPath.removeAllWaypoints(); if (m_actorGfx) delete m_actorGfx; @@ -1444,7 +1401,7 @@ void CNpcEnemy::processEnemyCollision( CThing *thisThing ) } } - s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, 16 ); + s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, 16 ); if ( groundHeight < 8 ) { @@ -1494,7 +1451,7 @@ void CNpcEnemy::processUserCollision( CThing *thisThing ) Pos.vx += otherDelta.vx; - s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, 16 ); + s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, 16 ); if ( groundHeight < 8 ) { diff --git a/source/enemy/npc.h b/source/enemy/npc.h index 8ac039953..ce7c4b1e4 100644 --- a/source/enemy/npc.h +++ b/source/enemy/npc.h @@ -87,6 +87,10 @@ public: NPC_BUTTERFLY_BACKGROUND, NPC_UNIT_TYPE_MAX, }; + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =NPC_UNIT_TYPE_MAX, + }; void init(); virtual void postInit(); @@ -95,8 +99,7 @@ public: virtual void think(int _frames); virtual void render(); virtual void processEvent( GAME_EVENT evt, CThing *sourceThing ); - void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} - void setType( NPC_UNIT_TYPE newType ) {m_type = newType;} + void setType( NPC_UNIT_TYPE newType ) {m_type = newType; setThingSubType(newType);} NPC_UNIT_TYPE getType() {return( m_type );} static NPC_UNIT_TYPE getTypeFromMapEdit( u16 newType ); void setHeading( s32 newHeading ) {m_heading = newHeading;} @@ -120,9 +123,6 @@ public: bool canBeSuckedUp(); bool suckUp( DVECTOR *suckPos, int _frames ); -protected: - class CLayerCollision *m_layerCollision; - protected: // NPC data structure definitions // @@ -306,7 +306,7 @@ protected: s32 m_frame; int m_animNo; CActorGfx *m_actorGfx; - SpriteBank *m_spriteBank; + POLY_FT4 *SprFrame; virtual void collidedWith(CThing *_thisThing); diff --git a/source/enemy/nscrab.cpp b/source/enemy/nscrab.cpp index 2631d56f9..e2a6d0f6f 100644 --- a/source/enemy/nscrab.cpp +++ b/source/enemy/nscrab.cpp @@ -38,7 +38,7 @@ void CNpcSpiderCrabEnemy::postInit() { m_npcPath.setPathType( CNpcPath::PONG_PATH ); - if ( m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy - 8, 16 ) <= 0 ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy - 8, 16 ) <= 0 ) { // starting off below ground, jump initially @@ -169,7 +169,7 @@ void CNpcSpiderCrabEnemy::processClose( int _frames ) // check for collision with ground - if ( m_layerCollision->getHeightFromGround( newPos.vx, newPos.vy ) < 0 ) + if ( CGameScene::getCollision()->getHeightFromGround( newPos.vx, newPos.vy ) < 0 ) { // abort jump @@ -266,7 +266,7 @@ void CNpcSpiderCrabEnemy::processSpiderCrabInitJumpMovement( int _frames ) { // check for collision on the way back down - if ( m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy ) < 0 ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy ) < 0 ) { collision = true; } @@ -325,8 +325,8 @@ void CNpcSpiderCrabEnemy::processMovementModifier( int _frames, s32 distX, s32 d testPos1.vx -= 10; testPos2.vx += 10; - testPos1.vy += m_layerCollision->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); - testPos2.vy += m_layerCollision->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); + testPos1.vy += CGameScene::getCollision()->getHeightFromGround( testPos1.vx, testPos1.vy, 16 ); + testPos2.vy += CGameScene::getCollision()->getHeightFromGround( testPos2.vx, testPos2.vy, 16 ); s32 xDist = testPos2.vx - testPos1.vx; s32 yDist = testPos2.vy - testPos1.vy; diff --git a/source/enemy/nsdart.cpp b/source/enemy/nsdart.cpp index 5fe763bf7..1ce75edcd 100644 --- a/source/enemy/nsdart.cpp +++ b/source/enemy/nsdart.cpp @@ -65,7 +65,7 @@ void CNpcSquidDartEnemy::render() int frame = FRM_SQUIDDART_SWIM0001 + ( m_frame >> 8 ); - SprFrame = m_spriteBank->printFT4(frame,renderPos.vx,renderPos.vy,m_reversed,0,10); + SprFrame = CGameScene::getSpriteBank()->printFT4(frame,renderPos.vx,renderPos.vy,m_reversed,0,10); //setRGB0( SprFrame, 255, 128, 255 ); @@ -106,7 +106,7 @@ void CNpcSquidDartEnemy::fireAsProjectile( s16 heading ) CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, 5*60); - projectile->setLayerCollision( m_layerCollision ); + projectile->setGraphic( FRM_SQUIDDART_SWIM0001 ); projectile->setHasRGB( true ); projectile->setRGB( 255, 128, 255 ); diff --git a/source/enemy/nshell.cpp b/source/enemy/nshell.cpp index 826c73455..abf0d897c 100644 --- a/source/enemy/nshell.cpp +++ b/source/enemy/nshell.cpp @@ -23,6 +23,7 @@ #include "utils\utils.h" #endif +#include "game/game.h" //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -47,7 +48,7 @@ void CNpcShellEnemy::render() { DVECTOR &renderPos=getRenderPos(); - SprFrame = m_spriteBank->printRotatedScaledSprite( m_shellType,renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); + SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( m_shellType,renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); // get xmax, xmin, ymax, ymin diff --git a/source/enemy/nshrkman.cpp b/source/enemy/nshrkman.cpp index 3d6a5fbf2..64fd402c4 100644 --- a/source/enemy/nshrkman.cpp +++ b/source/enemy/nshrkman.cpp @@ -183,7 +183,7 @@ void CNpcSharkManEnemy::processClose( int _frames ) direction = 1; } - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( _frames * m_velocity * direction ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( _frames * m_velocity * direction ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, abort @@ -197,7 +197,7 @@ void CNpcSharkManEnemy::processClose( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { diff --git a/source/enemy/nsj2back.cpp b/source/enemy/nsj2back.cpp index fa74cbca0..cf907fcf3 100644 --- a/source/enemy/nsj2back.cpp +++ b/source/enemy/nsj2back.cpp @@ -55,7 +55,7 @@ void CNpcSmallJellyfish2BackgroundEnemy::render() { DVECTOR &renderPos=getRenderPos(); - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); + SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); setRGB0( SprFrame, 128, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) // get xmax, xmin, ymax, ymin diff --git a/source/enemy/nsjback.cpp b/source/enemy/nsjback.cpp index 3dea6e763..b1d636edd 100644 --- a/source/enemy/nsjback.cpp +++ b/source/enemy/nsjback.cpp @@ -229,7 +229,7 @@ void CNpcSmallJellyfishBackgroundEnemy::render() { DVECTOR &renderPos=getRenderPos(); - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); + SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,15); setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) // get xmax, xmin, ymax, ymin diff --git a/source/enemy/nsjfish.cpp b/source/enemy/nsjfish.cpp index 235fe970e..337b83451 100644 --- a/source/enemy/nsjfish.cpp +++ b/source/enemy/nsjfish.cpp @@ -63,7 +63,7 @@ void CNpcSmallJellyfishEnemy::render() { DVECTOR &renderPos=getRenderPos(); - SprFrame = m_spriteBank->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); + SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( FRM_JELLYFISH1_SWIM1 + ( m_frame >> 8 ),renderPos.vx,renderPos.vy,4096,4096,m_drawRotation,10); setRGB0( SprFrame, 255, 128, 255 ); // Let me know if these change! ALso ket me know when the different coloured ones go in pls! (pkg) // get xmax, xmin, ymax, ymin @@ -380,7 +380,6 @@ void CNpcSmallJellyfishEnemy::fireAsProjectile( s16 heading ) CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, 5*60); - projectile->setLayerCollision( m_layerCollision ); projectile->setGraphic( FRM_JELLYFISH1_SWIM1 ); projectile->setHasRGB( true ); projectile->setRGB( 255, 128, 255 ); diff --git a/source/enemy/nsshark.cpp b/source/enemy/nsshark.cpp index 64a4e49bb..04ebc50e8 100644 --- a/source/enemy/nsshark.cpp +++ b/source/enemy/nsshark.cpp @@ -71,7 +71,6 @@ void CNpcSubSharkEnemy::processMovement( int _frames ) CProjectile *projectile; projectile = new( "test projectile" ) CProjectile; projectile->init( Pos, 1024 ); - projectile->setLayerCollision( m_layerCollision ); m_salvoCount--; diff --git a/source/enemy/nsstomp.cpp b/source/enemy/nsstomp.cpp index f609e6a85..d649ff8b4 100644 --- a/source/enemy/nsstomp.cpp +++ b/source/enemy/nsstomp.cpp @@ -88,7 +88,7 @@ void CNpcSkullStomperEnemy::processClose( int _frames ) { yMovement = m_data[m_type].speed * _frames; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight < yMovement ) { diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index f802638cf..a8503118d 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -126,7 +126,6 @@ void CNpcParasiticWormEnemy::postInit() CNpcParasiticWormSegment *wormSegment; wormSegment = new ("segment") CNpcParasiticWormSegment; wormSegment->init(); - //wormSegment->setLayerCollision( m_layerCollision ); if ( segCount < initLength ) { diff --git a/source/friend/fgary.cpp b/source/friend/fgary.cpp index e4c6273f7..5e268bbdd 100644 --- a/source/friend/fgary.cpp +++ b/source/friend/fgary.cpp @@ -32,7 +32,7 @@ void CNpcGaryFriend::think( int _frames ) // check vertical collision - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= 0 ) { @@ -40,7 +40,7 @@ void CNpcGaryFriend::think( int _frames ) // check horizontal collision - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) { // reverse direction @@ -65,7 +65,7 @@ void CNpcGaryFriend::think( int _frames ) Pos.vy += groundHeight; - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( multiplier * _frames ), Pos.vy ) < -maxHeight ) { // reverse direction diff --git a/source/friend/fplnkton.cpp b/source/friend/fplnkton.cpp index e0525db90..2adee59cd 100644 --- a/source/friend/fplnkton.cpp +++ b/source/friend/fplnkton.cpp @@ -36,6 +36,8 @@ #endif +#include "game/game.h" + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcPlanktonFriend::init() @@ -43,17 +45,12 @@ void CNpcPlanktonFriend::init() CNpcThing::init(); m_extension = EXTEND_RIGHT; - - m_spriteBank=new ("enemy sprites") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcPlanktonFriend::shutdown() { - m_spriteBank->dump(); delete m_spriteBank; - CNpcThing::shutdown(); } @@ -68,8 +65,8 @@ void CNpcPlanktonFriend::render() DVECTOR origRenderPos; DVECTOR offset = CLevel::getCameraPos(); int frame = FRM_PLANKTON_STATIC00; - int spriteWidth = m_spriteBank->getFrameWidth( frame ); - int spriteHeight = m_spriteBank->getFrameHeight( frame ); + int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth( frame ); + int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight( frame ); renderPos.vx = Pos.vx - offset.vx - ( spriteWidth >> 1 ); renderPos.vy = Pos.vy - offset.vy - ( spriteHeight >> 1 ); @@ -84,7 +81,7 @@ void CNpcPlanktonFriend::render() { if ( renderPos.vy + collisionRect.y2 >= 0 && renderPos.vy + collisionRect.y1 <= VidGetScrH() ) { - m_spriteBank->printFT4(frame,renderPos.vx,renderPos.vy,0,0,10); + CGameScene::getSpriteBank()->printFT4(frame,renderPos.vx,renderPos.vy,0,0,10); } } } diff --git a/source/friend/fplnkton.h b/source/friend/fplnkton.h index 6cf8b6bfd..e16952bc6 100644 --- a/source/friend/fplnkton.h +++ b/source/friend/fplnkton.h @@ -27,7 +27,6 @@ public: virtual void shutdown(); protected: virtual void startConderversation(); - SpriteBank *m_spriteBank; }; #endif \ No newline at end of file diff --git a/source/friend/friend.cpp b/source/friend/friend.cpp index e273d650f..32401c92a 100644 --- a/source/friend/friend.cpp +++ b/source/friend/friend.cpp @@ -67,9 +67,11 @@ CNpcFriend *CNpcFriend::Create(sThingActor *ThisActor) { CNpcFriend *friendNpc; - NPC_FRIEND_UNIT_TYPE friendType = CNpcFriend::getTypeFromMapEdit( ThisActor->Type ); + NPC_FRIEND_UNIT_TYPE Type = CNpcFriend::getTypeFromMapEdit( ThisActor->Type ); - switch( friendType ) + friendNpc = (CNpcFriend*)CThingManager::GetThing(CThing::TYPE_NPC,Type); + if (!friendNpc) + switch( Type ) { case CNpcFriend::NPC_FRIEND_BARNACLE_BOY: { @@ -121,7 +123,7 @@ CNpcFriend *CNpcFriend::Create(sThingActor *ThisActor) default: { - printf("UNKNOWN %i\n",friendType); + SYSTEM_DBGMSG("UNKNOWN %i\n",Type); friendNpc = NULL; ASSERT(0); break; @@ -130,7 +132,8 @@ CNpcFriend *CNpcFriend::Create(sThingActor *ThisActor) ASSERT( friendNpc ); - friendNpc->setType( friendType ); + friendNpc->setType( Type ); + friendNpc->setThingSubType(Type); u16 *PntList=(u16*)MakePtr(ThisActor,sizeof(sThingActor)); @@ -191,8 +194,6 @@ void CNpcFriend::postInit() void CNpcFriend::shutdown() { - //m_spriteBank->dump(); delete m_spriteBank; - delete m_actorGfx; CNpcThing::shutdown(); } diff --git a/source/friend/friend.h b/source/friend/friend.h index 75f5b06ce..b3a098540 100644 --- a/source/friend/friend.h +++ b/source/friend/friend.h @@ -37,6 +37,10 @@ public: NPC_FRIEND_PLANKTON, NPC_FRIEND_UNIT_TYPE_MAX, }; + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =NPC_FRIEND_UNIT_TYPE_MAX, + }; virtual void init(); void init( DVECTOR initPos ); @@ -44,15 +48,13 @@ public: virtual void shutdown(); virtual void think(int _frames); virtual void render(); - void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} + + void setType( NPC_FRIEND_UNIT_TYPE newType ) {m_type = newType;} static CNpcFriend *Create(sThingActor *ThisActor); static NPC_FRIEND_UNIT_TYPE getTypeFromMapEdit( u16 newType ); -protected: - class CLayerCollision *m_layerCollision; - protected: typedef struct NPC_FRIEND_DATA_TYPE { diff --git a/source/fx/fx.cpp b/source/fx/fx.cpp index 1cfb8498b..8635f1287 100644 --- a/source/fx/fx.cpp +++ b/source/fx/fx.cpp @@ -101,6 +101,8 @@ CFX *CFX::Create(const FX_TYPE Type) { CFX *NewFX; + NewFX = (CFX*)CThingManager::GetThing(CThing::TYPE_FX,Type); + if (!NewFX) switch(Type) { case FX_TYPE_FALLINGTILE: @@ -161,7 +163,7 @@ CFX *NewFX; ASSERT(!"UNKNOWN FX TYPE"); return NULL; } - + NewFX->setThingSubType(Type); return NewFX; } @@ -194,9 +196,6 @@ CFX *NewFX=CFX::Create(Type); void CFX::init() { CFXThing::init(); - - m_spriteBank=new ("FX Sprite") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); OtPos=OTPOS__ACTOR_POS; Life=-1; @@ -205,7 +204,6 @@ void CFX::init() /*****************************************************************************/ void CFX::shutdown() { - m_spriteBank->dump(); delete m_spriteBank; CFXThing::shutdown(); } diff --git a/source/fx/fx.h b/source/fx/fx.h index 41d48baaf..5b6e9d0cb 100644 --- a/source/fx/fx.h +++ b/source/fx/fx.h @@ -8,7 +8,6 @@ #include "thing/thing.h" /*****************************************************************************/ -class SpriteBank; class CFX : public CFXThing { public: @@ -47,6 +46,11 @@ public: FX_TYPE_FLAMES, FX_TYPE_EXPLODE, FX_TYPE_DEBRIS, + FX_TYPE_MAX + }; + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =FX_TYPE_MAX, }; static CFX *Create(const FX_TYPE Type); @@ -65,7 +69,6 @@ virtual void setDie() {DieOut=true;} virtual void setLife(int L) {Life=L;} protected: - SpriteBank *m_spriteBank; s32 OtPos; u8 DieOut; diff --git a/source/fx/fxbaseanim.cpp b/source/fx/fxbaseanim.cpp index ab068913a..0343ce147 100644 --- a/source/fx/fxbaseanim.cpp +++ b/source/fx/fxbaseanim.cpp @@ -9,7 +9,7 @@ #include "gfx\sprbank.h" #include #include "level\level.h" - +#include "game\game.h" #include "FX\FXBaseAnim.h" @@ -58,11 +58,11 @@ void CFXBaseAnim::render() CFX::render(); if (!canRender() || isSetToShutdown()) return; - +SpriteBank *SprBank=CGameScene::getSpriteBank(); DVECTOR &RenderPos=getRenderPos(); int ThisFrame=Frame>>FrameShift; -POLY_FT4 *Ft4=m_spriteBank->printFT4Scaled(BaseFrame+ThisFrame,RenderPos.vx,RenderPos.vy,0,0,OtPos*0,Scale>>4); +POLY_FT4 *Ft4=SprBank->printFT4Scaled(BaseFrame+ThisFrame,RenderPos.vx,RenderPos.vy,0,0,OtPos*0,Scale>>4); Ft4->u1--; Ft4->u3--; Ft4->v2--; Ft4->v3--; setRGB0(Ft4,R,G,B); diff --git a/source/fx/fxbasetrail.cpp b/source/fx/fxbasetrail.cpp index 26d001c97..3e5ce4a96 100644 --- a/source/fx/fxbasetrail.cpp +++ b/source/fx/fxbasetrail.cpp @@ -9,6 +9,7 @@ #include "gfx\sprbank.h" #include #include "level\level.h" +#include "game\game.h" #include "FX\FXBaseTrail.h" @@ -65,7 +66,7 @@ void CFXBaseTrail::render() if (canRender()) { DVECTOR RenderPos=getRenderPos(); - + SpriteBank *SprBank=CGameScene::getSpriteBank(); int ThisIdx=HeadIdx; int StartY=RenderPos.vy; @@ -78,7 +79,7 @@ void CFXBaseTrail::render() RenderPos.vy+=ThisElem.Ofs.vy>>2; if (ThisElem.Shade) { - Ft4=m_spriteBank->printRotatedScaledSprite(ThisElem.Frame,RenderPos.vx,RenderPos.vy,ThisElem.Scale,ThisElem.Scale,ThisElem.Angle,OtPos*0); + Ft4=SprBank->printRotatedScaledSprite(ThisElem.Frame,RenderPos.vx,RenderPos.vy,ThisElem.Scale,ThisElem.Scale,ThisElem.Angle,OtPos*0); setShadeTex(Ft4,0); setRGB0(Ft4,ThisElem.Shade,ThisElem.Shade,ThisElem.Shade); setSemiTrans(Ft4,1); diff --git a/source/fx/fxjfish.cpp b/source/fx/fxjfish.cpp index 2a18b05d8..8b009ce37 100644 --- a/source/fx/fxjfish.cpp +++ b/source/fx/fxjfish.cpp @@ -72,7 +72,6 @@ int AInc=1024/Width; if (dH>8) dH=8; if (dH<2) dH=2; HeightTable[H]=(s16)dH; -// printf("%i %i =%i\n",H,Ofs,HeightTable[H]); } */ } @@ -144,7 +143,7 @@ s16 *dH=HeightTable; for (int i=0; i=Count) Idx=0; - POLY_FT4 *Ft4=m_spriteBank->printFT4(FRM__TENTACLE,LastPos.vx,LastPos.vy,0,0,OtPos); + POLY_FT4 *Ft4=CGameScene::getSpriteBank()->printFT4(FRM__TENTACLE,LastPos.vx,LastPos.vy,0,0,OtPos); Ft4->x0=LastPos.vx+0+LastdW; Ft4->y0=LastPos.vy; Ft4->x1=LastPos.vx+8-LastdW; Ft4->y1=LastPos.vy; diff --git a/source/game/game.cpp b/source/game/game.cpp index 04f7f8cb5..dffd98293 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -81,8 +81,10 @@ int RenderZ=256; /*****************************************************************************/ -FontBank *CGameScene::s_genericFont; -MATRIX CGameScene::CamMtx; +FontBank *CGameScene::s_genericFont; +SpriteBank *CGameScene::s_GlobalSpritebank; +CLayerCollision *CGameScene::s_GlobalCollision; +MATRIX CGameScene::CamMtx; /*****************************************************************************/ CGameScene::ACTOR_TYPE CGameScene::actorType[40] = @@ -330,7 +332,7 @@ void CGameScene::sendEvent( GAME_EVENT evt, CThing *sourceThing ) /*****************************************************************************/ void CGameScene::initLevel() { - printf("InitLevel\n"); + SYSTEM_DBGMSG("InitLevel\n"); CThingManager::init(); CConversation::init(); @@ -342,7 +344,6 @@ void CGameScene::initLevel() createPlayer(); m_player->setRespawnPos(Level.getPlayerSpawnPos()); m_player->init(); - m_player->setLayerCollision(Level.getCollisionLayer()); DVECTOR mapSize=Level.getMapSize(); CPlayer::CameraBox camBox={0,0,mapSize.vx<<4,mapSize.vy<<4}; m_player->setCameraBox(camBox); @@ -351,7 +352,7 @@ void CGameScene::initLevel() // better timing over when it starts (pkg) CSoundMediator::playSong(); CActorPool::SetUpCache(); - printf("InitLevelDone\n"); + SYSTEM_DBGMSG("InitLevelDone\n"); } diff --git a/source/game/game.h b/source/game/game.h index ed7ab01e5..5fb8c310b 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -16,6 +16,7 @@ class FontBank; class SpriteBank; class CPlayer; +class CLayerCollision; class CGameScene : public CScene { public: @@ -74,6 +75,17 @@ static int s_levelFinished; static ACTOR_TYPE actorType[]; +// global vars +public: +static void setSpriteBank(SpriteBank *SprBank) {s_GlobalSpritebank=SprBank;} +static SpriteBank *getSpriteBank() {return(s_GlobalSpritebank);} + +static void setCollision(CLayerCollision *Col) {s_GlobalCollision=Col;} +static CLayerCollision *getCollision() {return(s_GlobalCollision);} + +static SpriteBank *s_GlobalSpritebank; +static CLayerCollision *s_GlobalCollision; + }; diff --git a/source/gfx/actor.cpp b/source/gfx/actor.cpp index 4b46b2f54..7aae84d3f 100644 --- a/source/gfx/actor.cpp +++ b/source/gfx/actor.cpp @@ -61,12 +61,12 @@ int SlotW=+32000,SlotH=+32000; if (SlotList[Slot].Width>ACCURACY_SHIFT))>>12; - ft4=CBubicleFactory::getSprites()->printFT4(m_fhBub,0,0,0,0,m_data.m_ot); + ft4=CGameScene::getSpriteBank()->printFT4(m_fhBub,0,0,0,0,m_data.m_ot); setXYWH(ft4,x,y,w,h); setSemiTrans(ft4,1); setRGB0(ft4,m_data.m_colour.m_r,m_data.m_colour.m_g,m_data.m_colour.m_b); @@ -386,13 +384,10 @@ void CBubicleFactory::init() int i; CBubicleEmitter *emt; CBubicle *bub; - - s_sprites=new ("Bubble Sprites") SpriteBank(); - s_sprites->load(SPRITES_SPRITES_SPR); - + SpriteBank *SprBank=CGameScene::getSpriteBank(); for(i=0;igetFrameHeader(s_frameTabSrc[i]); + s_frameTab[i]=SprBank->getFrameHeader(s_frameTabSrc[i]); } emt=s_emitters=(CBubicleEmitter*)MemAlloc(sizeof(CBubicleEmitter)*NUM_EMITTERS,"BubicleEmitters"); @@ -421,7 +416,6 @@ void CBubicleFactory::shutdown() MemFree(s_emitters); MemFree(s_bubicles); - s_sprites->dump(); delete s_sprites; s_initialised=false; } diff --git a/source/gfx/bubicles.h b/source/gfx/bubicles.h index fe6a8f422..2bfd5b70f 100644 --- a/source/gfx/bubicles.h +++ b/source/gfx/bubicles.h @@ -162,7 +162,6 @@ public: static CBubicleEmitter *spawnEmitter(BubicleEmitterData *_init); static CBubicle *spawnParticle(BubicleEmitterData *_init); static sFrameHdr *getBubbleFrameHeader(); - static SpriteBank *getSprites() {return s_sprites;} static void setMapOffset(DVECTOR *_offset); static const DVECTOR *getMapOffset(); @@ -180,7 +179,6 @@ private: static int s_initialised; static CBubicleEmitter *s_emitters; static CBubicle *s_bubicles; - static SpriteBank *s_sprites; static int s_frameTypeCounter; static const int s_frameTabSize; diff --git a/source/gfx/prim.cpp b/source/gfx/prim.cpp index 3900378b9..1c6f69b72 100644 --- a/source/gfx/prim.cpp +++ b/source/gfx/prim.cpp @@ -70,7 +70,6 @@ void PrimDisplay() /*****************************************************************************/ void FlushPrimPool() { - printf("%x %x\n",(int)CurrPrim,(int)PrimBuffer[PrimFlipFlag]); BaseOtPtr=(sOT*)OtList[PrimFlipFlag]; GUIOtPtr=BaseOtPtr; OtPtr=GUIOtPtr+MAX_OT_GUI; diff --git a/source/gfx/sprbank.cpp b/source/gfx/sprbank.cpp index 0d29c2fe9..ef651eb5e 100644 --- a/source/gfx/sprbank.cpp +++ b/source/gfx/sprbank.cpp @@ -181,6 +181,7 @@ void SpriteBank::load( FileEquate _file ) } else { +// ASSERT(!"Sprite Bank Already Loaded"); SpriteBankInstance *sbiPtr=s_bankList; do { diff --git a/source/gui/gui.cpp b/source/gui/gui.cpp index e423b1c20..3c0a8d4ff 100644 --- a/source/gui/gui.cpp +++ b/source/gui/gui.cpp @@ -30,6 +30,7 @@ #include "gfx\prim.h" #endif +#include "game\game.h" /* Std Lib ------- */ @@ -369,7 +370,7 @@ void CGUIObjectWithSpriteBank::shutdown() CGUIObject::shutdown(); m_spriteBank->dump(); - delete m_spriteBank; +// delete m_spriteBank; m_spriteBank=0; } @@ -382,8 +383,9 @@ void CGUIObjectWithSpriteBank::shutdown() ---------------------------------------------------------------------- */ void CGUIObjectWithSpriteBank::setSpriteBank(FileEquate _fe) { - m_spriteBank=new ("spritebank") SpriteBank(); - m_spriteBank->load(_fe); +// m_spriteBank=new ("spritebank") SpriteBank(); +// m_spriteBank->load(_fe); + m_spriteBank=CGameScene::getSpriteBank(); } @@ -402,8 +404,10 @@ void initGUIStuff() { ASSERT(!s_uiSpriteBank); - s_uiSpriteBank=new ("UI Sprites") SpriteBank(); - s_uiSpriteBank->load(SPRITES_SPRITES_SPR); +// s_uiSpriteBank=new ("UI Sprites") SpriteBank(); +// s_uiSpriteBank->load(SPRITES_SPRITES_SPR); + s_uiSpriteBank=CGameScene::getSpriteBank(); + } diff --git a/source/hazard/hazard.cpp b/source/hazard/hazard.cpp index 6dcd71ba7..777ec4e02 100644 --- a/source/hazard/hazard.cpp +++ b/source/hazard/hazard.cpp @@ -144,9 +144,11 @@ CNpcHazard *CNpcHazard::Create(sThingHazard *ThisHazard) { CNpcHazard *hazard; - NPC_HAZARD_UNIT_TYPE hazardType = getTypeFromMapEdit( ThisHazard->Type ); + NPC_HAZARD_UNIT_TYPE Type = getTypeFromMapEdit( ThisHazard->Type ); - switch( hazardType ) + hazard = (CNpcHazard*)CThingManager::GetThing(CThing::TYPE_HAZARD,Type); + if (!hazard) + switch( Type ) { case NPC_FALLING_HAZARD: { @@ -277,7 +279,8 @@ CNpcHazard *CNpcHazard::Create(sThingHazard *ThisHazard) ASSERT( hazard ); - hazard->setType( hazardType ); + hazard->setType( Type ); + hazard->setThingSubType(Type); hazard->init(); hazard->setWaypoints( ThisHazard ); hazard->setGraphic( ThisHazard ); @@ -348,9 +351,6 @@ void CNpcHazard::init() { CHazardThing::init(); - //m_actorGfx=CActorPool::GetActor( (FileEquate) ACTORS_CLAM_SBK ); - //m_spriteBank=0; - m_npcPath.initPath(); m_timer = 0; @@ -381,7 +381,6 @@ void CNpcHazard::setGraphic( sThingHazard *ThisHazard ) void CNpcHazard::shutdown() { delete m_modelGfx; - //if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank; // remove waypoints m_npcPath.removeAllWaypoints(); diff --git a/source/hazard/hazard.h b/source/hazard/hazard.h index b836ac4e1..533b843e9 100644 --- a/source/hazard/hazard.h +++ b/source/hazard/hazard.h @@ -59,13 +59,16 @@ public: NPC_HAZARD_TYPE_MAX, }; + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =NPC_HAZARD_TYPE_MAX, + }; virtual void init(); void setGraphic( sThingHazard *ThisHazard ); void shutdown(); void think(int _frames); virtual void render(); - void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} virtual void setWaypoints( sThingHazard *ThisHazard ); void addWaypoint( s32 xPos, s32 yPos ); virtual void setRespawnRate( s16 newRespawnRate ) {m_respawnRate=newRespawnRate;} @@ -97,12 +100,10 @@ protected: NPC_HAZARD_UNIT_TYPE m_type; CNpcPath m_npcPath; //CActorGfx *m_actorGfx; - //SpriteBank *m_spriteBank; DVECTOR m_base; s32 m_timer; bool m_timerActive; bool m_isActive; - class CLayerCollision *m_layerCollision; s32 m_extension; bool m_extendDir; s32 m_heading; diff --git a/source/hazard/hbarrel.cpp b/source/hazard/hbarrel.cpp index 3991f213a..4a1daa40a 100644 --- a/source/hazard/hbarrel.cpp +++ b/source/hazard/hbarrel.cpp @@ -19,6 +19,8 @@ #include "level\layercollision.h" #endif +#include "game\game.h" + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcBarrelHazard::init() @@ -61,7 +63,7 @@ void CNpcBarrelHazard::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -83,7 +85,7 @@ void CNpcBarrelHazard::processMovement( int _frames ) distX = distX / abs( distX ); - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * 3 * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * 3 * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -93,7 +95,7 @@ void CNpcBarrelHazard::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); moveX = distX * 3 * _frames; diff --git a/source/hazard/hboat.cpp b/source/hazard/hboat.cpp index 87d702f1e..0b1b6911b 100644 --- a/source/hazard/hboat.cpp +++ b/source/hazard/hboat.cpp @@ -64,7 +64,7 @@ void CNpcBoatHazard::processMovement( int _frames ) // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -94,7 +94,7 @@ void CNpcBoatHazard::processMovement( int _frames ) m_reversed = true; } - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * 3 * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * 3 * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -104,7 +104,7 @@ void CNpcBoatHazard::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { diff --git a/source/hazard/hdbarrel.cpp b/source/hazard/hdbarrel.cpp index 1d3c86ffc..c20704523 100644 --- a/source/hazard/hdbarrel.cpp +++ b/source/hazard/hdbarrel.cpp @@ -31,6 +31,9 @@ #include "level\level.h" #endif +#include "game\game.h" + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcDualPlatformBarrelHazard::init() @@ -80,7 +83,7 @@ void CNpcDualPlatformBarrelHazard::processMovement( int _frames ) distX = distX / abs( distX ); } - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * 3 * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * 3 * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -90,7 +93,7 @@ void CNpcDualPlatformBarrelHazard::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { diff --git a/source/hazard/hfalling.cpp b/source/hazard/hfalling.cpp index 7d1381605..7cc5f0520 100644 --- a/source/hazard/hfalling.cpp +++ b/source/hazard/hfalling.cpp @@ -92,7 +92,7 @@ void CNpcFallingHazard::processMovement( int _frames ) { yMovement = 3 * _frames; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight < yMovement ) { diff --git a/source/hazard/hmasher.cpp b/source/hazard/hmasher.cpp index ead2ca51a..3a97566c5 100644 --- a/source/hazard/hmasher.cpp +++ b/source/hazard/hmasher.cpp @@ -19,6 +19,8 @@ #include "level\layercollision.h" #endif +#include "game\game.h" + void CNpcMasherHazard::init() { CNpcHazard::init(); @@ -36,7 +38,7 @@ void CNpcMasherHazard::processMovement( int _frames ) s8 groundHeight; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight < yMovement ) { diff --git a/source/hazard/hrckshrd.cpp b/source/hazard/hrckshrd.cpp index 1ef822496..2863040e8 100644 --- a/source/hazard/hrckshrd.cpp +++ b/source/hazard/hrckshrd.cpp @@ -64,7 +64,7 @@ void CNpcRockShardHazard::processMovement( int _frames ) { yMovement = 6 * _frames; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight < yMovement ) { diff --git a/source/hazard/hrrock.cpp b/source/hazard/hrrock.cpp index 100685bcc..ab6dd5d11 100644 --- a/source/hazard/hrrock.cpp +++ b/source/hazard/hrrock.cpp @@ -19,6 +19,8 @@ #include "level\layercollision.h" #endif +#include "game\game.h" + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CNpcRollingRockHazard::init() @@ -90,7 +92,7 @@ void CNpcRollingRockHazard::processMovement( int _frames ) moveY += m_jumpVel >> 8; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); if ( groundHeight < 16 ) { @@ -104,7 +106,7 @@ void CNpcRollingRockHazard::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy, 64 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy, 64 ); if ( groundHeight < 64 ) { @@ -129,7 +131,7 @@ void CNpcRollingRockHazard::processMovement( int _frames ) // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { diff --git a/source/jellfish/jellfish.cpp b/source/jellfish/jellfish.cpp index 6fde41b11..8b3826113 100644 --- a/source/jellfish/jellfish.cpp +++ b/source/jellfish/jellfish.cpp @@ -43,6 +43,7 @@ #include "system\vid.h" #endif +#include "game\game.h" //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -109,10 +110,14 @@ void CJellyfishGenerator::think( int _frames, CLevel *level ) { case 1: { - enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; - ASSERT(enemy); + enemy = (CNpcEnemy*)CThingManager::GetThing(CThing::TYPE_ENEMY,CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND); + if (!enemy) + { + enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; + ASSERT(enemy); + } enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND ); - + enemy->setThingSubType(CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND); break; } @@ -120,15 +125,25 @@ void CJellyfishGenerator::think( int _frames, CLevel *level ) { if ( getRnd() % 4 == 0 ) { - enemy = new( "jellyfish" ) CNpcSmallJellyfish2BackgroundEnemy; - ASSERT(enemy); + enemy = (CNpcEnemy*)CThingManager::GetThing(CThing::TYPE_ENEMY,CNpcEnemy::NPC_SMALL_JELLYFISH_2_BACKGROUND); + if (!enemy) + { + enemy = new( "jellyfish" ) CNpcSmallJellyfish2BackgroundEnemy; + ASSERT(enemy); + } enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_2_BACKGROUND ); + enemy->setThingSubType(CNpcEnemy::NPC_SMALL_JELLYFISH_2_BACKGROUND); } else { - enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; - ASSERT(enemy); + enemy = (CNpcEnemy*)CThingManager::GetThing(CThing::TYPE_ENEMY,CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND); + if (!enemy) + { + enemy = new( "jellyfish" ) CNpcSmallJellyfishBackgroundEnemy; + ASSERT(enemy); + } enemy->setType( CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND ); + enemy->setThingSubType(CNpcEnemy::NPC_SMALL_JELLYFISH_BACKGROUND); } break; @@ -136,16 +151,19 @@ void CJellyfishGenerator::think( int _frames, CLevel *level ) case 3: { - enemy = new( "butterfly" ) CNpcButterflyBackgroundEnemy; - ASSERT(enemy); + enemy = (CNpcEnemy*)CThingManager::GetThing(CThing::TYPE_ENEMY,CNpcEnemy::NPC_BUTTERFLY_BACKGROUND); + if (!enemy) + { + enemy = new( "butterfly" ) CNpcButterflyBackgroundEnemy; + ASSERT(enemy); + } enemy->setType( CNpcEnemy::NPC_BUTTERFLY_BACKGROUND ); - + enemy->setThingSubType(CNpcEnemy::NPC_BUTTERFLY_BACKGROUND); break; } } enemy->init(); - enemy->setLayerCollision( level->getCollisionLayer() ); DVECTOR offset = CLevel::getCameraPos(); diff --git a/source/level/layerback.cpp b/source/level/layerback.cpp index be578fe89..545462cbf 100644 --- a/source/level/layerback.cpp +++ b/source/level/layerback.cpp @@ -119,7 +119,6 @@ sLayerShadeBackGfx *GfxList=Data->GfxList; // Render Back Shade -// printf("%i %i\n",ThisY,BandHeight); if (BandHeight>256) BandHeight=256; // if (ThisY<0) BandHeight=256; for (i=0; iWidth; MapHeight=LayerHdr->Height; - printf("COLLISION LAYER = %i %i\n",MapWidth,MapHeight); +// printf("COLLISION LAYER = %i %i\n",MapWidth,MapHeight); } /*****************************************************************************/ diff --git a/source/level/layertile.cpp b/source/level/layertile.cpp index 69721baaa..d57263930 100644 --- a/source/level/layertile.cpp +++ b/source/level/layertile.cpp @@ -25,7 +25,7 @@ CLayerTile::CLayerTile(sLevelHdr *LevelHdr,sLayerHdr *Hdr) MapWidth=LayerHdr->Width; MapHeight=LayerHdr->Height; - printf("%i %i\n",MapWidth,MapHeight); +// printf("%i %i\n",MapWidth,MapHeight); TileBank2d=LevelHdr->TileBank2d; Map=(sTileMapElem*)MakePtr(Hdr,sizeof(sLayerHdr)); } diff --git a/source/map/map.cpp b/source/map/map.cpp index dff5649ce..e3ef7c917 100644 --- a/source/map/map.cpp +++ b/source/map/map.cpp @@ -140,10 +140,6 @@ void CMapScene::init() m_font->setOt(10); m_font->setJustification(FontBank::JUST_LEFT); - m_spriteBank=new ("map screen sprite") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); - - m_currentChapterSelection=0; m_currentLevelSelection=0; m_screenImage=MemAlloc(512*256*2,"MapScreen"); @@ -165,7 +161,6 @@ void CMapScene::shutdown() { ClearScreenImage(); MemFree(m_screenImage); - m_spriteBank->dump(); delete m_spriteBank; m_font->dump(); delete m_font; } @@ -196,8 +191,8 @@ void CMapScene::render() { sprintf(spatCount,"%d/%d",getSpatulaCollectedCount(m_currentChapterSelection,i),getSpatulaAvailableCount(m_currentChapterSelection,i)); m_font->print(xpos,ypos,spatCount); - fh=m_spriteBank->getFrameHeader(s_mapLevelData[m_currentChapterSelection].m_questItemFrames[i]); - ft4=m_spriteBank->printFT4Scaled(fh,xpos+MAP_LEVEL_WIDTH-fh->W,ypos+MAP_LEVEL_HEIGHT-fh->H,0,0,10,128); + fh=CGameScene::getSpriteBank()->getFrameHeader(s_mapLevelData[m_currentChapterSelection].m_questItemFrames[i]); + ft4=CGameScene::getSpriteBank()->printFT4Scaled(fh,xpos+MAP_LEVEL_WIDTH-fh->W,ypos+MAP_LEVEL_HEIGHT-fh->H,0,0,10,128); if(!hasQuestItemBeenCollected(m_currentChapterSelection,i)) { setRGB0(ft4,10,10,10); @@ -209,8 +204,8 @@ void CMapScene::render() } // Selection cursor - fh=m_spriteBank->getFrameHeader(FRM__MAPPOINTER); - m_spriteBank->printFT4(fh,m_pointerPos.vx-(fh->W/2),m_pointerPos.vy-(fh->H/2),0,0,9); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__MAPPOINTER); + CGameScene::getSpriteBank()->printFT4(fh,m_pointerPos.vx-(fh->W/2),m_pointerPos.vy-(fh->H/2),0,0,9); char buf[100]; sprintf(buf,"Chapter %d, Level %d",m_currentChapterSelection+1,m_currentLevelSelection+1); diff --git a/source/map/map.h b/source/map/map.h index 4446d5b00..1c98c0432 100644 --- a/source/map/map.h +++ b/source/map/map.h @@ -91,8 +91,6 @@ private: char *m_screenImage; - class SpriteBank *m_spriteBank; - int m_currentChapterSelection; int m_currentLevelSelection; DVECTOR m_pointerPos; diff --git a/source/pickups/pballoon.cpp b/source/pickups/pballoon.cpp index f6a4c7aa5..9c33c13b6 100644 --- a/source/pickups/pballoon.cpp +++ b/source/pickups/pballoon.cpp @@ -45,6 +45,7 @@ #include "gfx\otpos.h" #endif +#include "game\game.h" /* Std Lib ------- */ @@ -86,7 +87,7 @@ void CBalloonPickup::init() CBaseWeaponPickup::init(); m_sin=0; - fh=getSpriteBank()->getFrameHeader(FRM__BALLOON); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__BALLOON); setCollisionSize(fh->W,fh->H); } @@ -101,7 +102,7 @@ DVECTOR CBalloonPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__BALLOON); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__BALLOON); size.vx=fh->W; size.vy=fh->H; return size; @@ -179,7 +180,7 @@ void CBalloonPickup::renderPickup(DVECTOR *_pos) int xo1,xo2; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__BALLOON); xo1=((msin((m_sin+balloon_phase)&4095)*balloon_scale1)>>12); diff --git a/source/pickups/pbubmix.cpp b/source/pickups/pbubmix.cpp index f1a9ea7b1..931e287a9 100644 --- a/source/pickups/pbubmix.cpp +++ b/source/pickups/pbubmix.cpp @@ -37,6 +37,7 @@ #include "gfx\otpos.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -78,7 +79,7 @@ void CBubbleMixturePickup::init() CBaseRespawningPickup::init(); m_sin=0; - fh=getSpriteBank()->getFrameHeader(FRM__BUBBLEMIXTURE); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__BUBBLEMIXTURE); setCollisionSize(fh->W,fh->H); } @@ -93,7 +94,7 @@ DVECTOR CBubbleMixturePickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__BUBBLEMIXTURE); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__BUBBLEMIXTURE); size.vx=fh->W; size.vy=fh->H; return size; @@ -147,7 +148,7 @@ void CBubbleMixturePickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__BUBBLEMIXTURE); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2)+((msin(m_sin)*bubmix_bobscale)>>12); diff --git a/source/pickups/pglasses.cpp b/source/pickups/pglasses.cpp index 7a83d7971..5ce8ab730 100644 --- a/source/pickups/pglasses.cpp +++ b/source/pickups/pglasses.cpp @@ -33,6 +33,7 @@ #include "gfx\otpos.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -76,7 +77,7 @@ void CGlassesPickup::init() m_glint=0; m_glintRot=0; - fh=getSpriteBank()->getFrameHeader(FRM__GLASSES); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__GLASSES); setCollisionSize(fh->W,fh->H); GameScene.getPlayer()->registerAddon(PLAYER_ADDON_GLASSES); @@ -93,7 +94,7 @@ DVECTOR CGlassesPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__GLASSES); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__GLASSES); size.vx=fh->W; size.vy=fh->H; return size; @@ -144,7 +145,7 @@ void CGlassesPickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__GLASSES); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2); diff --git a/source/pickups/phealth.cpp b/source/pickups/phealth.cpp index 79211e7b4..ae554c5a4 100644 --- a/source/pickups/phealth.cpp +++ b/source/pickups/phealth.cpp @@ -33,6 +33,7 @@ #include "gfx\otpos.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -74,7 +75,7 @@ void CBaseHealthPickup::init() CBasePickup::init(); m_sin=0; - fh=getSpriteBank()->getFrameHeader(getFrameNumber()); + fh=CGameScene::getSpriteBank()->getFrameHeader(getFrameNumber()); setCollisionSize(fh->W,fh->H); } @@ -89,7 +90,7 @@ DVECTOR CBaseHealthPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(getFrameNumber()); + fh=CGameScene::getSpriteBank()->getFrameHeader(getFrameNumber()); size.vx=fh->W; size.vy=fh->H; return size; @@ -132,7 +133,7 @@ void CBaseHealthPickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int angle; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(getFrameNumber()); angle=((msin(m_sin)*health_rotatescale)>>12)&4095; sprites->printRotatedScaledSprite(fh,_pos->vx,_pos->vy,4096,4096,angle,OTPOS__PICKUP_POS); diff --git a/source/pickups/phelmet.cpp b/source/pickups/phelmet.cpp index 87d3a36e5..170722a77 100644 --- a/source/pickups/phelmet.cpp +++ b/source/pickups/phelmet.cpp @@ -29,6 +29,7 @@ #include "gfx\otpos.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -69,7 +70,7 @@ void CHelmetPickup::init() CBasePickup::init(); - fh=getSpriteBank()->getFrameHeader(FRM__HELMET); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__HELMET); setCollisionSize(fh->W,fh->H); } @@ -84,7 +85,7 @@ DVECTOR CHelmetPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__HELMET); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__HELMET); size.vx=fh->W; size.vy=fh->H; return size; @@ -115,7 +116,7 @@ void CHelmetPickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__HELMET); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2); diff --git a/source/pickups/pickup.cpp b/source/pickups/pickup.cpp index 4419cc047..647d9ec09 100644 --- a/source/pickups/pickup.cpp +++ b/source/pickups/pickup.cpp @@ -79,6 +79,7 @@ #include "pickups\pquest.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -117,8 +118,6 @@ void CBasePickup::init() { CPickupThing::init(); - m_spriteBank=new ("pickup sprite") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); } /*---------------------------------------------------------------------- @@ -129,7 +128,6 @@ void CBasePickup::init() ---------------------------------------------------------------------- */ void CBasePickup::shutdown() { - m_spriteBank->dump(); delete m_spriteBank; CPickupThing::shutdown(); } @@ -320,7 +318,7 @@ void CBaseWeaponSimplePickup::init() CBaseWeaponPickup::init(); - fh=getSpriteBank()->getFrameHeader(FRM__NET); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__NET); setCollisionSize(fh->W,fh->H); } @@ -335,7 +333,7 @@ DVECTOR CBaseWeaponSimplePickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(getWeaponSpriteFrame()); + fh=CGameScene::getSpriteBank()->getFrameHeader(getWeaponSpriteFrame()); size.vx=fh->W; size.vy=fh->H; return size; @@ -353,7 +351,7 @@ void CBaseWeaponSimplePickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(getWeaponSpriteFrame()); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2); @@ -374,6 +372,8 @@ CBasePickup *createPickup(const PICKUP_TYPE _type,const DVECTOR *_pos) CBasePickup *pickup; DVECTOR pickupPos; + pickup = (CBasePickup*)CThingManager::GetThing(CThing::TYPE_PICKUP,_type); + if (!pickup) switch(_type) { case PICKUP__BIG_HEALTH: @@ -447,6 +447,7 @@ CBasePickup *createPickup(const PICKUP_TYPE _type,const DVECTOR *_pos) return NULL; } + pickup->setThingSubType(_type); pickup->init(); pickupPos=pickup->getSizeForPlacement(); pickupPos.vx=_pos->vx+(pickupPos.vx/2); diff --git a/source/pickups/pickup.h b/source/pickups/pickup.h index 6d88cb451..0495c088a 100644 --- a/source/pickups/pickup.h +++ b/source/pickups/pickup.h @@ -49,6 +49,7 @@ typedef enum PICKUP__QUEST_ITEM, PICKUP__BALLOON_AND_SPATULA, PICKUP__JELLY_LAUNCHER, + PICKUP__MAX } PICKUP_TYPE; @@ -60,6 +61,10 @@ PICKUP_TYPE; class CBasePickup : public CPickupThing { public: + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =PICKUP__MAX, + }; virtual void init(); virtual void shutdown(); virtual void think(int _frames); @@ -75,7 +80,6 @@ protected: DEFAULT_VISIBILITY_RADIUS=32, }; - class SpriteBank *getSpriteBank() {return m_spriteBank;} virtual int getVisibilityRadius() {return DEFAULT_VISIBILITY_RADIUS;} virtual void thinkPickup(int _Frames) {;} @@ -84,7 +88,6 @@ protected: virtual void collidedWith(CThing *_thisThing); private: - class SpriteBank *m_spriteBank; }; diff --git a/source/pickups/pjlammo.cpp b/source/pickups/pjlammo.cpp index 2caf69ba8..2caaab0a7 100644 --- a/source/pickups/pjlammo.cpp +++ b/source/pickups/pjlammo.cpp @@ -37,6 +37,7 @@ #include "gfx\otpos.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -78,7 +79,7 @@ void CJellyLauncherAmmoPickup::init() CBasePickup::init(); m_rattle=0; - fh=getSpriteBank()->getFrameHeader(FRM__JELLYAMMO); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__JELLYAMMO); setCollisionSize(fh->W,fh->H); } @@ -93,7 +94,7 @@ DVECTOR CJellyLauncherAmmoPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__JELLYAMMO); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__JELLYAMMO); size.vx=fh->W; size.vy=fh->H; return size; @@ -139,7 +140,7 @@ void CJellyLauncherAmmoPickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int angle; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__JELLYAMMO); if(m_rattle<=jlammo_rattlecount*4095) { diff --git a/source/pickups/plife.cpp b/source/pickups/plife.cpp index c0b162721..a40c0ff84 100644 --- a/source/pickups/plife.cpp +++ b/source/pickups/plife.cpp @@ -33,6 +33,7 @@ #include "gfx\otpos.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -74,7 +75,7 @@ void CLifePickup::init() CBasePickup::init(); m_sin=0; - fh=getSpriteBank()->getFrameHeader(FRM__PANTS); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__PANTS); setCollisionSize(fh->W,fh->H); } @@ -89,7 +90,7 @@ DVECTOR CLifePickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__PANTS); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__PANTS); size.vx=fh->W; size.vy=fh->H; return size; @@ -133,7 +134,7 @@ void CLifePickup::renderPickup(DVECTOR *_pos) int x,y; int size; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__PANTS); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2); diff --git a/source/pickups/pquest.cpp b/source/pickups/pquest.cpp index 901e02b2a..b472dc5bf 100644 --- a/source/pickups/pquest.cpp +++ b/source/pickups/pquest.cpp @@ -37,6 +37,7 @@ #include "game\game.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -130,7 +131,7 @@ void CQuestItemPickup::init() } ASSERT(m_gfxFrame!=-1); - fh=getSpriteBank()->getFrameHeader(m_gfxFrame); + fh=CGameScene::getSpriteBank()->getFrameHeader(m_gfxFrame); setCollisionSize(fh->W,fh->H); } @@ -145,7 +146,7 @@ DVECTOR CQuestItemPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(m_gfxFrame); + fh=CGameScene::getSpriteBank()->getFrameHeader(m_gfxFrame); size.vx=fh->W; size.vy=fh->H; return size; @@ -209,7 +210,7 @@ void CQuestItemPickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(m_gfxFrame); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2); diff --git a/source/pickups/pshoes.cpp b/source/pickups/pshoes.cpp index 3e9a9ee81..5fc2760b1 100644 --- a/source/pickups/pshoes.cpp +++ b/source/pickups/pshoes.cpp @@ -33,6 +33,7 @@ #include "gfx\otpos.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -74,7 +75,7 @@ void CShoesPickup::init() CBaseRespawningPickup::init(); m_sin=0; - fh=getSpriteBank()->getFrameHeader(FRM__SHOE); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__SHOE); setCollisionSize(fh->W,fh->H); } @@ -89,7 +90,7 @@ DVECTOR CShoesPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__SHOE); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__SHOE); size.vx=fh->W; size.vy=fh->H; return size; @@ -144,7 +145,7 @@ void CShoesPickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int x,y,yoff; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__SHOE); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2); diff --git a/source/pickups/pspatula.cpp b/source/pickups/pspatula.cpp index 5bff044f2..e86cf97a9 100644 --- a/source/pickups/pspatula.cpp +++ b/source/pickups/pspatula.cpp @@ -37,6 +37,7 @@ #include "game\game.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -79,7 +80,7 @@ void CSpatulaPickup::init() m_glint=0; m_glintRot=0; - fh=getSpriteBank()->getFrameHeader(FRM__SPATULA); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__SPATULA); setCollisionSize(fh->W,fh->H); } @@ -94,7 +95,7 @@ DVECTOR CSpatulaPickup::getSizeForPlacement() DVECTOR size; sFrameHdr *fh; - fh=getSpriteBank()->getFrameHeader(FRM__SPATULA); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__SPATULA); size.vx=fh->W; size.vy=fh->H; return size; @@ -143,7 +144,7 @@ void CSpatulaPickup::renderPickup(DVECTOR *_pos) sFrameHdr *fh; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__SPATULA); x=_pos->vx-(fh->W/2); y=_pos->vy-(fh->H/2); @@ -213,7 +214,7 @@ void CBalloonAndSpatulaPickup::renderPickup(DVECTOR *_pos) int xo1,xo2; int x,y; - sprites=getSpriteBank(); + sprites=CGameScene::getSpriteBank(); fh=sprites->getFrameHeader(FRM__BALLOON); fhspat=sprites->getFrameHeader(FRM__SPATULA); diff --git a/source/platform/pbaloon.cpp b/source/platform/pbaloon.cpp index 4622cff1f..a5c85d3c1 100644 --- a/source/platform/pbaloon.cpp +++ b/source/platform/pbaloon.cpp @@ -49,7 +49,7 @@ void CBridgeBalloon::render() renderPos.vx = Pos.vx - CamPos.vx; renderPos.vy = Pos.vy - CamPos.vy; - m_spriteBank->printFT4(FRM__BALLOON,renderPos.vx,renderPos.vy,0,0,10); + CGameScene::getSpriteBank()->printFT4(FRM__BALLOON,renderPos.vx,renderPos.vy,0,0,10); } } @@ -57,15 +57,12 @@ void CBridgeBalloon::render() void CBridgeBalloon::init() { - m_spriteBank=new ("enemy sprites") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void CBridgeBalloon::shutdown() { - if (m_spriteBank) m_spriteBank->dump(); delete m_spriteBank; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/platform/pbaloon.h b/source/platform/pbaloon.h index 1d0d2a170..a8411f556 100644 --- a/source/platform/pbaloon.h +++ b/source/platform/pbaloon.h @@ -28,7 +28,6 @@ public: virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); protected: DVECTOR Pos; - SpriteBank *m_spriteBank; }; class CNpcBalloonBridgePlatform : public CNpcPlatform diff --git a/source/platform/pbgeyser.cpp b/source/platform/pbgeyser.cpp index cad729b5b..ac355c60c 100644 --- a/source/platform/pbgeyser.cpp +++ b/source/platform/pbgeyser.cpp @@ -92,7 +92,6 @@ void CNpcGeyserPlatformGenerator::think( int _frames ) } } - newPlatform->setLayerCollision( m_layerCollision ); newPlatform->setTiltable( false ); newPlatform->postInit(); } diff --git a/source/platform/pcart.cpp b/source/platform/pcart.cpp index ed761b20f..c7081f8f3 100644 --- a/source/platform/pcart.cpp +++ b/source/platform/pcart.cpp @@ -67,7 +67,7 @@ void CNpcCartPlatform::processMovement( int _frames ) s32 checkDist = yMovement + 50; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy, checkDist ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy, checkDist ); if ( groundHeight < checkDist ) { @@ -116,7 +116,7 @@ void CNpcCartPlatform::processMovement( int _frames ) s32 yDiff; - yDiff = m_layerCollision->getHeightFromGround( testPos1.vx, testPos1.vy, sensorDist + 1 ); + yDiff = CGameScene::getCollision()->getHeightFromGround( testPos1.vx, testPos1.vy, sensorDist + 1 ); if ( yDiff <= sensorDist ) { @@ -125,7 +125,7 @@ void CNpcCartPlatform::processMovement( int _frames ) testPos1.vy += yDiff; } - yDiff = m_layerCollision->getHeightFromGround( testPos2.vx, testPos2.vy, sensorDist + 1 ); + yDiff = CGameScene::getCollision()->getHeightFromGround( testPos2.vx, testPos2.vy, sensorDist + 1 ); if ( yDiff <= sensorDist ) { diff --git a/source/platform/pfalling.cpp b/source/platform/pfalling.cpp index 2a85e349f..5a7c077c4 100644 --- a/source/platform/pfalling.cpp +++ b/source/platform/pfalling.cpp @@ -62,7 +62,7 @@ void CNpcFallingPlatform::processMovement( int _frames ) moveY = -moveY; } - s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); + s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); if ( groundHeight < moveY ) { diff --git a/source/platform/pfallnor.cpp b/source/platform/pfallnor.cpp index ed3c00f5c..c6242c72a 100644 --- a/source/platform/pfallnor.cpp +++ b/source/platform/pfallnor.cpp @@ -56,11 +56,11 @@ void CNpcFallingNoRespawnPlatform::processMovement( int _frames ) moveY = -moveY; } - s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); + s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); if ( groundHeight < moveY ) { - if ( ( m_layerCollision->getCollisionBlock( Pos.vx, Pos.vy + groundHeight + 8 ) & COLLISION_TYPE_MASK ) != (7<getCollisionBlock( Pos.vx, Pos.vy + groundHeight + 8 ) & COLLISION_TYPE_MASK ) != (7<init( startPos ); - ASSERT(m_layerCollision); while( sourceWaypoint ) { @@ -106,7 +105,6 @@ void CNpcFallingPlatformGenerator::think( int _frames ) } } - newPlatform->setLayerCollision( m_layerCollision ); newPlatform->setTiltable( false ); newPlatform->postInit(); } diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index bc812bfff..ea7f4e82e 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -169,9 +169,11 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) { CNpcPlatform *platform; - NPC_PLATFORM_UNIT_TYPE platformType = getTypeFromMapEdit( ThisPlatform->Type ); + NPC_PLATFORM_UNIT_TYPE Type = getTypeFromMapEdit( ThisPlatform->Type ); - switch( platformType ) + platform = (CNpcPlatform*)CThingManager::GetThing(CThing::TYPE_PLATFORM,Type); + if (!platform) + switch( Type ) { case NPC_LINEAR_PLATFORM: { @@ -271,7 +273,7 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) dualPlatformMaster->setOtherPlatform( dualPlatformSlave ); dualPlatformSlave->setOtherPlatform( dualPlatformMaster ); - dualPlatformSlave->setType( platformType ); + dualPlatformSlave->setType( Type ); dualPlatformSlave->setGraphic( ThisPlatform ); dualPlatformSlave->setTiltable( false ); @@ -383,7 +385,8 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) } ASSERT(platform); - platform->setType( platformType ); + platform->setType( Type ); + platform->setThingSubType( Type ); platform->setGraphic( ThisPlatform ); platform->setWaypoints( ThisPlatform ); @@ -471,8 +474,6 @@ void CNpcPlatform::init() m_tiltable = false; m_initRotation = 0; - m_layerCollision = NULL; - m_lifetime = 0; m_lifetimeType = m_data[m_type].lifetimeType; @@ -664,7 +665,8 @@ void CNpcPlatform::think(int _frames) void CNpcPlatform::setCollisionAngle(int newAngle) { - CPlatformThing::setCollisionAngle(newAngle); + m_collisionAngle=newAngle; +// CPlatformThing::setCollisionAngle(newAngle); calculateBoundingBoxSize(); CPlayer *player; diff --git a/source/platform/platform.h b/source/platform/platform.h index 272c1932a..c6db76977 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -88,6 +88,10 @@ public: NPC_CLAM_PLATFORM, NPC_PLATFORM_TYPE_MAX, }; + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =NPC_PLATFORM_TYPE_MAX, + }; void init(); void init( DVECTOR initPos ); @@ -99,7 +103,6 @@ public: virtual u8 canDrop() {return true;} void setType( NPC_PLATFORM_UNIT_TYPE newType ) {m_type = newType;} void setTypeFromMapEdit( u16 newType ); - void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); virtual u8 checkCollisionDelta( CThing *_thisThing, int threshold, CRECT collisionArea ); virtual int getHeightFromPlatformAtPosition(int _x,int _y, int offsetX = 0, int offsetY = 0); @@ -179,8 +182,6 @@ protected: static s32 playerXDistSqr; static s32 playerYDistSqr; - class CLayerCollision *m_layerCollision; - // internal variables NPC_PLATFORM_UNIT_TYPE m_type; @@ -223,10 +224,13 @@ protected: protected: - virtual void setCollisionAngle(int newAngle); // Actually.. this probly doesn't need to be in the base calss anymore.. :/ virtual void calculateNonRotatedCollisionData(); virtual void calculateBoundingBoxSize(); + virtual void setCollisionAngle(int newAngle); // Actually.. this probly doesn't need to be in the base calss anymore.. :/ + s16 getCollisionAngle() {return m_collisionAngle;} + s16 m_collisionAngle; + }; diff --git a/source/platform/pleaf.cpp b/source/platform/pleaf.cpp index 3b63e3828..1a82686f7 100644 --- a/source/platform/pleaf.cpp +++ b/source/platform/pleaf.cpp @@ -66,7 +66,7 @@ void CNpcLeafPlatform::processMovement( int _frames ) moveY = -moveY; } - s32 groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); + s32 groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy + moveY, 16 ); if ( groundHeight < moveY ) { diff --git a/source/platform/praft.cpp b/source/platform/praft.cpp index 93640d09a..b500f0b5f 100644 --- a/source/platform/praft.cpp +++ b/source/platform/praft.cpp @@ -55,7 +55,7 @@ void CNpcRaftPlatform::processMovement( int _frames ) { Pos.vy += _frames; - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy - 32 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy - 32 ); if ( groundHeight <= 0 ) { @@ -85,7 +85,7 @@ void CNpcRaftPlatform::processMovement( int _frames ) distX = distX / abs( distX ); - if ( m_layerCollision->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + ( distX * m_speed * _frames ), Pos.vy ) < -maxHeight ) { // there is an obstacle in the way, increment the path point (hopefully this will resolve the problem) @@ -95,7 +95,7 @@ void CNpcRaftPlatform::processMovement( int _frames ) { // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { @@ -119,7 +119,7 @@ void CNpcRaftPlatform::processMovement( int _frames ) } else { - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { diff --git a/source/platform/psbarrel.cpp b/source/platform/psbarrel.cpp index a3016e264..296b543e8 100644 --- a/source/platform/psbarrel.cpp +++ b/source/platform/psbarrel.cpp @@ -61,7 +61,7 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) // check for collision - if ( m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy ) < -maxHeight ) + if ( CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy ) < -maxHeight ) { moveX = 0; } @@ -80,7 +80,7 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) // check for vertical movement - groundHeight = m_layerCollision->getHeightFromGround( Pos.vx + moveX, Pos.vy, yMovement + 16 ); + groundHeight = CGameScene::getCollision()->getHeightFromGround( Pos.vx + moveX, Pos.vy, yMovement + 16 ); if ( groundHeight <= yMovement ) { diff --git a/source/player/player.cpp b/source/player/player.cpp index a5ebe5132..187790bf5 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -596,10 +596,6 @@ void CPlayer::init() m_fontBank->initialise(&standardFont); m_fontBank->setOt(5); - m_spriteBank=new ("PlayerSprites") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); - - m_layerCollision=NULL; m_actorGfx=CActorPool::GetActor(ACTORS_SPONGEBOB_SBK); @@ -665,7 +661,6 @@ void CPlayer::shutdown() } delete m_actorGfx; - m_spriteBank->dump(); delete m_spriteBank; m_fontBank->dump(); delete m_fontBank; CPlayerThing::shutdown(); @@ -1200,10 +1195,10 @@ for(int i=0;igetFrameHeader(*frames)->H; + ygap=CGameScene::getSpriteBank()->getFrameHeader(*frames)->H; for(i=5;i>0;i--) { - ft4=m_spriteBank->printFT4(*frames++,x,y,0,0,0); + ft4=CGameScene::getSpriteBank()->printFT4(*frames++,x,y,0,0,0); setSemiTrans(ft4,i>m_health); y+=ygap; } @@ -1215,11 +1210,11 @@ for(int i=0;iprintFT4(FRM__WATERHILIGHT,HEALTH_ICONX,HEALTH_ICONY,0,0,0); + ft4=CGameScene::getSpriteBank()->printFT4(FRM__WATERHILIGHT,HEALTH_ICONX,HEALTH_ICONY,0,0,0); setSemiTrans(ft4,true); - fh=m_spriteBank->getFrameHeader(FRM__WATER); - ft4=m_spriteBank->printFT4(fh,0,0,0,0,0); + fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__WATER); + ft4=CGameScene::getSpriteBank()->printFT4(fh,0,0,0,0,0); setSemiTrans(ft4,true); V=fh->V; W=fh->W; @@ -1230,7 +1225,7 @@ for(int i=0;iv0=V+(partH); ft4->v1=V+(partH); - m_spriteBank->printFT4(FRM__WATERMETER,HEALTH_ICONX,HEALTH_ICONY,0,0,0); + CGameScene::getSpriteBank()->printFT4(FRM__WATERMETER,HEALTH_ICONX,HEALTH_ICONY,0,0,0); } @@ -1242,18 +1237,18 @@ for(int i=0;igetFrameHeader(FRM__SHOE); + sFrameHdr *fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__SHOE); x=itemX-(fh->W/2); y=COLLECTEDITEM_BASEY-(fh->H/2); - m_spriteBank->printFT4(fh,x+2,y+2,0,0,0); - m_spriteBank->printFT4(fh,x-2,y-2,0,0,0); + CGameScene::getSpriteBank()->printFT4(fh,x+2,y+2,0,0,0); + CGameScene::getSpriteBank()->printFT4(fh,x-2,y-2,0,0,0); itemX+=COLLECTEDITEM_GAP; } /* if(isWearingDivingHelmet()) { - sFrameHdr *fh=m_spriteBank->getFrameHeader(FRM__HELMET); - m_spriteBank->printFT4(fh,itemX-(fh->W/2),COLLECTEDITEM_BASEY-(fh->H/2),0,0,0); + sFrameHdr *fh=CGameScene::getSpriteBank()->getFrameHeader(FRM__HELMET); + CGameScene::getSpriteBank()->printFT4(fh,itemX-(fh->W/2),COLLECTEDITEM_BASEY-(fh->H/2),0,0,0); itemX+=COLLECTEDITEM_GAP; } */ @@ -1291,7 +1286,7 @@ int CPlayer::getHeightFromGround(int _x,int _y,int _maxHeight) { int height; - height=m_layerCollision->getHeightFromGround(_x,_y,_maxHeight); + height=CGameScene::getCollision()->getHeightFromGround(_x,_y,_maxHeight); if(height>=_maxHeight) { CThing *platform; @@ -1337,7 +1332,7 @@ int CPlayer::getHeightFromPlatformNoGround(int _x,int _y,int _maxHeight) ---------------------------------------------------------------------- */ int CPlayer::getHeightFromGroundNoPlatform(int _x,int _y,int _maxHeight=32) { - return( m_layerCollision->getHeightFromGround(_x,_y,_maxHeight) ); + return( CGameScene::getCollision()->getHeightFromGround(_x,_y,_maxHeight) ); } /*---------------------------------------------------------------------- @@ -1796,7 +1791,7 @@ int CPlayer::canDoLookAround() void CPlayer::inSoakUpState() { if(isWearingDivingHelmet()&& - (m_layerCollision->getCollisionBlock(Pos.vx,Pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_WATER) + (CGameScene::getCollision()->getCollisionBlock(Pos.vx,Pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_WATER) { m_healthWaterLevel+=waterSoakUpSpeed; if(m_healthWaterLevel>WATERMAXHEALTH) @@ -2096,7 +2091,7 @@ void CPlayer::shove( DVECTOR move ) int colHeight; // X movement - colHeight=m_layerCollision->getHeightFromGround(Pos.vx+move.vx,Pos.vy,5); + colHeight=CGameScene::getCollision()->getHeightFromGround(Pos.vx+move.vx,Pos.vy,5); if(colHeight<0) { // Stop at the edge of the obstruction @@ -2114,7 +2109,7 @@ void CPlayer::shove( DVECTOR move ) cx=Pos.vx; for(i=0;igetHeightFromGround(cx,Pos.vy)<0) + if(CGameScene::getCollision()->getHeightFromGround(cx,Pos.vy)<0) { break; } @@ -2130,7 +2125,7 @@ void CPlayer::shove( DVECTOR move ) } // Y movement - colHeight=m_layerCollision->getHeightFromGround(Pos.vx,Pos.vy+move.vy,5); + colHeight=CGameScene::getCollision()->getHeightFromGround(Pos.vx,Pos.vy+move.vy,5); if(colHeight<0) { // Stop at the edge of the obstruction @@ -2148,7 +2143,7 @@ void CPlayer::shove( DVECTOR move ) cy=Pos.vy; for(i=0;igetHeightFromGround(Pos.vx,cy)<0) + if(CGameScene::getCollision()->getHeightFromGround(Pos.vx,cy)<0) { break; } @@ -2263,7 +2258,7 @@ int CPlayer::moveVertical(int _moveDistance) if(colHeightBefore>=0&&colHeightAfter<=0) { // About to hit a 'fall to death' block? - if((m_layerCollision->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_DEATH) + if((CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_DEATH) { // No // Stick at ground level @@ -2287,7 +2282,7 @@ int CPlayer::moveVertical(int _moveDistance) { // Must be below ground // Are we jumping into an impassable block? - if((m_layerCollision->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&& + if((CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&& getHeightFromGround(pos.vx,pos.vy+_moveDistance)<=0) { pos.vy=(pos.vy&0xfff0); @@ -2298,7 +2293,7 @@ int CPlayer::moveVertical(int _moveDistance) else { // Stood on any important types of collision? - switch(m_layerCollision->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK) + switch(CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy+_moveDistance)&COLLISION_TYPE_MASK) { case COLLISION_TYPE_FLAG_DAMAGE: takeDamage(DAMAGE__COLLISION_DAMAGE); @@ -2327,11 +2322,10 @@ int CPlayer::moveHorizontal(int _moveDistance) hitWall=false; if(_moveDistance) { - CLayerCollision *collision; + CLayerCollision *collision=CGameScene::getCollision(); DVECTOR pos; int colHeight; - collision=getLayerCollision(); pos=getPlayerPos(); colHeight=getHeightFromGround(pos.vx,pos.vy,5); if(colHeight==0) @@ -2379,7 +2373,7 @@ int CPlayer::moveHorizontal(int _moveDistance) } else if(colHeight>0) // Lets you jump through platforms from below { - if((m_layerCollision->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&& + if((CGameScene::getCollision()->getCollisionBlock(pos.vx+_moveDistance,pos.vy)&COLLISION_TYPE_MASK)!=COLLISION_TYPE_FLAG_NORMAL&& getHeightFromGround(pos.vx+_moveDistance,pos.vy,5)<0) { // Stop at the edge of the obstruction diff --git a/source/player/player.h b/source/player/player.h index 081411e91..4021725d0 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -214,7 +214,6 @@ public: DVECTOR getCameraPos() {return m_cameraPos;} - void setLayerCollision(class CLayerCollision *_layer) {m_layerCollision=_layer;} void setCameraBox(CameraBox _cameraBox); void setRespawnPos(DVECTOR _respawn) {m_respawnPos=_respawn;} @@ -262,7 +261,6 @@ public: PLAYERINPUT getPadInputHeld() {return m_padInput;} PLAYERINPUT getPadInputDown() {return m_padInputDown;} int tryingToPickupWeapon() {return m_tryingToPickupWeapon;} - class CLayerCollision *getLayerCollision() {return m_layerCollision;} void inSoakUpState(); void takeDamage(DAMAGE_TYPE _damage,REACT_DIRECTION _reactDirection=REACT__UP,CThing *_thing=NULL); @@ -344,7 +342,6 @@ private: // Various info about the current map - class CLayerCollision *m_layerCollision; CameraBox m_cameraPosLimitBox; CameraBox m_playerPosLimitBox; DVECTOR m_respawnPos; @@ -429,7 +426,6 @@ public: // Graphical resources public: class FontBank *getFontBank() {return m_fontBank;} - class SpriteBank *getSpriteBank() {return m_spriteBank;} enum { @@ -447,8 +443,6 @@ public: private: class FontBank *m_fontBank; - class SpriteBank *m_spriteBank; - }; diff --git a/source/player/pmbubble.cpp b/source/player/pmbubble.cpp index a773742a0..0950b62c5 100644 --- a/source/player/pmbubble.cpp +++ b/source/player/pmbubble.cpp @@ -25,6 +25,7 @@ #include "gfx\font.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -172,7 +173,7 @@ void CPlayerModeBubbleMixture::renderModeUi() char buf[4]; FontBank *fb; - sb=m_player->getSpriteBank(); + sb=CGameScene::getSpriteBank(); fh=sb->getFrameHeader(FRM__BUBBLEWAND); sb->printFT4(fh,CPlayer::POWERUPUI_ICONX,CPlayer::POWERUPUI_ICONY,0,0,CPlayer::POWERUPUI_OT); diff --git a/source/player/pmcoral.cpp b/source/player/pmcoral.cpp index fe9cf6ebf..9d1270253 100644 --- a/source/player/pmcoral.cpp +++ b/source/player/pmcoral.cpp @@ -283,7 +283,7 @@ void CPlayerModeCoralBlower::think() CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, 5*60); - projectile->setLayerCollision( m_player->getLayerCollision() ); + //CActorGfx *projectileGfx; //projectileGfx=CActorPool::GetActor((FileEquate)ACTORS_SHELL_SBK); @@ -354,7 +354,7 @@ void CPlayerModeCoralBlower::renderModeUi() sFrameHdr *fh; // char buf[4]; - sb=m_player->getSpriteBank(); + sb=CGameScene::getSpriteBank(); fh=sb->getFrameHeader(FRM__BLOWER); if(m_blowerState==BLOWER_STATE__FULL||m_blowerState==BLOWER_STATE__AIMING) { diff --git a/source/player/pmjelly.cpp b/source/player/pmjelly.cpp index 007de7d1b..14d819847 100644 --- a/source/player/pmjelly.cpp +++ b/source/player/pmjelly.cpp @@ -33,6 +33,7 @@ #include "gfx\font.h" #endif +#include "game/game.h" /* Std Lib ------- */ @@ -152,7 +153,7 @@ void CPlayerModeJellyLauncher::renderModeUi() FontBank *fb; char buf[4]; - sb=m_player->getSpriteBank(); + sb=CGameScene::getSpriteBank(); fh=sb->getFrameHeader(FRM__LAUNCHER); switch(m_firingState) { @@ -301,7 +302,7 @@ void CPlayerModeJellyLauncher::launchProjectile() CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, 5*60); - projectile->setLayerCollision( m_player->getLayerCollision() ); + projectile->setRGB( 255 + ( 128 << 8 ) + ( 255 << 16 ) ); fireHeading+=512; m_player->useOneJelly(); @@ -317,7 +318,7 @@ void CPlayerModeJellyLauncher::launchProjectile() CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, 5*60); - projectile->setLayerCollision( m_player->getLayerCollision() ); + projectile->setRGB( 255 + ( 128 << 8 ) + ( 255 << 16 ) ); m_player->useOneJelly(); } diff --git a/source/player/pmnet.cpp b/source/player/pmnet.cpp index de588c782..767225801 100644 --- a/source/player/pmnet.cpp +++ b/source/player/pmnet.cpp @@ -237,7 +237,7 @@ void CPlayerModeNet::think() CPlayerProjectile::PLAYER_PROJECTILE_DUMBFIRE, CPlayerProjectile::PLAYER_PROJECTILE_FINITE_LIFE, 5*60); - projectile->setLayerCollision( m_player->getLayerCollision() ); + projectile->updateCollisionArea(); projectile->setRGB( m_RGB ); @@ -282,7 +282,7 @@ void CPlayerModeNet::think() sFrameHdr *fh; char buf[4]; - sb=m_player->getSpriteBank(); + sb=CGameScene::getSpriteBank(); fh=sb->getFrameHeader(FRM__NET); if(m_player->getJellyFishAmmo()) { diff --git a/source/player/pmodes.cpp b/source/player/pmodes.cpp index e5fc07e3b..c4f313bdb 100644 --- a/source/player/pmodes.cpp +++ b/source/player/pmodes.cpp @@ -70,7 +70,7 @@ #include "player\psspring.h" #endif - +#include "game/game.h" /* Std Lib ------- */ @@ -297,7 +297,7 @@ void CPlayerModeBase::thinkVerticalMovement() playerHasHitGround(); pos=m_player->getPlayerPos(); if(m_player->getHeightFromGround(pos.vx,pos.vy,5)==0&& - (m_player->getLayerCollision()->getCollisionBlock(pos.vx,pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_WATER&& + (CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_WATER&& !m_player->getIsHealthSoFullThatIDontNeedToSoakUp()) { // Hit water - Go into soakup mode @@ -474,11 +474,10 @@ int csize=5; int cheight=15; int CPlayerModeBase::isOnEdge() { - CLayerCollision *collision; + CLayerCollision *collision=CGameScene::getCollision(); DVECTOR pos; int ret; - collision=m_player->getLayerCollision(); pos=m_player->getPlayerPos(); ret=0; if(m_player->getHeightFromGround(pos.vx-csize,pos.vy,cheight+1)>cheight) diff --git a/source/projectl/prnpcspr.cpp b/source/projectl/prnpcspr.cpp index 5d5f2f4ae..76f4f118e 100644 --- a/source/projectl/prnpcspr.cpp +++ b/source/projectl/prnpcspr.cpp @@ -23,6 +23,8 @@ #include "level\level.h" #endif +#include "game/game.h" + void CEnemyAsSpriteProjectile::think( int _frames ) { CPlayerProjectile::think( _frames ); @@ -51,8 +53,8 @@ void CEnemyAsSpriteProjectile::render() int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); - int spriteWidth = m_spriteBank->getFrameWidth( m_spriteFrame ); - int spriteHeight = m_spriteBank->getFrameHeight( m_spriteFrame ); + int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth( m_spriteFrame ); + int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight( m_spriteFrame ); offset = getScreenOffset(); @@ -64,8 +66,8 @@ void CEnemyAsSpriteProjectile::render() return; } - frameHdr = m_spriteBank->getFrameHeader( m_spriteFrame ); - POLY_FT4 *SprFrame = m_spriteBank->printRotatedScaledSprite( frameHdr, x, y, 4096, 4096, m_rotation, 0 ); + frameHdr = CGameScene::getSpriteBank()->getFrameHeader( m_spriteFrame ); + POLY_FT4 *SprFrame = CGameScene::getSpriteBank()->printRotatedScaledSprite( frameHdr, x, y, 4096, 4096, m_rotation, 0 ); if ( m_hasRGB ) { diff --git a/source/projectl/projectl.cpp b/source/projectl/projectl.cpp index da5d3904e..808c7a317 100644 --- a/source/projectl/projectl.cpp +++ b/source/projectl/projectl.cpp @@ -55,8 +55,6 @@ void CProjectile::init() { CEnemyProjectileThing::init(); - m_spriteBank=new ("projectile sprites") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); m_spriteFrame = FRM__SPIKE; m_initHeading = m_heading = 0; @@ -97,8 +95,6 @@ void CProjectile::init( DVECTOR initPos, s16 initHeading, PROJECTILE_MOVEMENT_TY void CProjectile::shutdown() { - m_spriteBank->dump(); delete m_spriteBank; - CEnemyProjectileThing::shutdown(); } @@ -250,7 +246,7 @@ void CProjectile::think(int _frames) case PROJECTILE_USER_SEEK: { - if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) + if ( CGameScene::getCollision()->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) { setToShutdown(); } @@ -312,7 +308,7 @@ void CProjectile::think(int _frames) case PROJECTILE_DUMBFIRE: default: { - if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) + if ( CGameScene::getCollision()->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) { setToShutdown(); } @@ -346,8 +342,8 @@ void CProjectile::render() int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); - int spriteWidth = m_spriteBank->getFrameWidth( m_spriteFrame ); - int spriteHeight = m_spriteBank->getFrameHeight( m_spriteFrame ); + int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth( m_spriteFrame ); + int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight( m_spriteFrame ); offset = getScreenOffset(); @@ -359,11 +355,11 @@ void CProjectile::render() return; } - //m_spriteBank->printFT4(FRM__SPIKE,x,y,0,0,0); + //CGameScene::getSpriteBank()->printFT4(FRM__SPIKE,x,y,0,0,0); - frameHdr = m_spriteBank->getFrameHeader( m_spriteFrame ); + frameHdr = CGameScene::getSpriteBank()->getFrameHeader( m_spriteFrame ); - m_spriteBank->printRotatedScaledSprite( frameHdr, x, y, 4096, 4096, m_heading, m_ot ); + CGameScene::getSpriteBank()->printRotatedScaledSprite( frameHdr, x, y, 4096, 4096, m_heading, m_ot ); } DVECTOR CProjectile::getScreenOffset() @@ -405,9 +401,6 @@ void CPlayerProjectile::init() { CPlayerProjectileThing::init(); - m_spriteBank=new ("projectile sprites") SpriteBank(); - m_spriteBank->load(SPRITES_SPRITES_SPR); - m_heading = 0; m_lifetime = GameState::getOneSecondInFrames() * 2; m_movementType = PLAYER_PROJECTILE_DUMBFIRE; @@ -453,7 +446,6 @@ void CPlayerProjectile::init( DVECTOR initPos, s16 initHeading, PLAYER_PROJECTIL void CPlayerProjectile::shutdown() { - m_spriteBank->dump(); delete m_spriteBank; CPlayerProjectileThing::shutdown(); } @@ -499,7 +491,7 @@ void CPlayerProjectile::think(int _frames) case PLAYER_PROJECTILE_DUMBFIRE: default: { - if ( m_layerCollision->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) + if ( CGameScene::getCollision()->Get( Pos.vx >> 4, Pos.vy >> 4 ) ) { // destroy destructable tiles @@ -538,8 +530,8 @@ void CPlayerProjectile::render() int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); - int spriteWidth = m_spriteBank->getFrameWidth(m_frame); - int spriteHeight = m_spriteBank->getFrameHeight(m_frame); + int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth(m_frame); + int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight(m_frame); offset = getScreenOffset(); @@ -559,7 +551,7 @@ void CPlayerProjectile::render() return; } - SprFrame = m_spriteBank->printFT4(FRM_JELLYFISH1_SWIM1 + m_frame,x,y,m_reversed,0,0); + SprFrame = CGameScene::getSpriteBank()->printFT4(FRM_JELLYFISH1_SWIM1 + m_frame,x,y,m_reversed,0,0); setRGB0( SprFrame, m_RGB.r, m_RGB.g, m_RGB.b ); } diff --git a/source/projectl/projectl.h b/source/projectl/projectl.h index d6d4c61f8..b1a92c11e 100644 --- a/source/projectl/projectl.h +++ b/source/projectl/projectl.h @@ -42,6 +42,10 @@ public: PROJECTILE_ATTACK = 0, PROJECTILE_RETURN = 1, }; + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =1, + }; void init(); void init( DVECTOR initPos, s16 initHeading ); @@ -57,20 +61,15 @@ public: void setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType ); void setPosition( DVECTOR newPos ); void setHeading( s16 newHeading ) {m_heading = newHeading;} - void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} void setOt( u8 newOt ) {m_ot=newOt;} void setGraphic( int frame ); void setSpeed( u16 newSpeed ) {m_speed = newSpeed;} -private: - class CLayerCollision *m_layerCollision; - protected: DVECTOR getScreenOffset(); bool processTargetSeek( int _frames, DVECTOR targetPos ); void collidedWith( CThing *_thisThing ); - class SpriteBank *m_spriteBank; DVECTOR m_initPos; s16 m_heading; s16 m_initHeading; @@ -100,6 +99,10 @@ public: PLAYER_PROJECTILE_FINITE_LIFE = 0, PLAYER_PROJECTILE_INFINITE_LIFE = 1, }; + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =1, + }; void init(); void init( DVECTOR initPos, s16 initHeading ); @@ -109,21 +112,18 @@ public: virtual void think(int _frames); virtual void render(); void processEvent( GAME_EVENT evt, CThing *sourceThing ); + void setMovementType( PLAYER_PROJECTILE_MOVEMENT_TYPE moveType ); PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType(); void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType ); void setPosition( DVECTOR newPos ); - void setLayerCollision( class CLayerCollision *_layer ) {m_layerCollision=_layer;} void setRGB( u32 new_RGB ); -private: - class CLayerCollision *m_layerCollision; protected: DVECTOR getScreenOffset(); void collidedWith( CThing *_thisThing ); - class SpriteBank *m_spriteBank; DVECTOR m_initPos; s16 m_heading; s32 m_lifetime; diff --git a/source/system/main.cpp b/source/system/main.cpp index c164cb99e..18cc770d8 100644 --- a/source/system/main.cpp +++ b/source/system/main.cpp @@ -113,6 +113,9 @@ void InitSystem() // reordered to reduce black screen (hope all is well SetDispMask(1); + GenericSpriteBank.load(SPRITES_SPRITES_SPR); + CGameScene::setSpriteBank(&GenericSpriteBank); + GameState::initialise(); CSoundMediator::initialise(); CSoundMediator::setSfxBank(CSoundMediator::SFX_INGAME); @@ -122,8 +125,6 @@ void InitSystem() // reordered to reduce black screen (hope all is well CBubicleFactory::init(); CActorPool::AddActor(ACTORS_SPONGEBOB_SBK); - GenericSpriteBank.load(SPRITES_SPRITES_SPR); - #if defined(__DEBUG_MEM__) DebugMemFontInit(); diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index 74c81c80b..d3c40d4f7 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -11,6 +11,7 @@ ===========================================================================*/ +//#define USE_FREE_LIST /*---------------------------------------------------------------------- Includes -------- */ @@ -31,9 +32,13 @@ #include "level\level.h" -#ifndef __HAZARD_HAZARD_H__ -#include "hazard\hazard.h" -#endif +// Needed for freelist table :o( +#include "pickups\pickup.h" +#include "platform\platform.h" +#include "projectl\projectl.h" +#include "enemy\npc.h" +#include "friend\friend.h" +#include "fx\fx.h" #ifndef __HAZARD_HRWEIGHT_H__ #include "hazard\hrweight.h" @@ -47,7 +52,6 @@ #include "hazard\hpswitch.h" #endif - /* Std Lib ------- */ @@ -82,11 +86,34 @@ static const int s_ThinkBBoxY1=256+128; CThing *CThingManager::s_thingLists[CThing::MAX_TYPE]; CThing *CThingManager::s_CollisionLists[CThing::MAX_TYPE]; int CThingManager::s_initialised=false; - sBBox CThingManager::m_RenderBBox; sBBox CThingManager::m_ThinkBBox; +#ifdef USE_FREE_LIST +CThing **CThingManager::s_FreeList[CThing::MAX_TYPE]; + +struct sFreeListTable +{ + u16 Type; + u16 Count; +}; + +static const sFreeListTable FreeListTable[]= +{ +/* 0*/ {CThing::TYPE_PICKUP ,CBasePickup::MAX_SUBTYPE}, +/* 1*/ {CThing::TYPE_PLATFORM ,CNpcPlatform::MAX_SUBTYPE}, +/* 2*/ {CThing::TYPE_PLAYER ,CPlayerThing::MAX_SUBTYPE}, +/* 3*/ {CThing::TYPE_PLAYERPROJECTILE ,CPlayerProjectile::MAX_SUBTYPE}, +/* 4*/ {CThing::TYPE_NPC ,CNpcFriend::MAX_SUBTYPE}, +/* 5*/ {CThing::TYPE_ENEMY ,CNpcEnemy::MAX_SUBTYPE}, +/* 6*/ {CThing::TYPE_ENEMYPROJECTILE ,CProjectile::MAX_SUBTYPE}, +/* 7*/ {CThing::TYPE_TRIGGER ,CTriggerThing::MAX_SUBTYPE}, +/* 8*/ {CThing::TYPE_HAZARD ,CNpcHazard::MAX_SUBTYPE}, +/* 9*/ {CThing::TYPE_FX ,CFX::MAX_SUBTYPE}, +}; +static const int FreeListTableSize=sizeof(FreeListTable)/sizeof(sFreeListTable); +#endif /*---------------------------------------------------------------------- Function: Purpose: @@ -98,6 +125,7 @@ void CThingManager::init() ASSERT(!s_initialised); initList(s_thingLists); initList(s_CollisionLists); + initFreeList(); s_initialised=true; } @@ -119,10 +147,11 @@ void CThingManager::shutdown() { thing=s_thingLists[i]; thing->shutdown(); - delete thing; + DeleteThing(thing); } } s_initialised=false; + shutdownFreeList(); } /*---------------------------------------------------------------------- @@ -167,7 +196,7 @@ void CThingManager::killAllThingsForRespawn() else { thing->shutdown(); - delete thing; + DeleteThing(thing); thing=s_thingLists[i]; } } @@ -353,7 +382,7 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); if (player && playerThing) { playerThing->setHasPlatformCollided( false ); - playerThing->setNewCollidedPos( playerThing->getPos() ); +//!Dave! playerThing->setNewCollidedPos( playerThing->getPos() ); // Player -> Platform collision thing1=s_CollisionLists[CThing::TYPE_PLATFORM]; @@ -521,7 +550,7 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); if ( thing->isSetToShutdown() ) { thing->shutdown(); - delete thing; + DeleteThing(thing); } thing = nextThing; @@ -629,6 +658,7 @@ CThing *CThingManager::checkCollisionAreaAgainstThings(CRECT *_area,int _type,i void CThingManager::addToThingList(CThing *_this) { int Type=_this->getThingType(); + _this->m_nextListThing=s_thingLists[Type]; s_thingLists[Type]=_this; } @@ -675,14 +705,130 @@ int Type=thing->getThingType(); s_CollisionLists[Type]=thing; } +/********************************************************************/ +/********************************************************************/ +/*** Free List Stuff ************************************************/ +/********************************************************************/ +/********************************************************************/ +void CThingManager::initFreeList() +{ +#ifdef USE_FREE_LIST +// Make sure no-one is being naughty + ASSERT(FreeListTableSize==CThing::MAX_TYPE) + + for (int i=0; iNextFreeThing; + delete ThisThing; + ThisThing=Next; + } + List[t]=0; + } + + } +#endif +} + +/********************************************************************/ +void CThingManager::shutdownFreeList() +{ +#ifdef USE_FREE_LIST + resetFreeList(); + for (int i=0; iNextFreeThing; + Thing->initDef(); + Thing->NextFreeThing=0; + } + + return(Thing); +#else + return(0); +#endif +} + +/********************************************************************/ +void CThingManager::DeleteThing(CThing *Thing) +{ +#ifdef USE_FREE_LIST +int Type=Thing->getThingType(); +int SubType=Thing->getThingSubType(); +CThing **List=s_FreeList[Type]; + +// Check its been aquired/set correctly + + ASSERT(SubType!=1234); + + Thing->NextFreeThing=List[SubType]; + List[SubType]=Thing; + +#else + delete Thing; +#endif +} + +/********************************************************************/ +/********************************************************************/ +/********************************************************************/ +/********************************************************************/ +/********************************************************************/ +/********************************************************************/ + /*---------------------------------------------------------------------- Function: Purpose: Params: Returns: ---------------------------------------------------------------------- */ +int DaveDbg=1; void CThing::init() { + ASSERT(DaveDbg); ParentThing=NULL; NextThing=NULL; m_numChildren = 0; @@ -691,11 +837,10 @@ void CThing::init() // These need to stay for init setCollisionSize(20,20); // Some temporary defaults.. (pkg) setCollisionCentreOffset(0,0); - setCollisionAngle(0); +//!Dave! setCollisionAngle(0); // Add to thing list CThingManager::addToThingList(this); - } /*---------------------------------------------------------------------- @@ -983,7 +1128,7 @@ CThing *List=NextThing; List->ParentThing=NULL; List->NextThing=NULL; List->shutdown(); - delete List; + CThingManager::DeleteThing(List); List=NextThing; } NextThing=NULL; @@ -1181,6 +1326,5 @@ void CTriggerThing::setTargetBox(int _x,int _y,int _w,int _h) m_boxY2=_y+_h; } -/*=========================================================================== -end */ + diff --git a/source/thing/thing.h b/source/thing/thing.h index 81334ff94..079e595cb 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -84,11 +84,19 @@ private: static CThing *s_CollisionLists[]; static sBBox m_RenderBBox; static sBBox m_ThinkBBox; +public: +// FreeList Stuff + static void initFreeList(); + static void resetFreeList(); + static void shutdownFreeList(); + static CThing *GetThing(int Type,int SubType); + static void DeleteThing(CThing *Thing); -// static CThing *s_FreeList[]; - +private: + static CThing **s_FreeList[]; }; + /*----------------------------------------------------------------------*/ // Base thing class class CThing @@ -110,16 +118,29 @@ public: MAX_TYPE, }; // TYPE; - CThing() {m_isShuttingDown=false;} + CThing() + { + initDef(); + m_SubType=1234; + } virtual ~CThing() {;} +virtual void initDef() + { + m_isShuttingDown=false; + NextFreeThing=0; + } + virtual TYPE getThingType()=0; +virtual void setThingSubType(int T) {m_SubType=T;} +virtual int getThingSubType() {return(m_SubType);} + virtual void init(); virtual void shutdown(); virtual void think(int _frames); virtual void render(); - void setToShutdown() {m_isShuttingDown = true;} + void setToShutdown(bool f=true) {m_isShuttingDown = f;} u8 isSetToShutdown() {return( m_isShuttingDown);} virtual int dontKillDuringLevelRespawn() {return false;} @@ -167,8 +188,8 @@ virtual bool alwaysThink() {return(false);} DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;} int getCollisionRadius() {return m_collisionRadius;} virtual CRECT const &getCollisionArea() {return m_collisionArea;} - s16 getCollisionAngle() {return m_collisionAngle;} // pkg - move to CNpcPlatform? - DVECTOR const &getNewCollidedPos() {return m_newCollidedPos;} // pkg - to be removed? +//!Dave! s16 getCollisionAngle() {return m_collisionAngle;} // pkg - move to CNpcPlatform? +//!Dave! DVECTOR const &getNewCollidedPos() {return m_newCollidedPos;} // pkg - to be removed? DVECTOR const &getCollisionSize() {return m_collisionSize;} virtual int canCollide() {return true;} @@ -179,8 +200,7 @@ virtual void collidedWith(CThing *_thisThing) {;} virtual void setHasPlatformCollided( bool newVal ) {;} virtual bool getHasPlatformCollided() {return false;} virtual s32 getNewYPos( CThing *_thisThing ); - void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed? - +//!Dave! void setNewCollidedPos(DVECTOR newPos) {m_newCollidedPos = newPos;} // pkg - to be removed? public: // Thing states @@ -193,24 +213,26 @@ protected: bool m_renderFlag,m_thinkFlag; DVECTOR m_RenderPos; bool m_isShuttingDown; + int m_SubType; protected: virtual void setCollisionSize(int _w,int _h); virtual void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;} virtual void setCollisionCentreOffset(DVECTOR xy) {m_collisionCentreOffset=xy;} -virtual void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;} // pkg - move to CNpcPlatform? +//!Dave!virtual void setCollisionAngle(int newAngle) {m_collisionAngle = newAngle;} // pkg - move to CNpcPlatform? private: DVECTOR m_collisionSize; DVECTOR m_collisionCentreOffset; int m_collisionRadius; CRECT m_collisionArea; DVECTOR m_collisionCentre; - s16 m_collisionAngle; // pkg - move to CNpcPlatform? - DVECTOR m_newCollidedPos; // pkg - to be removed? +//!Dave! s16 m_collisionAngle; // pkg - move to CNpcPlatform? +//!Dave! DVECTOR m_newCollidedPos; // pkg - to be removed? // Free List Stuff -public: -//virtual int getMaxType()=0; +public: + CThing *NextFreeThing; + }; /*---------------------------------------------------------------------- */ @@ -224,6 +246,10 @@ virtual TYPE getThingType() {return TYPE_PICKUP;} class CPlayerThing : public CThing { public: + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =1, + }; virtual TYPE getThingType() {return TYPE_PLAYER;} virtual bool alwaysThink() {return(true);} @@ -262,9 +288,15 @@ virtual TYPE getThingType() {return TYPE_PLATFORM;} class CTriggerThing : public CThing { public: + enum + { // For Dynamic ThingCache + MAX_SUBTYPE =1, + }; + virtual TYPE getThingType() {return TYPE_TRIGGER;} virtual void setPositionAndSize(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg) virtual void setTargetBox(int _x,int _y,int _w,int _h); // Wonder if this might be better in CThing? (pkg) + protected: int m_boxX1,m_boxY1,m_boxX2,m_boxY2; };