diff --git a/source/platform/pbgeyser.cpp b/source/platform/pbgeyser.cpp index ac355c60c..63e52f1ea 100644 --- a/source/platform/pbgeyser.cpp +++ b/source/platform/pbgeyser.cpp @@ -61,7 +61,8 @@ void CNpcGeyserPlatformGenerator::think( int _frames ) { case NPC_BUBBLE_PLATFORM: { - newPlatform = new ("falling platform") CNpcBubblePlatform; + //newPlatform = new ("falling platform") CNpcBubblePlatform; + newPlatform = CNpcPlatform::Create( m_targetType ); break; } diff --git a/source/platform/pfgen.cpp b/source/platform/pfgen.cpp index d3f75a766..0b0d6215a 100644 --- a/source/platform/pfgen.cpp +++ b/source/platform/pfgen.cpp @@ -70,7 +70,8 @@ void CNpcFallingPlatformGenerator::think( int _frames ) case NPC_CRATE_PLATFORM: case NPC_VERTICAL_OILDRUM_PLATFORM: { - newPlatform = new ("falling platform") CNpcFallingNoRespawnPlatform; + //newPlatform = new ("falling platform") CNpcFallingNoRespawnPlatform; + newPlatform = CNpcPlatform::Create( m_targetType ); break; } diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index fd7bb3a84..5a8564488 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -169,12 +169,10 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) +CNpcPlatform *CNpcPlatform::Create(int Type) { CNpcPlatform *platform; - NPC_PLATFORM_UNIT_TYPE Type = getTypeFromMapEdit( ThisPlatform->Type ); - platform = (CNpcPlatform*)CThingManager::GetThing(CThing::TYPE_PLATFORM,Type); if (!platform) switch( Type ) @@ -182,7 +180,6 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) case NPC_LINEAR_PLATFORM: { platform = new ("linear platform") CNpcLinearPlatform; - break; } @@ -268,19 +265,7 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) case NPC_DUAL_PLATFORM: { - CNpcDualPlatform *dualPlatformMaster; - platform = dualPlatformMaster = new ("dual platform master") CNpcDualPlatform; - dualPlatformMaster->setMaster( true ); - CNpcDualPlatform *dualPlatformSlave; - dualPlatformSlave = new ("dual platform slave") CNpcDualPlatform; - dualPlatformSlave->setMaster( false ); - dualPlatformMaster->setOtherPlatform( dualPlatformSlave ); - dualPlatformSlave->setOtherPlatform( dualPlatformMaster ); - - dualPlatformSlave->setType( Type ); - dualPlatformSlave->setGraphic( ThisPlatform ); - dualPlatformSlave->setTiltable( false ); - + platform = new ("dual platform master") CNpcDualPlatform; break; } @@ -389,12 +374,8 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) } ASSERT(platform); - platform->setType( Type ); + platform->setType( (NPC_PLATFORM_UNIT_TYPE) Type ); platform->setThingSubType( Type ); - platform->setGraphic( ThisPlatform ); - - platform->setWaypoints( ThisPlatform ); - platform->setTiltable( false ); return( platform ); @@ -402,6 +383,48 @@ CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +CNpcPlatform *CNpcPlatform::Create(sThingPlatform *ThisPlatform) +{ + CNpcPlatform *platform; + + NPC_PLATFORM_UNIT_TYPE Type = getTypeFromMapEdit( ThisPlatform->Type ); + + platform=Create(Type); + + switch( Type ) + { + case NPC_DUAL_PLATFORM: + { + CNpcDualPlatform *dualPlatformMaster = (CNpcDualPlatform *) platform; + dualPlatformMaster->setMaster( true ); + + CNpcDualPlatform *dualPlatformSlave; + dualPlatformSlave = (CNpcDualPlatform *) CNpcPlatform::Create( NPC_DUAL_PLATFORM ); + dualPlatformSlave->setMaster( false ); + + dualPlatformSlave->setType( Type ); + dualPlatformSlave->setGraphic( ThisPlatform ); + dualPlatformSlave->setTiltable( false ); + + dualPlatformMaster->setOtherPlatform( dualPlatformSlave ); + dualPlatformSlave->setOtherPlatform( dualPlatformMaster ); + + break; + } + + default: + break; + } + + ASSERT(platform); + platform->setGraphic( ThisPlatform ); + platform->setWaypoints( ThisPlatform ); + + return( platform ); +} + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CNpcPlatform::setWaypoints( sThingPlatform *ThisPlatform ) { int pointNum; diff --git a/source/platform/platform.h b/source/platform/platform.h index c6db76977..e0380e512 100644 --- a/source/platform/platform.h +++ b/source/platform/platform.h @@ -115,6 +115,7 @@ public: NPC_PLATFORM_UNIT_TYPE getType() {return( m_type );} static NPC_PLATFORM_UNIT_TYPE getTypeFromMapEdit( u16 newType ); + static CNpcPlatform *Create(int Type); static CNpcPlatform *Create(sThingPlatform *ThisPlatform); void setSpeed( s16 newSpeed ) {m_speed = newSpeed;}