diff --git a/source/game/game.cpp b/source/game/game.cpp index dffd98293..0a6765e48 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -186,6 +186,7 @@ void CGameScene::init() void CGameScene::createPlayer() { m_player=new ("player") CPlayer(); + m_player->setThingSubType(0); } // This is also to be overloaded for demomode.. to stop the pause menu appearing diff --git a/source/hazard/hazard.cpp b/source/hazard/hazard.cpp index 777ec4e02..84a918bb6 100644 --- a/source/hazard/hazard.cpp +++ b/source/hazard/hazard.cpp @@ -279,7 +279,6 @@ CNpcHazard *CNpcHazard::Create(sThingHazard *ThisHazard) ASSERT( hazard ); - hazard->setType( Type ); hazard->setThingSubType(Type); hazard->init(); hazard->setWaypoints( ThisHazard ); diff --git a/source/hazard/hazard.h b/source/hazard/hazard.h index 533b843e9..6374aea20 100644 --- a/source/hazard/hazard.h +++ b/source/hazard/hazard.h @@ -72,8 +72,6 @@ public: virtual void setWaypoints( sThingHazard *ThisHazard ); void addWaypoint( s32 xPos, s32 yPos ); virtual void setRespawnRate( s16 newRespawnRate ) {m_respawnRate=newRespawnRate;} - void setType( NPC_HAZARD_UNIT_TYPE type ) {m_type = type;} - NPC_HAZARD_UNIT_TYPE getType() {return( m_type );} static NPC_HAZARD_UNIT_TYPE getTypeFromMapEdit( u16 newType ); static CNpcHazard *Create(sThingHazard *ThisHazard); @@ -97,9 +95,7 @@ protected: virtual void processTimer( int _frames ); virtual void collidedWith(CThing *_thisThing); - NPC_HAZARD_UNIT_TYPE m_type; CNpcPath m_npcPath; - //CActorGfx *m_actorGfx; DVECTOR m_base; s32 m_timer; bool m_timerActive; diff --git a/source/level/level.cpp b/source/level/level.cpp index 07879fd98..ced52b82e 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -367,6 +367,7 @@ void CLevel::initThings(int _respawningLevel) { // Camera lock trigger trigger=(CCameraLockTrigger*)new ("CameraLockTrigger") CCameraLockTrigger(); + trigger->setThingSubType(0); trigger->init(); trigger->setPositionAndSize(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4, TriggerList->Width<<4,TriggerList->Height<<4); @@ -417,6 +418,7 @@ void CLevel::initThings(int _respawningLevel) } if(trigger) { + trigger->setThingSubType(0); trigger->init(); trigger->setPositionAndSize(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4, TriggerList->Width<<4,TriggerList->Height<<4); diff --git a/source/platform/pbgeyser.cpp b/source/platform/pbgeyser.cpp index 63e52f1ea..cb9d3c370 100644 --- a/source/platform/pbgeyser.cpp +++ b/source/platform/pbgeyser.cpp @@ -50,7 +50,7 @@ void CNpcGeyserPlatformGenerator::think( int _frames ) if ( m_timer < 0 ) { //m_timer = getRnd() % ( m_data[m_type].initTimer * GameState::getOneSecondInFrames() ); - m_timer = m_data[m_type].initTimer * GameState::getOneSecondInFrames(); + m_timer = m_dataPtr->initTimer * GameState::getOneSecondInFrames(); // generate new falling platform @@ -75,7 +75,7 @@ void CNpcGeyserPlatformGenerator::think( int _frames ) ASSERT(newPlatform); - newPlatform->setType( m_targetType ); + newPlatform->setThingSubType( m_targetType ); newPlatform->setGraphic( m_graphicNum ); DVECTOR startPos = Pos; diff --git a/source/platform/pconveyr.cpp b/source/platform/pconveyr.cpp index 7b6f76cf9..dc3f440d3 100644 --- a/source/platform/pconveyr.cpp +++ b/source/platform/pconveyr.cpp @@ -53,7 +53,7 @@ void CNpcConveyorPlatformGenerator::think( int _frames ) m_timer = second; - m_timer += m_data[m_type].initTimer * second; + m_timer += m_dataPtr->initTimer * second; m_timer += second - ( getRnd() % ( 2 * second ) ); @@ -66,7 +66,7 @@ void CNpcConveyorPlatformGenerator::think( int _frames ) ASSERT(newPlatform); - newPlatform->setType( NPC_CONVEYOR_PLATFORM ); + newPlatform->setThingSubType( NPC_CONVEYOR_PLATFORM ); newPlatform->setGraphic( m_graphicNum ); CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); diff --git a/source/platform/pfgen.cpp b/source/platform/pfgen.cpp index 56964374c..a9a2a9efd 100644 --- a/source/platform/pfgen.cpp +++ b/source/platform/pfgen.cpp @@ -53,7 +53,7 @@ void CNpcFallingPlatformGenerator::think( int _frames ) m_timer = second; - m_timer += m_data[m_type].initTimer * second; + m_timer += m_dataPtr->initTimer * second; m_timer += second - ( getRnd() % ( 2 * second ) ); @@ -84,7 +84,7 @@ void CNpcFallingPlatformGenerator::think( int _frames ) ASSERT(newPlatform); - newPlatform->setType( m_targetType ); + newPlatform->setThingSubType( m_targetType ); newPlatform->setGraphic( m_graphicNum ); CNpcWaypoint *sourceWaypoint = m_npcPath.getWaypointList(); diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 364e386f4..6a41e5cdf 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -394,7 +394,6 @@ CNpcPlatform *CNpcPlatform::Create(int Type) } ASSERT(platform); - platform->setType( (NPC_PLATFORM_UNIT_TYPE) Type ); platform->setThingSubType( Type ); platform->setTiltable( false ); @@ -422,7 +421,7 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) dualPlatformSlave = (CNpcDualPlatform *) CNpcPlatform::Create( NPC_DUAL_PLATFORM ); dualPlatformSlave->setMaster( false ); - dualPlatformSlave->setType( Type ); + dualPlatformSlave->setThingSubType( Type ); dualPlatformSlave->setGraphic( ThisPlatform ); dualPlatformSlave->setTiltable( false ); @@ -504,6 +503,7 @@ void CNpcPlatform::init() { CPlatformThing::init(); + m_dataPtr=&m_data[getThingSubType()]; m_heading = 0; m_velocity = 0; @@ -511,10 +511,10 @@ void CNpcPlatform::init() m_reversed = false; m_extension = 0; m_contact = false; - m_timer = m_data[m_type].initTimer * GameState::getOneSecondInFrames(); - m_timerType = m_data[m_type].initTimerType; + m_timer = m_dataPtr->initTimer * GameState::getOneSecondInFrames(); + m_timerType = m_dataPtr->initTimerType; m_isActive = true; - m_detectCollision = m_data[m_type].detectCollision; + m_detectCollision = m_dataPtr->detectCollision; m_state = 0; m_tiltAngle = 0; m_tiltVelocity = 0; @@ -522,13 +522,13 @@ void CNpcPlatform::init() m_initRotation = 0; m_lifetime = 0; - m_lifetimeType = m_data[m_type].lifetimeType; + m_lifetimeType = m_dataPtr->lifetimeType; m_isShuttingDown = false; m_npcPath.initPath(); - m_speed = m_data[m_type].speed; + m_speed = m_dataPtr->speed; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -539,7 +539,7 @@ void CNpcPlatform::init( DVECTOR initPos ) Pos = m_initPos = m_base = initPos; - m_initLifetime = m_lifetime = GameState::getOneSecondInFrames() * m_data[m_type].lifetime; + m_initLifetime = m_lifetime = GameState::getOneSecondInFrames() * m_dataPtr->lifetime; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -560,10 +560,10 @@ void CNpcPlatform::reinit() m_rotation = 0; m_reversed = false; m_contact = false; - m_timer = m_data[m_type].initTimer * GameState::getOneSecondInFrames(); - m_timerType = m_data[m_type].initTimerType; + m_timer = m_dataPtr->initTimer * GameState::getOneSecondInFrames(); + m_timerType = m_dataPtr->initTimerType; m_isActive = true; - m_detectCollision = m_data[m_type].detectCollision; + m_detectCollision = m_dataPtr->detectCollision; m_state = 0; m_tiltAngle = 0; m_tiltVelocity = 0; @@ -1205,7 +1205,8 @@ void CNpcPlatform::addWaypoint( s32 xPos, s32 yPos ) void CNpcPlatform::setTypeFromMapEdit( u16 newType ) { - m_type = mapEditConvertTable[newType]; +int Type= mapEditConvertTable[newType]; + setThingSubType(Type); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/source/platform/platform.h b/source/platform/platform.h index e3169c943..db9cf052a 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -103,7 +103,6 @@ public: virtual void think(int _frames); virtual void render(); virtual u8 canDrop() {return true;} - void setType( NPC_PLATFORM_UNIT_TYPE newType ) {m_type = newType;} void setTypeFromMapEdit( u16 newType ); virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); virtual u8 checkCollisionDelta( CThing *_thisThing, int threshold, CRECT collisionArea ); @@ -114,7 +113,6 @@ public: void setGraphic( u8 graphicNum ); virtual void setWaypoints( sThingPlatform *ThisPlatform ); virtual void trigger() {;} - NPC_PLATFORM_UNIT_TYPE getType() {return( m_type );} static NPC_PLATFORM_UNIT_TYPE getTypeFromMapEdit( u16 newType ); static CNpcPlatform *Create(int Type); @@ -187,7 +185,8 @@ protected: // internal variables - NPC_PLATFORM_UNIT_TYPE m_type; +// NPC_PLATFORM_UNIT_TYPE m_type; + NPC_PLATFORM_DATA *m_dataPtr; CNpcPath m_npcPath; s32 m_heading; s32 m_velocity; diff --git a/source/platform/plinear.cpp b/source/platform/plinear.cpp index 07b63444b..b0fa3996b 100644 --- a/source/platform/plinear.cpp +++ b/source/platform/plinear.cpp @@ -40,7 +40,7 @@ void CNpcLinearPlatform::processMovement( int _frames ) if ( !pathComplete ) { s16 decDir, incDir; - s16 maxTurnRate = m_data[m_type].turnSpeed; + s16 maxTurnRate = m_dataPtr->turnSpeed; decDir = m_heading - headingToTarget; diff --git a/source/platform/prbridge.cpp b/source/platform/prbridge.cpp index 829e4a540..c51b1c414 100644 --- a/source/platform/prbridge.cpp +++ b/source/platform/prbridge.cpp @@ -88,6 +88,7 @@ void CNpcRisingBridgePlatform::setWaypoints( sThingPlatform *ThisPlatform ) ASSERT( trigger ); trigger->init(); + trigger->setThingSubType(0); trigger->setPositionAndSize( newXPos << 4, newYPos << 4, 100, 0 ); //trigger->setTargetBox(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4,TriggerList->TargetSize.X<<4,TriggerList->TargetSize.Y<<4); trigger->setPlatform( this ); @@ -100,7 +101,7 @@ void CNpcRisingBridgePlatform::processMovement( int _frames ) if ( m_triggered ) { m_triggered = false; - m_extension += ( m_data[m_type].speed * _frames ) << 8; + m_extension += ( m_dataPtr->speed * _frames ) << 8; if ( m_extension > m_maxExtension ) { m_extension = m_maxExtension; diff --git a/source/player/pmbubble.cpp b/source/player/pmbubble.cpp index c033c849d..30bdfe9ef 100644 --- a/source/player/pmbubble.cpp +++ b/source/player/pmbubble.cpp @@ -107,7 +107,7 @@ void CPlayerModeBubbleMixture::think() CNpcPlayerBubblePlatform *bubble; DVECTOR pos; bubble=new ("bubble platform") CNpcPlayerBubblePlatform; - bubble->setType( CNpcPlatform::NPC_PLAYER_BUBBLE_PLATFORM ); + bubble->setThingSubType( CNpcPlatform::NPC_PLAYER_BUBBLE_PLATFORM ); bubble->setGraphic( (u8) 0 ); bubble->setTiltable( false ); pos=m_player->getPos(); diff --git a/source/projectl/projectl.cpp b/source/projectl/projectl.cpp index 808c7a317..c3d58f840 100644 --- a/source/projectl/projectl.cpp +++ b/source/projectl/projectl.cpp @@ -57,6 +57,7 @@ void CProjectile::init() m_spriteFrame = FRM__SPIKE; + setThingSubType(0); m_initHeading = m_heading = 0; m_lifetime = GameState::getOneSecondInFrames() * 2; m_movementType = PROJECTILE_DUMBFIRE; @@ -400,7 +401,7 @@ void CProjectile::collidedWith(CThing *_thisThing) void CPlayerProjectile::init() { CPlayerProjectileThing::init(); - + setThingSubType(0); m_heading = 0; m_lifetime = GameState::getOneSecondInFrames() * 2; m_movementType = PLAYER_PROJECTILE_DUMBFIRE; diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index 0ace61049..dcc05190e 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -244,7 +244,7 @@ void CThingManager::matchPressureSwitches() while( hazard ) { - if ( hazard->getType() == CNpcHazard::NPC_PRESSURE_SWITCH_HAZARD ) + if ( hazard->getThingSubType() == CNpcHazard::NPC_PRESSURE_SWITCH_HAZARD ) { CNpcPressureSwitchHazard *switchHazard = (CNpcPressureSwitchHazard *) hazard; @@ -256,7 +256,7 @@ void CThingManager::matchPressureSwitches() while( platform ) { - if ( platform->getType() == CNpcPlatform::NPC_TRAPDOOR_PLATFORM ) + if ( platform->getThingSubType() == CNpcPlatform::NPC_TRAPDOOR_PLATFORM ) { CNpcTrapdoorPlatform *trapdoor = (CNpcTrapdoorPlatform *) platform; @@ -292,7 +292,7 @@ void CThingManager::matchWheelsAndWeights() while( hazard1 ) { - if ( hazard1->getType() == CNpcHazard::NPC_RISING_WEIGHT_HAZARD ) + if ( hazard1->getThingSubType() == CNpcHazard::NPC_RISING_WEIGHT_HAZARD ) { CNpcRisingWeightHazard *weight = (CNpcRisingWeightHazard *) hazard1; DVECTOR wheelPos = weight->getWheelPos(); @@ -301,7 +301,7 @@ void CThingManager::matchWheelsAndWeights() while( hazard2 ) { - if ( hazard2->getType() == CNpcHazard::NPC_RISING_WEIGHT_WHEEL_HAZARD ) + if ( hazard2->getThingSubType() == CNpcHazard::NPC_RISING_WEIGHT_WHEEL_HAZARD ) { CNpcRisingWeightWheelHazard *wheel = (CNpcRisingWeightWheelHazard *) hazard2; @@ -860,8 +860,7 @@ int SubType=Thing->getThingSubType(); CThing **List=s_FreeList[Type]; // Check its been aquired/set correctly -// Temp workaround - ASSERT(SubType!=1234); +// ASSERT(SubType!=1234); if (SubType!=1234) { Thing->NextFreeThing=List[SubType]; @@ -870,7 +869,8 @@ CThing **List=s_FreeList[Type]; } else { -// delete Thing; + printf("%i %i\n",Type,SubType); + ASSERT(!"Thing not Setup Correctly"); Thing->NextFreeThing=DuffList; DuffList=Thing; DuffListCount++;