diff --git a/source/game/game.cpp b/source/game/game.cpp index 816a37d6b..c1bc689bf 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -812,7 +812,7 @@ void CGameScene::initLevel() { m_player->setCanExitLevelNow(); } - DVECTOR mapSize=Level.getMapSize(); + DVECTOR const &mapSize=Level.getMapSize(); CPlayer::CameraBox camBox={0,0,mapSize.vx<<4,mapSize.vy<<4}; m_player->setCameraBox(camBox); diff --git a/source/game/healthman.cpp b/source/game/healthman.cpp index 814c24c9f..b1a03b715 100644 --- a/source/game/healthman.cpp +++ b/source/game/healthman.cpp @@ -159,7 +159,7 @@ sItem *item=ItemList; int mapHeight; CLayerCollision *ColLayer=CGameScene::getCollision(); - mapHeight=GameScene.GetLevel().getMapSize().vy*16; + mapHeight=GameScene.GetLevel().getMapHeight16(); for (int i=0; iinit(MapPos,0); TileLayers[CLayerTile::LAYER_TILE_TYPE_ACTION]=NewLayer; + MapSize.vx=Layer->Width; + MapSize.vy=Layer->Height; + MapSize16.vx=Layer->Width*16; + MapSize16.vy=Layer->Height*16; } // Collision @@ -726,6 +730,7 @@ void CLevel::think(int _frames) /*****************************************************************************/ /*****************************************************************************/ /*****************************************************************************/ +/* DVECTOR CLevel::getMapSize() { DVECTOR size; @@ -737,7 +742,7 @@ sLayerHdr *layer; return size; } - +*/ /*****************************************************************************/ /*****************************************************************************/ diff --git a/source/level/level.h b/source/level/level.h index 405707fd7..a9677fb12 100644 --- a/source/level/level.h +++ b/source/level/level.h @@ -78,7 +78,14 @@ static CFmaScene::FMA_SCRIPT_NUMBER getFMAToFollow() {return LvlTable[s_glo sThingHazard **getHazardList() {return HazardList;} CLayerCollision *getCollisionLayer() {return CollisionLayer;} - DVECTOR getMapSize(); + + DVECTOR const &getMapSize() {return(MapSize);} + int getMapWidth() {return(MapSize.vx);} + int getMapHeight() {return(MapSize.vy);} + + DVECTOR const &getMapSize16() {return(MapSize16);} + int getMapWidth16() {return(MapSize16.vx);} + int getMapHeight16() {return(MapSize16.vy);} bool GetNextLevel(int &Lvl); @@ -132,6 +139,7 @@ static int s_playerFacing; static u8 m_isBossRespawn; static s32 m_bossHealth; + DVECTOR MapSize,MapSize16; static CNpcCheckpointHazard *m_checkpoint; // Level Repair stuff diff --git a/source/player/pmdead.cpp b/source/player/pmdead.cpp index 5b1728684..d5be7bdd7 100644 --- a/source/player/pmdead.cpp +++ b/source/player/pmdead.cpp @@ -124,7 +124,7 @@ void CPlayerModeDead::think() m_player->setAnimFrame(frame); } - if(m_player->getPos().vy<(GameScene.GetLevel().getMapSize().vy+4)*16) + if(m_player->getPos().vy<(GameScene.GetLevel().getMapHeight()+4)*16) { m_player->moveVertical(5); } diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index c159094d5..b788f0743 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -440,6 +440,8 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); m_ThinkBBox.XMax=s_ThinkBBoxX1+CamPos.vx; m_ThinkBBox.YMin=s_ThinkBBoxY0+CamPos.vy; m_ThinkBBox.YMax=s_ThinkBBoxY1+CamPos.vy; +CLevel &Lvl=GameScene.GetLevel(); +DVECTOR const &MapSize=Lvl.getMapSize16(); int i; CThing *thing; @@ -456,43 +458,52 @@ DVECTOR const &CamPos=CLevel::getCameraPos(); CRECT const *ThingRect= thing->getThinkBBox(); int lastFlag=thing->getThinkFlag()<<1; int Flag=1; - // Will speed this up - if (!thing->alwaysThink()) - { - if (ThingRect->x2x1>m_ThinkBBox.XMax) Flag=0; - if (ThingRect->y2y1>m_ThinkBBox.YMax) Flag=0; - } - thing->setThinkFlag(Flag); -// Is in think zone - if (Flag) - { - thing->think(_frames); -// thing->updateCollisionArea(); - if (thing->canCollide()) - { - CThingManager::addToCollisionList(thing); - } - } - Flag|=lastFlag; -// Handle enter/leave states (not sure of viabilty now) - switch (Flag) - { // Last This - case 0: // 0 0 - break; - case 1: // 0 1 -// thing->enterThinkZone(_frames); - break; - case 2: // 1 0 - thing->leftThinkZone(_frames); - break; - case 3: // 1 1 - break; - default: - ASSERT("Invalid Think State"); - } + DVECTOR const &ThingPos=thing->getPos(); + // Will speed this up + if (ThingPos.vx<0 || ThingPos.vx>=MapSize.vx || ThingPos.vy<0 || ThingPos.vy>=MapSize.vy) + { + thing->setToShutdown(); + SYSTEM_DBGMSG("ThingOffMap: T:%i S:%i TXY%i %i, MWH%i %i\n",(int)thing->getThingType(),(int)thing->getThingSubType(),ThingPos.vx,ThingPos.vy,MapSize.vx,MapSize.vy); + } + else + { + if (!thing->alwaysThink()) + { + if (ThingRect->x2x1>m_ThinkBBox.XMax) Flag=0; + if (ThingRect->y2y1>m_ThinkBBox.YMax) Flag=0; + } + thing->setThinkFlag(Flag); +// Is in think zone + if (Flag) + { + thing->think(_frames); +// thing->updateCollisionArea(); + if (thing->canCollide()) + { + CThingManager::addToCollisionList(thing); + } + } + Flag|=lastFlag; +// Handle enter/leave states (not sure of viabilty now) + switch (Flag) + { // Last This + case 0: // 0 0 + break; + case 1: // 0 1 + // thing->enterThinkZone(_frames); + break; + case 2: // 1 0 + thing->leftThinkZone(_frames); + break; + case 3: // 1 1 + break; + default: + ASSERT("Invalid Think State"); + } /* THIS WILL NOT STAY HERE, THINGS MUST BE INITIALISED CORRECTLY */ - thing->updateCollisionArea(); + thing->updateCollisionArea(); + } thing=thing->m_nextListThing; } }