diff --git a/source/level/level.cpp b/source/level/level.cpp index af14494c7..b41438d5c 100644 --- a/source/level/level.cpp +++ b/source/level/level.cpp @@ -421,7 +421,6 @@ void CLevel::initThings(int _respawningLevel) trigger->setPositionAndSize(TriggerList->Pos.X<<4,TriggerList->Pos.Y<<4, TriggerList->Width<<4,TriggerList->Height<<4); trigger->setTargetBox(TriggerList->TargetPos.X<<4,TriggerList->TargetPos.Y<<4,TriggerList->TargetSize.X<<4,TriggerList->TargetSize.Y<<4); - trigger->updateCollisionArea(); } TriggerList++; } @@ -444,7 +443,6 @@ void CLevel::initThings(int _respawningLevel) pos.vx=ItemList->Pos.X<<4; pos.vy=ItemList->Pos.Y<<4; newPickup=createPickup((PICKUP_TYPE)ItemList->Type,&pos); - newPickup->updateCollisionArea(); if(isSpat) { ((CSpatulaPickup*)newPickup)->setSpatulaNumber(spatNumber); @@ -479,7 +477,6 @@ void CLevel::initThings(int _respawningLevel) enemy->setLayerCollision( getCollisionLayer() ); enemy->setupWaypoints( ThisActor ); enemy->postInit(); - enemy->updateCollisionArea(); if ( ThisActor->Speed ) { @@ -494,7 +491,6 @@ void CLevel::initThings(int _respawningLevel) friendNpc=CNpcFriend::Create(ThisActor); friendNpc->setLayerCollision( getCollisionLayer() ); friendNpc->postInit(); - friendNpc->updateCollisionArea(); } break; @@ -514,7 +510,6 @@ void CLevel::initThings(int _respawningLevel) platform = CNpcPlatform::Create( ThisPlatform ); platform->setLayerCollision( getCollisionLayer() ); platform->postInit(); - platform->updateCollisionArea(); if ( ThisPlatform->Speed ) { @@ -532,7 +527,6 @@ void CLevel::initThings(int _respawningLevel) CNpcHazard *hazard; hazard = CNpcHazard::Create( ThisHazard ); hazard->setLayerCollision( getCollisionLayer() ); - hazard->updateCollisionArea(); if ( ThisHazard->Respawn ) { hazard->setRespawnRate( ThisHazard->Respawn ); @@ -543,6 +537,7 @@ void CLevel::initThings(int _respawningLevel) // initialise jellyfish generator CJellyfishGenerator::init(); + CThingManager::initAllThings(); } diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index e935198ea..bf993a45c 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -152,6 +152,25 @@ void CThingManager::killAllThingsForRespawn() } } +/*---------------------------------------------------------------------- + Function: + Purpose: + Params: + Returns: + ---------------------------------------------------------------------- */ +void CThingManager::initAllThings() +{ + for(int i=0; iupdateCollisionArea(); + thing=thing->m_nextListThing; + } + } +} + /*---------------------------------------------------------------------- Function: Purpose: @@ -172,9 +191,10 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); int i; CThing *thing; CThing *thing1,*thing2,*playerThing; + initList(s_CollisionLists); - for(i=0;ithink(_frames); -// thing->updateCollisionArea(); + thing->updateCollisionArea(); if (thing->canCollide()) { - CThingManager::addToCollisionList(thing); + CThingManager::addToCollisionList(thing); } } /* THIS WILL NOT STAY HERE, THINGS MUST BE INITIALISED CORRECTLY */ - thing->updateCollisionArea(); +// thing->updateCollisionArea(); thing=thing->m_nextListThing; } @@ -213,7 +233,7 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); playerThing=s_CollisionLists[CThing::TYPE_PLAYER]; - if (playerThing) + if (player && playerThing) { playerThing->setHasPlatformCollided( false ); playerThing->setNewCollidedPos( playerThing->getPos() ); @@ -514,13 +534,12 @@ void CThingManager::removeFromThingList(CThing *_this) Params: Returns: ---------------------------------------------------------------------- */ -void CThingManager::addToCollisionList(CThing *_this) +void CThingManager::addToCollisionList(CThing *thing) { -int Type=_this->getThingType(); - - _this->m_nextCollisionThing=s_CollisionLists[Type]; - s_CollisionLists[Type]=_this; +int Type=thing->getThingType(); + thing->m_nextCollisionThing=s_CollisionLists[Type]; + s_CollisionLists[Type]=thing; } /*---------------------------------------------------------------------- @@ -536,13 +555,14 @@ void CThing::init() m_numChildren = 0; Pos.vx=Pos.vy=10; - - // Add to thing list - CThingManager::addToThingList(this); - +// These need to stay for init setCollisionSize(20,20); // Some temporary defaults.. (pkg) setCollisionCentreOffset(0,0); setCollisionAngle(0); + +// Add to thing list + CThingManager::addToThingList(this); + } /*---------------------------------------------------------------------- diff --git a/source/thing/thing.h b/source/thing/thing.h index febe5bda4..d97cfe3b7 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -55,6 +55,7 @@ public: static void shutdown(); static void killAllThingsForRespawn(); + static void initAllThings(); static void thinkAllThings(int _frames); static void renderAllThings(); static void processEventAllThings(GAME_EVENT _event,CThing *_sourceThing);