From c7fe8c740b93d495b833d59e4df531c10e2b9dd2 Mon Sep 17 00:00:00 2001 From: Daveo Date: Mon, 23 Jul 2001 19:26:37 +0000 Subject: [PATCH] --- source/enemy/nanemone.cpp | 4 +-- source/enemy/nfdutch.cpp | 2 +- source/enemy/ngeneric.cpp | 2 +- source/enemy/nmjfish.cpp | 4 +-- source/enemy/npc.cpp | 16 +++++------ source/enemy/npcpath.cpp | 10 +++---- source/enemy/npcpath.h | 10 +++---- source/enemy/nshrkman.cpp | 2 +- source/enemy/nsjback.cpp | 4 +-- source/enemy/nssnake.cpp | 36 +++++++++++------------ source/enemy/nssnake.h | 6 ++-- source/enemy/nworm.cpp | 30 +++++++++---------- source/enemy/nworm.h | 4 +-- source/friend/fgary.cpp | 2 +- source/friend/fplnkton.cpp | 4 +-- source/fx/fxlaser.cpp | 13 ++++----- source/game/game.cpp | 56 ++---------------------------------- source/game/game.h | 2 +- source/game/healthman.cpp | 4 +-- source/game/healthman.h | 4 +-- source/gfx/actor.cpp | 38 ++++++------------------ source/gfx/actor.h | 12 ++------ source/hazard/hbbarrel.cpp | 2 +- source/hazard/hcheck.cpp | 4 +-- source/hazard/hfalling.cpp | 2 +- source/hazard/hflytrap.cpp | 2 +- source/hazard/hpendulm.cpp | 2 +- source/hazard/hrckshrd.cpp | 2 +- source/hazard/hrweight.cpp | 2 +- source/jellfish/jellfish.cpp | 2 +- source/level/layertile.cpp | 4 +-- source/level/level.h | 2 +- source/platform/pbaloon.cpp | 18 ++++++------ source/platform/pbaloon.h | 2 +- source/platform/pbob.cpp | 2 +- source/platform/pbounce.cpp | 12 ++++---- source/platform/pbubble.cpp | 16 +++++------ source/platform/pbubtube.cpp | 12 ++++---- source/platform/pbwheel.cpp | 2 +- source/platform/pcart.cpp | 16 +++++------ source/platform/pclam.cpp | 12 ++++---- source/platform/pconveyr.cpp | 12 ++++---- source/platform/pdual.cpp | 22 +++++++------- source/platform/pfallnor.cpp | 2 +- source/platform/pfblock.cpp | 14 ++++----- source/platform/pgbubble.cpp | 2 +- source/platform/pghost.cpp | 4 +-- source/platform/pjellfsh.cpp | 12 ++++---- source/platform/platform.cpp | 54 +++++++++++++++++----------------- source/platform/plift.cpp | 20 ++++++------- source/platform/ppendulm.cpp | 2 +- source/platform/psbarrel.cpp | 16 +++++------ source/platform/pseesaw.cpp | 2 +- source/platform/psoil.cpp | 2 +- source/player/player.cpp | 10 +++---- source/player/player.h | 10 +++---- source/player/pmcart.cpp | 5 ++-- source/player/pmcoral.cpp | 10 +++---- source/player/pmnet.cpp | 8 +++--- source/player/pmodes.cpp | 21 ++++++-------- source/player/pmodes.h | 2 +- source/player/psbutt.cpp | 6 ++-- source/player/psduck.cpp | 3 +- source/projectl/prnpc.cpp | 2 +- source/projectl/prnpcspr.cpp | 3 +- source/projectl/projectl.cpp | 37 +++--------------------- source/projectl/projectl.h | 6 ++-- source/thing/thing.cpp | 39 ++++++------------------- source/thing/thing.h | 36 +++++++++++++---------- source/triggers/trestart.cpp | 4 +-- 70 files changed, 302 insertions(+), 445 deletions(-) diff --git a/source/enemy/nanemone.cpp b/source/enemy/nanemone.cpp index b5c32ea93..019b30cc2 100644 --- a/source/enemy/nanemone.cpp +++ b/source/enemy/nanemone.cpp @@ -468,14 +468,14 @@ void CNpcAnemone2Enemy::render() spikePos.vy += result.vy; sFrameHdr *frameHdr; - DVECTOR offset; + int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth(FRM__SPIKE); int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight(FRM__SPIKE); - offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); x = spikePos.vx - offset.vx; y = spikePos.vy - offset.vy; diff --git a/source/enemy/nfdutch.cpp b/source/enemy/nfdutch.cpp index e54f2e317..33465b442 100644 --- a/source/enemy/nfdutch.cpp +++ b/source/enemy/nfdutch.cpp @@ -161,7 +161,7 @@ void CNpcFlyingDutchmanEnemy::processMovement( int _frames ) { CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); s32 minX, maxX; m_npcPath.getPathXExtents( &minX, &maxX ); diff --git a/source/enemy/ngeneric.cpp b/source/enemy/ngeneric.cpp index 13f5c2e86..b86b73f49 100644 --- a/source/enemy/ngeneric.cpp +++ b/source/enemy/ngeneric.cpp @@ -131,7 +131,7 @@ void CNpcEnemy::processGenericGetUserDist( int _frames, s32 *distX, s32 *distY ) CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); *distX = playerPos.vx - this->Pos.vx; *distY = playerPos.vy - this->Pos.vy; diff --git a/source/enemy/nmjfish.cpp b/source/enemy/nmjfish.cpp index d14ffd1cf..ee3c66886 100644 --- a/source/enemy/nmjfish.cpp +++ b/source/enemy/nmjfish.cpp @@ -374,7 +374,7 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames ) { CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); Pos.vx = playerPos.vx + ( ( 70 * rcos( m_extension ) ) >> 12 ); Pos.vy = playerPos.vy + ( ( 70 * rsin( m_extension ) ) >> 12 ); @@ -396,7 +396,7 @@ void CNpcMotherJellyfishEnemy::processMovement( int _frames ) { Pos.vx += 8 * _frames; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( Pos.vx - offset.vx > VidGetScrW() ) { diff --git a/source/enemy/npc.cpp b/source/enemy/npc.cpp index cb917a6cd..ce1f7c22f 100644 --- a/source/enemy/npc.cpp +++ b/source/enemy/npc.cpp @@ -849,15 +849,15 @@ void CNpcEnemy::processAttackCollision() void CNpcEnemy::drawAttackEffect() { - CRECT rect; - rect = getCollisionArea(); + +CRECT const &rect = getCollisionArea(); DVECTOR thwakPos; s32 xDist; CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); xDist = playerPos.vx - this->Pos.vx; @@ -1320,7 +1320,7 @@ void CNpcEnemy::processShotDeathEnd( int _frames ) m_speed++; } - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( Pos.vy - offset.vy > VidGetScrH() ) { @@ -1507,8 +1507,8 @@ int CNpcEnemy::canCollide() void CNpcEnemy::processEnemyCollision( CThing *thisThing ) { - DVECTOR otherPos = thisThing->getPos(); - DVECTOR otherDelta = thisThing->getPosDelta(); + DVECTOR const &otherPos = thisThing->getPos(); + DVECTOR otherDelta = thisThing->getPosDelta(); s32 xDist = Pos.vx - otherPos.vx; s32 yDist = Pos.vy - otherPos.vy; @@ -1572,8 +1572,8 @@ void CNpcEnemy::processEnemyCollision( CThing *thisThing ) void CNpcEnemy::processUserCollision( CThing *thisThing ) { - DVECTOR otherPos = thisThing->getPos(); - DVECTOR otherDelta = thisThing->getPosDelta(); + DVECTOR const &otherPos = thisThing->getPos(); + DVECTOR const &otherDelta = thisThing->getPosDelta(); s32 xDist = Pos.vx - otherPos.vx; s32 yDist = Pos.vy - otherPos.vy; diff --git a/source/enemy/npcpath.cpp b/source/enemy/npcpath.cpp index c4026eaf3..445b58b1e 100644 --- a/source/enemy/npcpath.cpp +++ b/source/enemy/npcpath.cpp @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool CNpcPath::isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist ) +bool CNpcPath::isPointNear( DVECTOR const &testPos, s32 *xDist, s32 *yDist ) { s32 xDistSqr, yDistSqr; @@ -268,14 +268,14 @@ void CNpcPath::reversePathDir() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool CNpcPath::getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ) +bool CNpcPath::getDistToNextWaypoint( DVECTOR const ¤tPos, s32 *distX, s32 *distY ) { return( isPointNear( currentPos, distX, distY ) ); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ) +s32 CNpcPath::think( DVECTOR const ¤tPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ) { if ( !waypointPtr ) { @@ -305,7 +305,7 @@ s32 CNpcPath::think( DVECTOR currentPos, bool *pathComplete, bool *waypointChang //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist ) +bool CNpcPath::thinkFlat( DVECTOR const ¤tPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist ) { bool pointChange = false; @@ -350,7 +350,7 @@ bool CNpcPath::thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s3 //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -bool CNpcPath::thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ) +bool CNpcPath::thinkVertical( DVECTOR const ¤tPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ) { bool pointChange = false; diff --git a/source/enemy/npcpath.h b/source/enemy/npcpath.h index 680678493..caee80c67 100644 --- a/source/enemy/npcpath.h +++ b/source/enemy/npcpath.h @@ -33,10 +33,10 @@ public: void decPath(); void resetPath(); void reversePathDir(); - s32 think( DVECTOR currentPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ); - bool thinkFlat( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist = 10 ); - bool thinkVertical( DVECTOR currentPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ); - bool getDistToNextWaypoint( DVECTOR currentPos, s32 *distX, s32 *distY ); + s32 think( DVECTOR const ¤tPos, bool *pathComplete, bool *waypointChange, s32 *distX, s32 *distY ); + bool thinkFlat( DVECTOR const ¤tPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading, u8 waypointDist = 10 ); + bool thinkVertical( DVECTOR const ¤tPos, bool *pathComplete, s32 *distX, s32 *distY, s32 *heading ); + bool getDistToNextWaypoint( DVECTOR const ¤tPos, s32 *distX, s32 *distY ); void getPathXExtents( s32 *minExtent, s32 *maxExtent ); void getPathYExtents( s32 *minExtent, s32 *maxExtent ); u8 getWaypointCount() { return( waypointCount ); } @@ -44,7 +44,7 @@ public: void setWaypointPtr( u16 *newPtr ); void setPathExtents(); u16 *getWaypointPtr() { return( waypointPtr ); } - bool isPointNear( DVECTOR testPos, s32 *xDist, s32 *yDist ); + bool isPointNear( DVECTOR const &testPos, s32 *xDist, s32 *yDist ); void getCurrentWaypointPos( DVECTOR *waypointPos ); private: diff --git a/source/enemy/nshrkman.cpp b/source/enemy/nshrkman.cpp index 30936f098..60b28239a 100644 --- a/source/enemy/nshrkman.cpp +++ b/source/enemy/nshrkman.cpp @@ -158,7 +158,7 @@ void CNpcSharkManEnemy::processClose( int _frames ) newPos.vy -= 50; CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); xDist = playerPos.vx - newPos.vx; yDist = playerPos.vy - newPos.vy; diff --git a/source/enemy/nsjback.cpp b/source/enemy/nsjback.cpp index b1d636edd..6bd728a4c 100644 --- a/source/enemy/nsjback.cpp +++ b/source/enemy/nsjback.cpp @@ -55,7 +55,7 @@ void CNpcSmallJellyfishBackgroundEnemy::processMovement( int _frames ) // change direction? DVECTOR renderPos; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); renderPos.vx = Pos.vx - offset.vx; renderPos.vy = Pos.vy - offset.vy; @@ -175,7 +175,7 @@ void CNpcSmallJellyfishBackgroundEnemy::shutdown() void CNpcSmallJellyfishBackgroundEnemy::processUserCollision( CThing *thisThing ) { - DVECTOR otherPos = thisThing->getPos(); + DVECTOR const &otherPos = thisThing->getPos(); DVECTOR otherDelta = thisThing->getPosDelta(); s32 xDist = Pos.vx - otherPos.vx; diff --git a/source/enemy/nssnake.cpp b/source/enemy/nssnake.cpp index e0dd79f1b..3d2ce164d 100644 --- a/source/enemy/nssnake.cpp +++ b/source/enemy/nssnake.cpp @@ -679,7 +679,7 @@ void CNpcSeaSnakeEnemy::updateTail( DVECTOR &oldPos, int _frames ) for ( segmentCount = 0 ; segmentCount < m_segmentCount ; segmentCount++ ) { - DVECTOR currentPos = m_segmentArray[segmentCount].getPos(); + DVECTOR const ¤tPos = m_segmentArray[segmentCount].getPos(); s32 xDist = oldPos.vx - currentPos.vx; s32 yDist = oldPos.vy - currentPos.vy; @@ -692,7 +692,7 @@ void CNpcSeaSnakeEnemy::updateTail( DVECTOR &oldPos, int _frames ) if ( segmentCount < m_segmentCount - 1 ) { - DVECTOR nextPos = m_segmentArray[segmentCount + 1].getPos(); + DVECTOR const &nextPos = m_segmentArray[segmentCount + 1].getPos(); xDist = currentPos.vx - nextPos.vx; yDist = currentPos.vy - nextPos.vy; headingFromNext = ratan2( yDist, xDist ); @@ -1000,23 +1000,22 @@ void CNpcSeaSnakeEnemy::render() int CNpcSeaSnakeEnemy::checkCollisionAgainst( CThing *_thisThing, int _frames ) { - DVECTOR pos,thisThingPos; +// DVECTOR pos,thisThingPos; int radius; int collided; - pos=getCollisionCentre(); - thisThingPos=_thisThing->getCollisionCentre(); +DVECTOR const &pos=getCollisionCentre(); +DVECTOR const &thisThingPos=_thisThing->getCollisionCentre(); radius=getCollisionRadius()+_thisThing->getCollisionRadius(); collided=false; if(abs(pos.vx-thisThingPos.vx)getCollisionArea(); +CRECT const &thisRect=getCollisionArea(); +CRECT const &thatRect=_thisThing->getCollisionArea(); if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) @@ -1096,23 +1095,22 @@ void CNpcSeaSnakeSegment::render() int CNpcSeaSnakeSegment::checkCollisionAgainst( CThing *_thisThing, int _frames ) { - DVECTOR pos,thisThingPos; +// DVECTOR pos,thisThingPos; int radius; int collided; - pos = getCollisionCentre(); - thisThingPos = _thisThing->getCollisionCentre(); +DVECTOR const &pos = getCollisionCentre(); +DVECTOR const &thisThingPos = _thisThing->getCollisionCentre(); radius = getCollisionRadius() + _thisThing->getCollisionRadius(); collided = false; if(abs(pos.vx-thisThingPos.vx)getCollisionArea(); +CRECT const &thisRect=getCollisionArea(); +CRECT const &thatRect=_thisThing->getCollisionArea(); if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) @@ -1144,7 +1142,7 @@ void CNpcSeaSnakeEnemy::processShot( int _frames ) m_state = NPC_GENERIC_HIT_DEATH_END; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( Pos.vy - offset.vy > VidGetScrH() ) { @@ -1196,7 +1194,7 @@ u8 CNpcSeaSnakeEnemy::isSnakeStopped() return( true ); } - DVECTOR tailPos = m_segmentArray[m_segmentCount - 1].getPos(); + DVECTOR const &tailPos = m_segmentArray[m_segmentCount - 1].getPos(); if ( tailPos.vx == Pos.vx && tailPos.vy == Pos.vy ) { @@ -1210,7 +1208,7 @@ u8 CNpcSeaSnakeEnemy::isSnakeStopped() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CNpcSeaSnakeEnemy::moveEntireSnake( DVECTOR newPos ) +void CNpcSeaSnakeEnemy::moveEntireSnake( DVECTOR const &newPos ) { Pos.vx = newPos.vx; Pos.vy = newPos.vy; diff --git a/source/enemy/nssnake.h b/source/enemy/nssnake.h index 7e34adc17..2a9012d80 100644 --- a/source/enemy/nssnake.h +++ b/source/enemy/nssnake.h @@ -28,8 +28,8 @@ public: void processEnemyCollision( CThing *thisThing ); void setScale( u16 scale ) {m_scale = scale;} CNpcSeaSnakeSegment *m_nextSegment; - void setPos( DVECTOR newPos ) {Pos = newPos;} - DVECTOR getPos() {return( Pos );} + void setPos( DVECTOR const &newPos ) {Pos = newPos;} + DVECTOR const &getPos() {return( Pos );} void setHeading( s16 newHeading ) {m_heading = newHeading;} void updateCollisionArea(); int checkCollisionAgainst(CThing *_thisThing, int _frames); @@ -70,7 +70,7 @@ protected: void processUserCollision( CThing *thisThing ); u8 processPathMove( int _frames, s32 *moveX, s32 *moveY, s32 *moveVel, s32 *moveDist ); u8 isSnakeStopped(); - void moveEntireSnake( DVECTOR newPos ); + void moveEntireSnake( DVECTOR const &newPos ); void addHealthMeter(); void updateTail( DVECTOR &oldPos, int _frames ); diff --git a/source/enemy/nworm.cpp b/source/enemy/nworm.cpp index 61b55456d..7391352e6 100644 --- a/source/enemy/nworm.cpp +++ b/source/enemy/nworm.cpp @@ -277,7 +277,7 @@ void CNpcParasiticWormEnemy::processMovement( int _frames ) for ( segmentCount = 0 ; segmentCount < NPC_PARASITIC_WORM_LENGTH ; segmentCount++ ) { - DVECTOR currentPos = m_segmentArray[segmentCount].getPos(); + DVECTOR const ¤tPos = m_segmentArray[segmentCount].getPos(); s32 xDist = oldPos.vx - currentPos.vx; s32 yDist = oldPos.vy - currentPos.vy; @@ -290,7 +290,7 @@ void CNpcParasiticWormEnemy::processMovement( int _frames ) if ( segmentCount < NPC_PARASITIC_WORM_LENGTH - 1 ) { - DVECTOR nextPos = m_segmentArray[segmentCount + 1].getPos(); + DVECTOR const &nextPos = m_segmentArray[segmentCount + 1].getPos(); xDist = currentPos.vx - nextPos.vx; yDist = currentPos.vy - nextPos.vy; headingFromNext = ratan2( yDist, xDist ); @@ -469,23 +469,22 @@ void CNpcParasiticWormEnemy::render() int CNpcParasiticWormEnemy::checkCollisionAgainst( CThing *_thisThing, int _frames ) { - DVECTOR pos,thisThingPos; +// DVECTOR pos,thisThingPos; int radius; int collided; - pos=getCollisionCentre(); - thisThingPos=_thisThing->getCollisionCentre(); +DVECTOR const &pos=getCollisionCentre(); +DVECTOR const &thisThingPos=_thisThing->getCollisionCentre(); radius=getCollisionRadius()+_thisThing->getCollisionRadius(); collided=false; if(abs(pos.vx-thisThingPos.vx)getCollisionArea(); +CRECT const &thisRect=getCollisionArea(); +CRECT const &thatRect=_thisThing->getCollisionArea(); if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) @@ -565,23 +564,22 @@ void CNpcParasiticWormSegment::render() int CNpcParasiticWormSegment::checkCollisionAgainst( CThing *_thisThing, int _frames ) { - DVECTOR pos,thisThingPos; +// DVECTOR pos,thisThingPos; int radius; int collided; - pos = getCollisionCentre(); - thisThingPos = _thisThing->getCollisionCentre(); +DVECTOR const &pos = getCollisionCentre(); +DVECTOR const &thisThingPos = _thisThing->getCollisionCentre(); radius = getCollisionRadius() + _thisThing->getCollisionRadius(); collided = false; if(abs(pos.vx-thisThingPos.vx)getCollisionArea(); +CRECT const &thisRect=getCollisionArea(); +CRECT const &thatRect=_thisThing->getCollisionArea(); if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) diff --git a/source/enemy/nworm.h b/source/enemy/nworm.h index 1ae0e0228..783267dc7 100644 --- a/source/enemy/nworm.h +++ b/source/enemy/nworm.h @@ -23,8 +23,8 @@ public: void processEnemyCollision( CThing *thisThing ); void setScale( u16 scale ) {m_scale = scale;} CNpcParasiticWormSegment *m_nextSegment; - void setPos( DVECTOR newPos ) {Pos = newPos;} - DVECTOR getPos() {return( Pos );} + void setPos( DVECTOR const &newPos ) {Pos = newPos;} + DVECTOR const &getPos() {return( Pos );} void setHeading( s16 newHeading ) {m_heading = newHeading;} void updateCollisionArea(); int checkCollisionAgainst(CThing *_thisThing, int _frames); diff --git a/source/friend/fgary.cpp b/source/friend/fgary.cpp index 555a8c47c..0eabcbf8f 100644 --- a/source/friend/fgary.cpp +++ b/source/friend/fgary.cpp @@ -125,7 +125,7 @@ void CNpcGaryFriend::think( int _frames ) m_speed++; } - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( Pos.vy - offset.vy > VidGetScrH() ) { diff --git a/source/friend/fplnkton.cpp b/source/friend/fplnkton.cpp index 2adee59cd..bd90ce75e 100644 --- a/source/friend/fplnkton.cpp +++ b/source/friend/fplnkton.cpp @@ -63,7 +63,7 @@ void CNpcPlanktonFriend::render() // Render DVECTOR renderPos; DVECTOR origRenderPos; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); int frame = FRM_PLANKTON_STATIC00; int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth( frame ); int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight( frame ); @@ -71,7 +71,7 @@ void CNpcPlanktonFriend::render() renderPos.vx = Pos.vx - offset.vx - ( spriteWidth >> 1 ); renderPos.vy = Pos.vy - offset.vy - ( spriteHeight >> 1 ); - CRECT collisionRect = getCollisionArea(); +CRECT const &collisionRect = getCollisionArea(); collisionRect.x1 -= Pos.vx; collisionRect.x2 -= Pos.vx; collisionRect.y1 -= Pos.vy; diff --git a/source/fx/fxlaser.cpp b/source/fx/fxlaser.cpp index 4602df375..e331c57a4 100644 --- a/source/fx/fxlaser.cpp +++ b/source/fx/fxlaser.cpp @@ -96,23 +96,22 @@ int H=renderPos1.vy-renderPos0.vy; /*****************************************************************************/ int CFXLaser::checkCollisionAgainst(CThing *_thisThing, int _frames) { - DVECTOR pos,thisThingPos; +// DVECTOR pos,thisThingPos; int radius; int collided; - pos=getCollisionCentre(); - thisThingPos=_thisThing->getCollisionCentre(); +DVECTOR const &pos=getCollisionCentre(); +DVECTOR const &thisThingPos=_thisThing->getCollisionCentre(); radius=getCollisionRadius()+_thisThing->getCollisionRadius(); collided=false; if(abs(pos.vx-thisThingPos.vx)getCollisionArea(); +CRECT const &thisRect=getCollisionArea(); +CRECT const &thatRect=_thisThing->getCollisionArea(); if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) diff --git a/source/game/game.cpp b/source/game/game.cpp index ecf0b8484..8b22e0790 100644 --- a/source/game/game.cpp +++ b/source/game/game.cpp @@ -106,16 +106,7 @@ #include "gfx\actor.h" -int RenderZ=378;//256; Increased to make depth less, and SB more visible -// Horrible evil bodge 4 Petro, via Gary :o( -#define USE_GLOBAL_RGB -#ifdef USE_GLOBAL_RGB -u8 GlobalRGB[4]={127,127,127,127}; -int GlobalRGBSel=0; -char *GlobalRGBName[4]={"Sprites","Action","Mid","Other"}; -int GlobalRGBX=200; -int GlobalRGBY=28; -#endif +static const int RenderZ=378;//256; Increased to make depth less, and SB more visible /*****************************************************************************/ @@ -208,11 +199,6 @@ CGameScene GameScene; /*****************************************************************************/ void CGameScene::init() { -// Setup Constant Camera Matrix -// SetIdentTrans(&CamMtx,0,0,RenderZ); -// SetGeomScreen(RenderZ); -// SetTransMatrix(&CamMtx); - setCameraMtx(); s_genericFont=new ("CGameScene::Init") FontBank(); @@ -348,26 +334,7 @@ void CGameScene::render_showing_lives() void CGameScene::render_playing() { // CamMtx.t[2]=ZPos; // Temp -#ifdef USE_GLOBAL_RGB - if (PadIsConnected(1)) - { - s_genericFont->setTrans(0); - s_genericFont->setSMode(0); - for (int i=0; i<3; i++) - { - char Buf[32]; - if (i==GlobalRGBSel) - s_genericFont->setColour(255,255,255); - else - s_genericFont->setColour(64,64,64); - - sprintf(Buf,"%s: %i",GlobalRGBName[i],GlobalRGB[i]); - s_genericFont->print(GlobalRGBX,GlobalRGBY+(i*16),Buf); - } - } - -#endif if(m_levelHasTimer) { int timerValue; @@ -384,10 +351,6 @@ void CGameScene::render_playing() CThingManager::renderAllThings(); setCameraMtx(); -// SetIdentTrans(&CamMtx,0,0,RenderZ); -// SetGeomScreen(RenderZ); -// SetRotMatrix(&CamMtx); -// SetTransMatrix(&CamMtx); Level.render(); m_HealthManager->render(); @@ -543,19 +506,6 @@ void CGameScene::think_showing_lives(int _frames) /*****************************************************************************/ void CGameScene::think_playing(int _frames) { -#ifdef USE_GLOBAL_RGB - if (PadIsConnected(1)) - { - if (PadGetDown(1) & PAD_UP) GlobalRGBSel--; - if (PadGetDown(1) & PAD_DOWN) GlobalRGBSel++; - GlobalRGBSel&=3; - - if(PadGetHeld(1)&PAD_LEFT ) GlobalRGB[GlobalRGBSel]--; - if(PadGetHeld(1)&PAD_RIGHT ) GlobalRGB[GlobalRGBSel]++; - GlobalRGB[GlobalRGBSel]&=255; - } -#endif - if(s_readyToExit) { return; @@ -685,7 +635,7 @@ void CGameScene::think_playing(int _frames) if(!CConversation::isActive()&&!m_pauseMenu->isActive()) { - DVECTOR camPos; + DVECTOR camPos; CJellyfishGenerator::think( _frames, &Level ); CThingManager::thinkAllThings(_frames); camPos=m_player->getCameraPos(); @@ -832,7 +782,7 @@ void CGameScene::initLevel() /*****************************************************************************/ -void CGameScene::dropHealth(DVECTOR &Pos,int Amount,int Vel) +void CGameScene::dropHealth(DVECTOR const &Pos,int Amount,int Vel) { m_HealthManager->drop(Pos,Amount,Vel); } diff --git a/source/game/game.h b/source/game/game.h index a6d4df221..27353467a 100644 --- a/source/game/game.h +++ b/source/game/game.h @@ -62,7 +62,7 @@ static ACTOR_TYPE getActorType( int actorNum ) {return actorType[actorNum];} static void setBossHasBeenKilled() {s_bossHasBeenKilled=true;} static int getBossHasBeenKilled() {return s_bossHasBeenKilled;} -static void dropHealth(DVECTOR &Pos,int Amount,int Vel); +static void dropHealth(DVECTOR const &Pos,int Amount,int Vel); static void setCameraShake(s16 X,s16 Y); diff --git a/source/game/healthman.cpp b/source/game/healthman.cpp index 1f698af01..9d845200d 100644 --- a/source/game/healthman.cpp +++ b/source/game/healthman.cpp @@ -52,7 +52,7 @@ void CHealthManager::shutdown() /*****************************************************************************/ const int AngleS=2048+1024+512; -void CHealthManager::drop(DVECTOR &Pos,int Amount,int Vel) +void CHealthManager::drop(DVECTOR const &Pos,int Amount,int Vel) { int Count=0; int Am=Amount; @@ -86,7 +86,7 @@ int AngleInc=1024/Count; } /*****************************************************************************/ -void CHealthManager::addItem(DVECTOR &Pos,int TableIdx,int Angle,int Vel) +void CHealthManager::addItem(DVECTOR const &Pos,int TableIdx,int Angle,int Vel) { int Idx=0; diff --git a/source/game/healthman.h b/source/game/healthman.h index 2c98ad432..56d244c50 100644 --- a/source/game/healthman.h +++ b/source/game/healthman.h @@ -35,14 +35,14 @@ public: void init(); void shutdown(); - void drop(DVECTOR &Pos,int Amount,int Vel); + void drop(DVECTOR const &Pos,int Amount,int Vel); void checkPlayerCol(CPlayer *Thing); void think(int frames); void render(); protected: - void addItem(DVECTOR &Pos,int TableIdx,int Angle,int Vel); + void addItem(DVECTOR const &Pos,int TableIdx,int Angle,int Vel); sItem ItemList[ITEM_MAX]; sFrameHdr *FrameHdr; diff --git a/source/gfx/actor.cpp b/source/gfx/actor.cpp index fc01c6d93..e885ebd90 100644 --- a/source/gfx/actor.cpp +++ b/source/gfx/actor.cpp @@ -517,9 +517,6 @@ CActorGfx::~CActorGfx() void CActorGfx::setActor(sActorPool *ThisActor) { PoolEntry=ThisActor; -// ShadowXOfs=DEF_SHADOW_OFS; -// ShadowYOfs=DEF_SHADOW_OFS; -// ShadowFlag=false; OtPos=OTPOS__ACTOR_POS; } @@ -605,27 +602,11 @@ sSpriteAnim *ThisAnim=SpriteBank->AnimList+Anim; Ft4=GetPrimFT4(); SetUpFT4(Ft4,ThisNode,Pos.vx,Pos.vy,XFlip,YFlip); -extern u8 GlobalRGB[]; - setRGB0(Ft4,GlobalRGB[0],GlobalRGB[0],GlobalRGB[0]); Ft4->tpage=ThisNode->TPage; Ft4->clut=PoolEntry->ActorGfx->Clut; + setShadeTex(Ft4,1); addPrim(OtPtr+OtPos,Ft4); -/* - if (ShadowFlag) - { - POLY_FT4 *sFt4=GetPrimFT4(); - *sFt4=*Ft4; - sFt4->x0-=ShadowXOfs; - sFt4->x1-=ShadowXOfs; - sFt4->y0+=ShadowYOfs; - sFt4->y1+=ShadowYOfs; - setSemiTrans(sFt4,1); - setRGB0(sFt4,0,0,0); - addPrim(OtPtr+OtPos,sFt4); - } -*/ // Set BBox -//int HalfW=CurrentFrameGfx->W>>1; // Sizes now depend on aspect corrected sizes, so get sizes back from poly int BBoxW=Ft4->x1-Ft4->x0; int BBoxH=Ft4->y2-Ft4->y0; @@ -810,9 +791,7 @@ void CModelGfx::SetModel(int Type) } /*****************************************************************************/ -static const int MXO=0; -static const int MYO=-8*0; -void CModelGfx::Render(DVECTOR &Pos,SVECTOR *Angle,VECTOR *Scale) +void CModelGfx::Render(DVECTOR &Pos,SVECTOR *Angle,VECTOR *Scale,s32 ClipFlag) { #define BLOCK_MULT 16 sElem3d *Elem=&ModelElemBank[Model->ElemID]; @@ -848,8 +827,8 @@ sTri *TList=&ModelTriList[Elem->TriStart]; } } - RenderPos.vx=(INGAME_SCREENOFS_X+MXO)+Pos.vx; - RenderPos.vy=(INGAME_SCREENOFS_Y+MYO)+Pos.vy; + RenderPos.vx=(INGAME_SCREENOFS_X)+Pos.vx; + RenderPos.vy=(INGAME_SCREENOFS_Y)+Pos.vy; gte_SetRotMatrix(&Mtx); CMX_SetTransMtxXY(&RenderPos); @@ -860,20 +839,20 @@ sTri *TList=&ModelTriList[Elem->TriStart]; gte_ldv3(P0,P1,P2); setlen(TPrimPtr, GPU_PolyFT3Tag); TPrimPtr->code=TList->PolyCode; - setRGB0(TPrimPtr,128,128,128); gte_rtpt_b(); - + setShadeTex(TPrimPtr,1); T0=*(u32*)&TList->uv0; // Get UV0 & TPage T1=*(u32*)&TList->uv1; // Get UV1 & Clut - T2=*(u16*)&TList->uv2; // Get UV2 + T2=*(u32*)&TList->uv2; // Get UV2 *(u32*)&TPrimPtr->u0=T0; // Set UV0 *(u32*)&TPrimPtr->u1=T1; // Set UV1 - *(u16*)&TPrimPtr->u2=T2; // Set UV2 + *(u32*)&TPrimPtr->u2=T2; // Set UV2 ThisOT=OtPtr+TList->OTOfs; TList++; gte_nclip_b(); gte_stsxy3_ft3(TPrimPtr); gte_stopz(&ClipZ); + ClipZ|=ClipFlag; // <-- Evil!! if (ClipZ<=0) { addPrim(ThisOT,TPrimPtr); @@ -884,3 +863,4 @@ sTri *TList=&ModelTriList[Elem->TriStart]; SetPrimPtr((u8*)TPrimPtr); } + diff --git a/source/gfx/actor.h b/source/gfx/actor.h index fea0d6b58..adbd46d4d 100644 --- a/source/gfx/actor.h +++ b/source/gfx/actor.h @@ -130,11 +130,6 @@ static sActorPool *ActorList,*LastActor; class CActorGfx { public: - enum - { - DEF_SHADOW_OFS=32, - }; - CActorGfx(sActorPool *ThisActor); virtual ~CActorGfx(); @@ -149,8 +144,6 @@ virtual ~CActorGfx(); sBBox &GetBBox() {return(BBox);} -// void SetShadow(bool f) {ShadowFlag=f;} -// void SetShadowOfs(int X,int Y) {ShadowXOfs=X; ShadowYOfs=Y;} void SetOtPos(int Ot) {OtPos=Ot;} @@ -162,8 +155,6 @@ protected: sSpriteFrameGfx *CurrentFrameGfx; sBBox BBox; -// bool ShadowFlag; -// s16 ShadowXOfs,ShadowYOfs; u32 OtPos; }; @@ -179,7 +170,8 @@ virtual ~CModelGfx(){}; static void SetData(sLevelHdr *LevelHdr); void SetModel(int Type); - void Render(DVECTOR &Pos,SVECTOR *Angle=0,VECTOR *Scale=0); + void Render(DVECTOR &Pos,SVECTOR *Angle=0,VECTOR *Scale=0,s32 ClipFlag=0xffffffff); + void RenderClip(DVECTOR &Pos,SVECTOR *Angle=0,VECTOR *Scale=0) {Render(Pos,Angle,Scale,0);} sBBox &GetBBox() {return(Model->BBox);} protected: diff --git a/source/hazard/hbbarrel.cpp b/source/hazard/hbbarrel.cpp index e46fc8ef5..0f85299c3 100644 --- a/source/hazard/hbbarrel.cpp +++ b/source/hazard/hbbarrel.cpp @@ -76,7 +76,7 @@ void CNpcBouncingBarrelHazard::processMovement( int _frames ) m_rotation += 64 * _frames; m_rotation &= 4095; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); s32 yPos = Pos.vy - offset.vy; diff --git a/source/hazard/hcheck.cpp b/source/hazard/hcheck.cpp index b73bf4917..a8cd46fcb 100644 --- a/source/hazard/hcheck.cpp +++ b/source/hazard/hcheck.cpp @@ -75,7 +75,7 @@ void CNpcCheckpointHazard::render() { int x,y; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth(m_spriteFrame); int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight(m_spriteFrame); @@ -101,7 +101,7 @@ void CNpcCheckpointHazard::collidedWith(CThing *_thisThing) { case TYPE_PLAYER: { - CRECT collisionArea=getCollisionArea(); + CRECT const &collisionArea=getCollisionArea(); DVECTOR respawnPos; respawnPos.vx=collisionArea.x1+((collisionArea.x2-collisionArea.x1)/2); respawnPos.vy=collisionArea.y2; diff --git a/source/hazard/hfalling.cpp b/source/hazard/hfalling.cpp index e887a8f28..b5c01c8df 100644 --- a/source/hazard/hfalling.cpp +++ b/source/hazard/hfalling.cpp @@ -156,7 +156,7 @@ void CNpcFallingHazard::processMovement( int _frames ) } } - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); s32 yPos = Pos.vy - offset.vy; diff --git a/source/hazard/hflytrap.cpp b/source/hazard/hflytrap.cpp index bc854b71d..0658fe6df 100644 --- a/source/hazard/hflytrap.cpp +++ b/source/hazard/hflytrap.cpp @@ -123,7 +123,7 @@ void CNpcFlyTrapHazard::render() scale.vy = ONE; scale.vz = ONE; - m_modelGfx->Render(renderPos,&rotation,&scale); + m_modelGfx->RenderClip(renderPos,&rotation,&scale); sBBox boundingBox = m_modelGfx->GetBBox(); diff --git a/source/hazard/hpendulm.cpp b/source/hazard/hpendulm.cpp index a7aec7642..313e8f06c 100644 --- a/source/hazard/hpendulm.cpp +++ b/source/hazard/hpendulm.cpp @@ -130,7 +130,7 @@ void CNpcPendulumHazard::render() int x1,y1,x2,y2; int minX, maxX, minY, maxY; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); CHazardThing::render(); diff --git a/source/hazard/hrckshrd.cpp b/source/hazard/hrckshrd.cpp index 7bb54e799..6c25af1a6 100644 --- a/source/hazard/hrckshrd.cpp +++ b/source/hazard/hrckshrd.cpp @@ -93,7 +93,7 @@ void CNpcRockShardHazard::processMovement( int _frames ) Pos.vy += yMovement; } - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); s32 yPos = Pos.vy - offset.vy; diff --git a/source/hazard/hrweight.cpp b/source/hazard/hrweight.cpp index 2305ebc39..5c5ddc2fa 100644 --- a/source/hazard/hrweight.cpp +++ b/source/hazard/hrweight.cpp @@ -144,7 +144,7 @@ void CNpcRisingWeightHazard::render() int x1,y1,x2,y2; int minX, maxX, minY, maxY; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( m_isActive ) { diff --git a/source/jellfish/jellfish.cpp b/source/jellfish/jellfish.cpp index 6f4214bb0..00963271b 100644 --- a/source/jellfish/jellfish.cpp +++ b/source/jellfish/jellfish.cpp @@ -122,7 +122,7 @@ void CJellyfishGenerator::think( int _frames, CLevel *level ) } } - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); DVECTOR startPos; diff --git a/source/level/layertile.cpp b/source/level/layertile.cpp index 1cbfdbc5e..4d2a5dfb7 100644 --- a/source/level/layertile.cpp +++ b/source/level/layertile.cpp @@ -41,7 +41,7 @@ TSPRT *PrimPtr=PrimBank; for (int i=0; iw=TILE2D_WIDTH; PrimPtr->h=TILE2D_HEIGHT; PrimPtr++; @@ -136,8 +136,6 @@ TSPRT *PrimPtr=PrimBank; PrimPtr->y0=TileY; setTSprtTPage(PrimPtr,Tile->TPage); *(u32*)&PrimPtr->u0=*(u32*)&Tile->u0; // copy uv AND clut -extern u8 GlobalRGB[]; - setRGB0(PrimPtr,GlobalRGB[2],GlobalRGB[2],GlobalRGB[2]); addPrim(ThisOT,PrimPtr); PrimPtr++; } diff --git a/source/level/level.h b/source/level/level.h index 66c017d6d..225eafbff 100644 --- a/source/level/level.h +++ b/source/level/level.h @@ -48,7 +48,7 @@ public: void render(); void think(int _frames); - void setCameraCentre(DVECTOR _pos) {MapPos=_pos;} + void setCameraCentre(DVECTOR const &_pos) {MapPos=_pos;} static DVECTOR const &getCameraPos() {return MapPos;} static DVECTOR const &getPlayerSpawnPos() {return s_playerSpawnPos;} diff --git a/source/platform/pbaloon.cpp b/source/platform/pbaloon.cpp index 2c635a14d..d6d7b30b3 100644 --- a/source/platform/pbaloon.cpp +++ b/source/platform/pbaloon.cpp @@ -69,7 +69,7 @@ void CBridgeBalloon::shutdown() int CBridgeBalloon::checkCollisionAgainst(CThing *_thisThing, int _frames) { - DVECTOR projectilePos = _thisThing->getPos(); + DVECTOR const &projectilePos = _thisThing->getPos(); s32 xDist = projectilePos.vx - Pos.vx; s32 yDist = projectilePos.vy - Pos.vy; @@ -284,15 +284,15 @@ int CNpcBalloonBridgePlatform::checkCollisionAgainst(CThing *_thisThing, int _fr thisRect = getCollisionArea(); thatRect = _thisThing->getCollisionArea(); - DVECTOR posDelta = getPosDelta(); + DVECTOR const &thisPosDelta = getPosDelta(); + int ThisAbsY=abs(thisPosDelta.vy)>>1; + thisRect.y1 -= ThisAbsY; + thisRect.y2 += ThisAbsY; - thisRect.y1 -= abs( posDelta.vy ) >> 1; - thisRect.y2 += abs( posDelta.vy ) >> 1; - - posDelta = _thisThing->getPosDelta(); - - thatRect.y1 -= abs( posDelta.vy ) >> 1; - thatRect.y2 += abs( posDelta.vy ) >> 1; + DVECTOR const &ThatPosDelta = _thisThing->getPosDelta(); + int ThatAbsY=abs(ThatPosDelta.vy)>>1; + thatRect.y1 -= ThatAbsY; + thatRect.y2 += ThatAbsY; if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) diff --git a/source/platform/pbaloon.h b/source/platform/pbaloon.h index 781fe6a45..f66996bbc 100644 --- a/source/platform/pbaloon.h +++ b/source/platform/pbaloon.h @@ -21,7 +21,7 @@ class CBridgeBalloon { public: - void setPos( DVECTOR newPos ) {Pos = newPos;} + void setPos( DVECTOR const &newPos ) {Pos = newPos;} void render(); void init(); void shutdown(); diff --git a/source/platform/pbob.cpp b/source/platform/pbob.cpp index 0bdd33b14..7df08b377 100644 --- a/source/platform/pbob.cpp +++ b/source/platform/pbob.cpp @@ -36,7 +36,7 @@ void CNpcBobbingPlatform::processMovement( int _frames ) if ( m_contact ) { CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); int height = player->getHeightFromGroundNoPlatform( playerPos.vx, playerPos.vy ); diff --git a/source/platform/pbounce.cpp b/source/platform/pbounce.cpp index 69f624df7..a56d474ff 100644 --- a/source/platform/pbounce.cpp +++ b/source/platform/pbounce.cpp @@ -145,15 +145,15 @@ void CNpcBouncePlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); diff --git a/source/platform/pbubble.cpp b/source/platform/pbubble.cpp index 4208e564c..a8df5aa40 100644 --- a/source/platform/pbubble.cpp +++ b/source/platform/pbubble.cpp @@ -99,15 +99,15 @@ int CNpcBubblePlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) thisRect = getCollisionArea(); thatRect = _thisThing->getCollisionArea(); - DVECTOR posDelta = getPosDelta(); + DVECTOR const &thisPosDelta = getPosDelta(); + int ThisAbsY=abs(thisPosDelta.vy)>>1; + thisRect.y1 -= ThisAbsY; + thisRect.y2 += ThisAbsY; - thisRect.y1 -= abs( posDelta.vy ) >> 1; - thisRect.y2 += abs( posDelta.vy ) >> 1; - - posDelta = _thisThing->getPosDelta(); - - thatRect.y1 -= abs( posDelta.vy ) >> 1; - thatRect.y2 += abs( posDelta.vy ) >> 1; + DVECTOR const &ThatPosDelta = _thisThing->getPosDelta(); + int ThatAbsY=abs(ThatPosDelta.vy)>>1; + thatRect.y1 -= ThatAbsY; + thatRect.y2 += ThatAbsY; if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) diff --git a/source/platform/pbubtube.cpp b/source/platform/pbubtube.cpp index df1948c77..65e39cca9 100644 --- a/source/platform/pbubtube.cpp +++ b/source/platform/pbubtube.cpp @@ -154,15 +154,15 @@ void CNpcBubbleTubePlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); diff --git a/source/platform/pbwheel.cpp b/source/platform/pbwheel.cpp index ed53db808..ea1c27d4a 100644 --- a/source/platform/pbwheel.cpp +++ b/source/platform/pbwheel.cpp @@ -102,7 +102,7 @@ int CNpcBigWheelPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int off { DVECTOR top; - CRECT collisionArea = getCollisionArea(); + CRECT const &collisionArea = getCollisionArea(); top.vy = offsetY + collisionArea.y1; diff --git a/source/platform/pcart.cpp b/source/platform/pcart.cpp index d80cf4aeb..61d39bb76 100644 --- a/source/platform/pcart.cpp +++ b/source/platform/pcart.cpp @@ -75,7 +75,7 @@ void CNpcCartPlatform::processMovement( int _frames ) CPlayer *player = GameScene.getPlayer(); DVECTOR newPos = Pos; - CRECT collisionArea=getCollisionArea(); + CRECT const &collisionArea=getCollisionArea(); newPos.vy = collisionArea.y1; player->setPos( newPos ); @@ -98,7 +98,7 @@ void CNpcCartPlatform::processMovement( int _frames ) Pos.vy += moveY; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); s32 yPos = Pos.vy - offset.vy; @@ -365,15 +365,15 @@ void CNpcCartPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const & playerPos=player->getPos(); +CRECT const & playerCollisionArea = player->getCollisionArea(); +CRECT const & collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); diff --git a/source/platform/pclam.cpp b/source/platform/pclam.cpp index 66f82ecca..2580dfa64 100644 --- a/source/platform/pclam.cpp +++ b/source/platform/pclam.cpp @@ -52,15 +52,15 @@ void CNpcClamPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); diff --git a/source/platform/pconveyr.cpp b/source/platform/pconveyr.cpp index 842ce8b15..16362a271 100644 --- a/source/platform/pconveyr.cpp +++ b/source/platform/pconveyr.cpp @@ -120,7 +120,7 @@ void CNpcConveyorPlatform::processMovement( int _frames ) m_rotation += 64 * _frames; m_rotation &= 4095; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); Pos.vy += 3 * _frames; @@ -187,13 +187,13 @@ void CNpcConveyorPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -226,7 +226,7 @@ void CNpcConveyorPlatform::collidedWith( CThing *_thisThing ) { int distLeft, distRight; - DVECTOR playerCollisionSize = player->getCollisionSize(); + DVECTOR const &playerCollisionSize = player->getCollisionSize(); distLeft = collisionArea.x1 - playerPos.vx - ( playerCollisionSize.vx >> 1 ); distRight = collisionArea.x2 - playerPos.vx + ( playerCollisionSize.vx >> 1 ); diff --git a/source/platform/pdual.cpp b/source/platform/pdual.cpp index 424b7a111..7b0e6c11b 100644 --- a/source/platform/pdual.cpp +++ b/source/platform/pdual.cpp @@ -238,7 +238,7 @@ void CNpcDualPlatform::render() { int x1,y1,x2,y2; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( m_isActive ) { @@ -343,15 +343,15 @@ void CNpcDualPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -391,12 +391,12 @@ void CNpcDualPlatform::collidedWith( CThing *_thisThing ) case TYPE_NPC: { CNpcFriend *friendNpc; - DVECTOR friendPos; - CRECT collisionArea; +// DVECTOR friendPos; +// CRECT collisionArea; friendNpc = (CNpcFriend*) _thisThing; - friendPos = friendNpc->getPos(); - collisionArea=getCollisionArea(); +DVECTOR const &friendPos = friendNpc->getPos(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); diff --git a/source/platform/pfallnor.cpp b/source/platform/pfallnor.cpp index a62cbf827..943c9cb94 100644 --- a/source/platform/pfallnor.cpp +++ b/source/platform/pfallnor.cpp @@ -48,7 +48,7 @@ void CNpcFallingNoRespawnPlatform::processMovement( int _frames ) s32 distX, distY, heading; bool pathComplete; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( m_spinFinish ) { diff --git a/source/platform/pfblock.cpp b/source/platform/pfblock.cpp index 8c76218ad..a01a3d838 100644 --- a/source/platform/pfblock.cpp +++ b/source/platform/pfblock.cpp @@ -81,7 +81,7 @@ void CNpcFallingBlockPlatform::processMovement( int _frames ) } else { - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); s32 yPos = Pos.vy - offset.vy; @@ -106,15 +106,15 @@ void CNpcFallingBlockPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); diff --git a/source/platform/pgbubble.cpp b/source/platform/pgbubble.cpp index 8bb6a2376..ff648c81b 100644 --- a/source/platform/pgbubble.cpp +++ b/source/platform/pgbubble.cpp @@ -80,7 +80,7 @@ void CNpcGeyserBubblePlatform::processMovement( int _frames ) } } - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); s32 yPos = Pos.vy - offset.vy; diff --git a/source/platform/pghost.cpp b/source/platform/pghost.cpp index 02920180f..53cdb32ce 100644 --- a/source/platform/pghost.cpp +++ b/source/platform/pghost.cpp @@ -59,7 +59,7 @@ void CNpcGhostTrainPlatform::processMovement( int _frames ) CPlayer *player = GameScene.getPlayer(); DVECTOR newPos = Pos; - CRECT collisionArea=getCollisionArea(); + CRECT const &collisionArea=getCollisionArea(); newPos.vy = collisionArea.y1; player->setPos( newPos ); @@ -82,7 +82,7 @@ void CNpcGhostTrainPlatform::processMovement( int _frames ) Pos.vy += moveY; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); s32 yPos = Pos.vy - offset.vy; diff --git a/source/platform/pjellfsh.cpp b/source/platform/pjellfsh.cpp index 371884881..bd0bfa2d1 100644 --- a/source/platform/pjellfsh.cpp +++ b/source/platform/pjellfsh.cpp @@ -64,15 +64,15 @@ void CNpcJellyfishPlatform::collidedWith( CThing *_thisThing ) if ( m_detectCollision && m_isActive ) { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerArea=player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerArea=player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 height = getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy); diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index 14773ba84..df8601da9 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -689,8 +689,8 @@ void CNpcPlatform::reinit() void CNpcPlatform::calculateNonRotatedCollisionData() { - DVECTOR collisionSize = getCollisionSize(); - DVECTOR collisionOffset = getCollisionCentreOffset(); +DVECTOR const &collisionSize = getCollisionSize(); +DVECTOR const &collisionOffset = getCollisionCentreOffset(); m_nonRotatedCollisionArea.XMax = ( collisionSize.vx >> 1 ) + collisionOffset.vx; m_nonRotatedCollisionArea.XMin = -( collisionSize.vx >> 1 ) + collisionOffset.vx; @@ -859,9 +859,7 @@ void CNpcPlatform::setCollisionAngle(int newAngle) player=GameScene.getPlayer(); if(player->isOnPlatform()==this) { - DVECTOR playerPos; - - playerPos=player->getPos(); + DVECTOR const &playerPos=player->getPos(); DVECTOR shove; shove.vx = 0; @@ -955,7 +953,7 @@ void CNpcPlatform::processTilt( int _frames ) // user is touching platform, tilt accordingly CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); if ( playerPos.vx > Pos.vx + 10 ) { @@ -1057,14 +1055,14 @@ u8 CNpcPlatform::checkCollisionDelta( CThing *_thisThing, int threshold, CRECT c // check for case of "was not colliding previously because was above" + // "is not colliding now because is below" - DVECTOR otherPos = _thisThing->getPos(); + DVECTOR const &otherPos = _thisThing->getPos(); if ( getHeightFromPlatformAtPosition( otherPos.vx, otherPos.vy ) < 0 ) { // is currently below platform landing point - DVECTOR otherPosDelta = _thisThing->getPosDelta(); - DVECTOR posDelta = getPosDelta(); + DVECTOR const &otherPosDelta = _thisThing->getPosDelta(); + DVECTOR const &posDelta = getPosDelta(); if ( otherPosDelta.vy > 0 || posDelta.vy < 0 ) { @@ -1115,15 +1113,15 @@ void CNpcPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -1163,12 +1161,12 @@ void CNpcPlatform::collidedWith( CThing *_thisThing ) case TYPE_NPC: { CNpcFriend *friendNpc; - DVECTOR friendPos; - CRECT collisionArea; +// DVECTOR friendPos; +// CRECT collisionArea; friendNpc = (CNpcFriend*) _thisThing; - friendPos = friendNpc->getPos(); - collisionArea=getCollisionArea(); +DVECTOR const &friendPos = friendNpc->getPos(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -1259,15 +1257,15 @@ int CNpcPlatform::checkCollisionAgainst(CThing *_thisThing, int _frames) thisRect = getCollisionArea(); thatRect = _thisThing->getCollisionArea(); - DVECTOR posDelta = getPosDelta(); + DVECTOR const &thisPosDelta = getPosDelta(); + int ThisAbsY=abs(thisPosDelta.vy)>>1; + thisRect.y1 -= ThisAbsY; + thisRect.y2 += ThisAbsY; - thisRect.y1 -= abs( posDelta.vy ) >> 1; - thisRect.y2 += abs( posDelta.vy ) >> 1; - - posDelta = _thisThing->getPosDelta(); - - thatRect.y1 -= abs( posDelta.vy ) >> 1; - thatRect.y2 += abs( posDelta.vy ) >> 1; + DVECTOR const &ThatPosDelta = _thisThing->getPosDelta(); + int ThatAbsY=abs(ThatPosDelta.vy)>>1; + thatRect.y1 -= ThatAbsY; + thatRect.y2 += ThatAbsY; if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) @@ -1295,7 +1293,7 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, in DVECTOR top; int angle; - CRECT collisionArea = getCollisionArea(); + CRECT const &collisionArea = getCollisionArea(); top.vy = offsetY + collisionArea.y1; diff --git a/source/platform/plift.cpp b/source/platform/plift.cpp index 837b1ebbe..42a866073 100644 --- a/source/platform/plift.cpp +++ b/source/platform/plift.cpp @@ -165,15 +165,15 @@ void CNpcLiftPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -213,12 +213,12 @@ void CNpcLiftPlatform::collidedWith( CThing *_thisThing ) case TYPE_NPC: { CNpcFriend *friendNpc; - DVECTOR friendPos; - CRECT collisionArea; +// DVECTOR friendPos; +// CRECT collisionArea; friendNpc = (CNpcFriend*) _thisThing; - friendPos = friendNpc->getPos(); - collisionArea=getCollisionArea(); +DVECTOR const &friendPos = friendNpc->getPos(); +CRECT const &collisionArea=getCollisionArea(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); diff --git a/source/platform/ppendulm.cpp b/source/platform/ppendulm.cpp index 02f7d16c0..8fc433f18 100644 --- a/source/platform/ppendulm.cpp +++ b/source/platform/ppendulm.cpp @@ -136,7 +136,7 @@ void CNpcPendulumPlatform::render() int x1,y1,x2,y2; int x1Boundary,y1Boundary,x2Boundary,y2Boundary; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( m_isActive ) { diff --git a/source/platform/psbarrel.cpp b/source/platform/psbarrel.cpp index 28362910a..f282af131 100644 --- a/source/platform/psbarrel.cpp +++ b/source/platform/psbarrel.cpp @@ -56,7 +56,7 @@ void CNpcSteerableBarrelPlatform::processMovement( int _frames ) { player->setReverseCameraMovement(true); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); s32 playerMovement = player->getMovement(); @@ -203,7 +203,7 @@ void CNpcSteerableBarrelPlatform::render() if (canRender()) { DVECTOR &renderPos=getRenderPos(); - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); SVECTOR rotation; rotation.vx = 0; @@ -229,15 +229,15 @@ void CNpcSteerableBarrelPlatform::collidedWith( CThing *_thisThing ) case TYPE_PLAYER: { CPlayer *player; - DVECTOR playerPos; - CRECT collisionArea; - CRECT playerCollisionArea; +// DVECTOR playerPos; +// CRECT collisionArea; +// CRECT playerCollisionArea; // Only interested in SBs feet colliding with the box (pkg) player=(CPlayer*)_thisThing; - playerPos=player->getPos(); - playerCollisionArea = player->getCollisionArea(); - collisionArea=getCollisionArea(); +DVECTOR const &playerPos=player->getPos(); +CRECT const &playerCollisionArea = player->getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) diff --git a/source/platform/pseesaw.cpp b/source/platform/pseesaw.cpp index acf8178f4..9f1daf2c2 100644 --- a/source/platform/pseesaw.cpp +++ b/source/platform/pseesaw.cpp @@ -46,7 +46,7 @@ void CNpcSeesawPlatform::processMovement( int _frames ) CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); s32 distX = playerPos.vx - this->Pos.vx; diff --git a/source/platform/psoil.cpp b/source/platform/psoil.cpp index a49f35398..9bd04af7f 100644 --- a/source/platform/psoil.cpp +++ b/source/platform/psoil.cpp @@ -46,7 +46,7 @@ void CNpcSteerableOildrumPlatform::processMovement( int _frames ) { player->setReverseCameraMovement(true); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); s32 playerMovement = player->getMovement(); diff --git a/source/player/player.cpp b/source/player/player.cpp index dcc439a6e..a5c82ccf3 100644 --- a/source/player/player.cpp +++ b/source/player/player.cpp @@ -1526,7 +1526,7 @@ if(drawlastpos) Params: Returns: ---------------------------------------------------------------------- */ -void CPlayer::setRespawnPosAndRingTelephone(DVECTOR _respawn) +void CPlayer::setRespawnPosAndRingTelephone(DVECTOR const &_respawn) { if(m_respawnPos.vx!=_respawn.vx|| m_respawnPos.vy!=_respawn.vy) @@ -2395,7 +2395,7 @@ void CPlayer::justButtBouncedABadGuy() Params: Returns: ---------------------------------------------------------------------- */ -void CPlayer::shove( DVECTOR move ) +void CPlayer::shove( DVECTOR const &move ) { int colHeight; @@ -3026,10 +3026,10 @@ void CPlayer::setPlayerCollisionSize(int _x,int _y,int _w,int _h) } void CPlayer::getPlayerCollisionSize(int *_x,int *_y,int *_w,int *_h) { - DVECTOR offset,size; +// DVECTOR offset,size; - offset=getCollisionCentreOffset(); - size=getCollisionSize(); +DVECTOR const &offset=getCollisionCentreOffset(); +DVECTOR const &size=getCollisionSize(); *_x=offset.vx; *_y=offset.vy; diff --git a/source/player/player.h b/source/player/player.h index 558a501c7..14b1809cc 100644 --- a/source/player/player.h +++ b/source/player/player.h @@ -226,7 +226,7 @@ public: void detectHazardousSurface(); virtual void render(); virtual int dontKillDuringLevelRespawn() {return true;} - virtual void shove(DVECTOR move); + virtual void shove(DVECTOR const &move); void moveLeft(); // This is only for camera scroll right now void moveRight(); // " " " " " void fall(); // " " " " " @@ -236,12 +236,12 @@ public: int isTryingToConversateWithFriend() {return m_allowConversation;} - DVECTOR getCameraPos() {return m_cameraPos;} + DVECTOR const &getCameraPos() {return m_cameraPos;} void setCartCam(int _flag) {m_cartCamActive=_flag;} void setReverseCameraMovement(int _flag) {m_reverseCameraMovement=_flag;} void setCameraBox(CameraBox _cameraBox); - void setRespawnPos(DVECTOR _respawn) {m_respawnPos=_respawn;} - void setRespawnPosAndRingTelephone(DVECTOR _respawn); + void setRespawnPos(DVECTOR const &_respawn) {m_respawnPos=_respawn;} + void setRespawnPosAndRingTelephone(DVECTOR const &_respawn); // This isn't funny anymore.. :( int getHeightFromGround(int _x,int _y,int _maxHeight=32); @@ -285,7 +285,7 @@ private: public: - DVECTOR getPlayerPos() {return Pos;} + DVECTOR const &getPlayerPos() {return Pos;} void setPlayerPos(DVECTOR *_pos) {Pos=*_pos;} void ignoreNewlyPressedButtonsOnPadThisThink(); PLAYERINPUT getPadInputHeld() {return m_padInput;} diff --git a/source/player/pmcart.cpp b/source/player/pmcart.cpp index 7e77224e7..118ec3b04 100644 --- a/source/player/pmcart.cpp +++ b/source/player/pmcart.cpp @@ -80,8 +80,9 @@ void CPlayerModeCart::think() if ( platform ) { - newPos.vx = platform->getPos().vx; - newPos.vy = platform->getPos().vy; + newPos=platform->getPos(); +// newPos.vx = platform->getPos().vx; +// newPos.vy = platform->getPos().vy; int platformOffset = ( ( CNpcPlatform* ) platform )->getHeightFromPlatformAtPosition( newPos.vx, newPos.vy ); s16 angle = ( ( CNpcPlatform * ) platform )->getCollisionAngle(); diff --git a/source/player/pmcoral.cpp b/source/player/pmcoral.cpp index aa1454b38..0b77e6601 100644 --- a/source/player/pmcoral.cpp +++ b/source/player/pmcoral.cpp @@ -212,12 +212,12 @@ void CPlayerModeCoralBlower::think() else if(m_enemy==NULL) { // Search for an enemy.. - DVECTOR playerPos; +// DVECTOR playerPos; int playerFacing; CRECT suckRect; CThing *thing; - playerPos=m_player->getPos(); + DVECTOR const &playerPos=m_player->getPos(); playerFacing=m_player->getFacing(); suckRect.x1=playerPos.vx+(blowerCatchPos.vx*playerFacing)-(blowerCatchSize.vx/2); @@ -228,7 +228,7 @@ void CPlayerModeCoralBlower::think() #ifdef __USER_paul__ { CRECT area=suckRect; - DVECTOR ofs=CLevel::getCameraPos(); + DVECTOR const &ofs=CLevel::getCameraPos(); area.x1-=ofs.vx; area.y1-=ofs.vy; area.x2-=ofs.vx; @@ -352,11 +352,11 @@ void CPlayerModeCoralBlower::renderModeUi() { // Draw aiming cursor int facing,heading; - DVECTOR screenOfs,launchPos,targetPos; + DVECTOR launchPos,targetPos; facing=m_player->getFacing(); heading=((m_launchHeading+1024)*facing)&4095; - screenOfs=CLevel::getCameraPos(); + DVECTOR const &screenOfs=CLevel::getCameraPos(); launchPos=m_player->getPlayerPos(); launchPos.vx+=(blowerLaunchPoint.vx*facing)-screenOfs.vx; launchPos.vy+=blowerLaunchPoint.vy-screenOfs.vy; diff --git a/source/player/pmnet.cpp b/source/player/pmnet.cpp index 68b8e1e94..4d760f9c2 100644 --- a/source/player/pmnet.cpp +++ b/source/player/pmnet.cpp @@ -231,15 +231,15 @@ void CPlayerModeNet::think() case NET_STATE__CATCHING: { - DVECTOR catchPos; - DVECTOR playerPos; +// DVECTOR catchPos; +// DVECTOR playerPos; int playerFacing; CRECT netRect; CThing *thing; ASSERT(m_netFrame<(int)(sizeof(netCatchPos)/sizeof(DVECTOR))); - catchPos=netCatchPos[m_netFrame]; - playerPos=m_player->getPos(); + DVECTOR const &catchPos=netCatchPos[m_netFrame]; + DVECTOR const &playerPos=m_player->getPos(); playerFacing=m_player->getFacing(); netRect.x1=playerPos.vx+(catchPos.vx*playerFacing)-(netCatchSize.vx/2); diff --git a/source/player/pmodes.cpp b/source/player/pmodes.cpp index faca4f83d..9ef66297e 100644 --- a/source/player/pmodes.cpp +++ b/source/player/pmodes.cpp @@ -199,7 +199,7 @@ int CPlayerMode::getPadInputDown() {return m_player->getPadInputDown();} ---------------------------------------------------------------------- */ int CPlayerMode::getHeightFromGound() { - DVECTOR pos=getPlayerPos(); + DVECTOR const &pos=getPlayerPos(); return m_player->getHeightFromGround(pos.vx,pos.vy); } @@ -219,7 +219,7 @@ void CPlayerMode::inSoakUpState() {m_player->inSoakUpState();} Params: Returns: ---------------------------------------------------------------------- */ -DVECTOR CPlayerMode::getPlayerPos() {return m_player->getPlayerPos();} +DVECTOR const &CPlayerMode::getPlayerPos() {return m_player->getPlayerPos();} void CPlayerMode::setPlayerPos(DVECTOR *_pos) {m_player->setPlayerPos(_pos);} /*---------------------------------------------------------------------- @@ -350,11 +350,9 @@ void CPlayerModeBase::thinkVerticalMovement() { if(m_player->moveVertical(m_player->getMoveVelocity()->vy>>VELOCITY_SHIFT)) { - DVECTOR pos; - if(m_currentState!=STATE_CELEBRATE) playerHasHitGround(); - pos=m_player->getPlayerPos(); + DVECTOR const &pos=m_player->getPlayerPos(); if(m_player->getHeightFromGround(pos.vx,pos.vy,5)==0&& (CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_SOAKUP) { @@ -378,8 +376,8 @@ void CPlayerModeBase::thinkVerticalMovement() m_currentState!=STATE_JUMPBACK&&m_currentState!=STATE_BUTTBOUNCEUP&& m_currentState!=STATE_FLOAT&&m_currentState!=STATE_CELEBRATE) { - DVECTOR pos; - pos=m_player->getPlayerPos(); + DVECTOR const &pos=m_player->getPlayerPos(); + if(m_player->getHeightFromGround(pos.vx,pos.vy,1)!=0 #ifdef SHITE_COLLISION && @@ -565,10 +563,9 @@ int cheight=15; int CPlayerModeBase::isOnEdge() { CLayerCollision *collision=CGameScene::getCollision(); - DVECTOR pos; int ret; - pos=m_player->getPlayerPos(); + DVECTOR const &pos=m_player->getPlayerPos(); ret=0; if(m_player->getHeightFromGround(pos.vx-csize,pos.vy,cheight+1)>cheight) { @@ -589,8 +586,7 @@ int CPlayerModeBase::isOnEdge() ---------------------------------------------------------------------- */ int CPlayerModeBase::canMoveLeft() { - DVECTOR pos; - pos=m_player->getPlayerPos(); + DVECTOR const &pos=m_player->getPlayerPos(); #ifdef SHITE_COLLISION return m_player->getHeightFromGround(pos.vx-checkx,pos.vy,checkdist)>-checkycanmove?true:false; #else @@ -601,8 +597,7 @@ int CPlayerModeBase::canMoveLeft() int CPlayerModeBase::canMoveRight() { - DVECTOR pos; - pos=m_player->getPlayerPos(); + DVECTOR const &pos=m_player->getPlayerPos(); #ifdef SHITE_COLLISION return m_player->getHeightFromGround(pos.vx+checkx,pos.vy,checkdist)>-checkycanmove?true:false; #else diff --git a/source/player/pmodes.h b/source/player/pmodes.h index 117ac70ce..9bbe3a991 100644 --- a/source/player/pmodes.h +++ b/source/player/pmodes.h @@ -109,7 +109,7 @@ public: public: - DVECTOR getPlayerPos(); // Public so that the states can get the position for bubicle spawners + DVECTOR const &getPlayerPos(); // Public so that the states can get the position for bubicle spawners protected: void setPlayerPos(DVECTOR *_pos); // Private so that they cannot directly alter it diff --git a/source/player/psbutt.cpp b/source/player/psbutt.cpp index 0888ef1c4..8158aa0b0 100644 --- a/source/player/psbutt.cpp +++ b/source/player/psbutt.cpp @@ -174,9 +174,8 @@ void CPlayerStateButtBounceLand::enter(CPlayerModeBase *_playerMode) m_bounceOffFloor=false; if(_playerMode->getIsInWater()) { - DVECTOR pos; + DVECTOR const &pos=_playerMode->getPlayerPos(); - pos=_playerMode->getPlayerPos(); if((CGameScene::getCollision()->getCollisionBlock(pos.vx,pos.vy)&COLLISION_TYPE_MASK)==COLLISION_TYPE_FLAG_DESTRUCTABLE_WALL) { CLevel &level=GameScene.GetLevel(); @@ -223,8 +222,7 @@ void CPlayerStateButtBounceUp::enter(CPlayerModeBase *_playerMode) { if(_playerMode->getIsInWater()) { - DVECTOR pos; - pos=_playerMode->getPlayerPos(); + DVECTOR const &pos=_playerMode->getPlayerPos(); CGameBubicleFactory::spawnBubicles(pos.vx-20,pos.vy,40,10,CGameBubicleFactory::TYPE_MEDIUM); CPadVibrationManager::setVibration(0,CPadVibrationManager::VIBE_MEDIUM); CGameScene::setCameraShake(0,8); diff --git a/source/player/psduck.cpp b/source/player/psduck.cpp index f47e18a0d..7a2b6bc4e 100644 --- a/source/player/psduck.cpp +++ b/source/player/psduck.cpp @@ -90,8 +90,7 @@ void CPlayerStateSoakUp::think(CPlayerModeBase *_playerMode) { if(m_breatheDelayFrames==0) { - DVECTOR pos; - pos=_playerMode->getPlayerPos(); + DVECTOR const & pos=_playerMode->getPlayerPos(); CGameBubicleFactory::spawnBubicles(pos.vx+BUBBLE_XOFF,pos.vy+BUBBLE_YOFF,BUBBLE_W,BUBBLE_H,CGameBubicleFactory::TYPE_SPONGEBOBSOAKUP); m_breatheDelayFrames=0; } diff --git a/source/projectl/prnpc.cpp b/source/projectl/prnpc.cpp index 35332ed27..1af40fafd 100644 --- a/source/projectl/prnpc.cpp +++ b/source/projectl/prnpc.cpp @@ -43,7 +43,7 @@ void CEnemyAsProjectile::render() // Render DVECTOR renderPos; - DVECTOR offset = CLevel::getCameraPos(); + DVECTOR const &offset = CLevel::getCameraPos(); renderPos.vx = Pos.vx - offset.vx; renderPos.vy = Pos.vy - offset.vy; diff --git a/source/projectl/prnpcspr.cpp b/source/projectl/prnpcspr.cpp index 874cd95f9..8de09afa9 100644 --- a/source/projectl/prnpcspr.cpp +++ b/source/projectl/prnpcspr.cpp @@ -75,14 +75,13 @@ void CEnemyAsSpriteProjectile::setRGB( int R, int G, int B ) void CEnemyAsSpriteProjectile::render() { sFrameHdr *frameHdr; - DVECTOR offset; int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth( m_spriteFrame ); int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight( m_spriteFrame ); - offset = getScreenOffset(); + DVECTOR const &offset = CLevel::getCameraPos(); x = Pos.vx - offset.vx; y = Pos.vy - offset.vy; diff --git a/source/projectl/projectl.cpp b/source/projectl/projectl.cpp index 7e732adb6..2845156c7 100644 --- a/source/projectl/projectl.cpp +++ b/source/projectl/projectl.cpp @@ -259,13 +259,6 @@ void CProjectile::setState( PROJECTILE_STATE newState ) //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CProjectile::setPosition( DVECTOR newPos ) -{ - Pos = newPos; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CProjectile::setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType ) { m_lifetimeType = lifeType; @@ -317,7 +310,7 @@ void CProjectile::think(int _frames) default: { CPlayer *player = GameScene.getPlayer(); - DVECTOR playerPos = player->getPos(); + DVECTOR const &playerPos = player->getPos(); if ( processTargetSeek( _frames, playerPos ) ) { @@ -424,14 +417,14 @@ void CProjectile::render() CEnemyProjectileThing::render(); sFrameHdr *frameHdr; - DVECTOR offset; + int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); int spriteWidth = CGameScene::getSpriteBank()->getFrameWidth( m_spriteFrame ); int spriteHeight = CGameScene::getSpriteBank()->getFrameHeight( m_spriteFrame ); - offset = getScreenOffset(); + DVECTOR const &offset = CLevel::getCameraPos(); x = Pos.vx - offset.vx /*+ ( scrnWidth >> 1 ) - ( spriteWidth >> 1 )*/; y = Pos.vy - offset.vy /*+ ( scrnHeight >> 1 ) - ( spriteHeight >> 1 )*/; @@ -450,13 +443,6 @@ void CProjectile::render() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -DVECTOR CProjectile::getScreenOffset() -{ - return CLevel::getCameraPos(); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CProjectile::processEvent( GAME_EVENT evt, CThing *sourceThing ) { } @@ -597,13 +583,6 @@ CPlayerProjectile::PLAYER_PROJECTILE_MOVEMENT_TYPE CPlayerProjectile::getMovemen //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -void CPlayerProjectile::setPosition( DVECTOR newPos ) -{ - Pos = newPos; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CPlayerProjectile::setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType ) { m_lifetimeType = lifeType; @@ -733,12 +712,11 @@ void CPlayerProjectile::render() { CPlayerProjectileThing::render(); - DVECTOR offset; int x,y; int scrnWidth = VidGetScrW(); int scrnHeight = VidGetScrH(); - offset = getScreenOffset(); + DVECTOR const &offset = CLevel::getCameraPos(); if ( m_hitTarget ) { @@ -776,13 +754,6 @@ void CPlayerProjectile::render() //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -DVECTOR CPlayerProjectile::getScreenOffset() -{ - return CLevel::getCameraPos(); -} - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - void CPlayerProjectile::processEvent( GAME_EVENT evt, CThing *sourceThing ) { } diff --git a/source/projectl/projectl.h b/source/projectl/projectl.h index 71025fed4..64e524958 100644 --- a/source/projectl/projectl.h +++ b/source/projectl/projectl.h @@ -61,7 +61,7 @@ public: PROJECTILE_MOVEMENT_TYPE getMovementType(); void setState( PROJECTILE_STATE newState ); void setLifeTime( PROJECTILE_LIFETIME_TYPE lifeType ); - void setPosition( DVECTOR newPos ); + void setPosition( DVECTOR const &newPos ) {Pos = newPos;} void setHeading( s16 newHeading ) {m_heading = newHeading;} void setOt( u8 newOt ) {m_ot=newOt;} void setGraphic( int frame ); @@ -71,7 +71,6 @@ public: void setShock() {m_shock = true;} protected: - DVECTOR getScreenOffset(); bool processTargetSeek( int _frames, DVECTOR targetPos ); void collidedWith( CThing *_thisThing ); @@ -127,12 +126,11 @@ public: void setMovementType( PLAYER_PROJECTILE_MOVEMENT_TYPE moveType ); PLAYER_PROJECTILE_MOVEMENT_TYPE getMovementType(); void setLifeTime( PLAYER_PROJECTILE_LIFETIME_TYPE lifeType ); - void setPosition( DVECTOR newPos ); + void setPosition( DVECTOR const &newPos ) {Pos = newPos;} void setRGB( u32 new_RGB ); protected: - DVECTOR getScreenOffset(); void collidedWith( CThing *_thisThing ); DVECTOR m_initPos; diff --git a/source/thing/thing.cpp b/source/thing/thing.cpp index b802913da..e6e69f624 100644 --- a/source/thing/thing.cpp +++ b/source/thing/thing.cpp @@ -1345,28 +1345,6 @@ void CThing::updateCollisionArea() m_collisionArea.y2=m_collisionArea.y1+m_collisionSize.vy; } -/*---------------------------------------------------------------------- - Function: - Purpose: - Params: - Returns: - ---------------------------------------------------------------------- */ -/* -s32 CThing::getNewYPos(CThing *_thisThing) -{ - CRECT thisRect; - thisRect = getCollisionArea(); - - if ( thisRect.y1 < thisRect.y2 ) - { - return( thisRect.y1 ); - } - else - { - return( thisRect.y2 ); - } -} -*/ /*---------------------------------------------------------------------- Function: Purpose: @@ -1375,23 +1353,22 @@ s32 CThing::getNewYPos(CThing *_thisThing) ---------------------------------------------------------------------- */ int CThing::checkCollisionAgainst(CThing *_thisThing, int _frames) { - DVECTOR pos,thisThingPos; +// DVECTOR pos,thisThingPos; int radius; int collided; - pos=getCollisionCentre(); - thisThingPos=_thisThing->getCollisionCentre(); +DVECTOR const &pos=getCollisionCentre(); +DVECTOR const &thisThingPos=_thisThing->getCollisionCentre(); radius=getCollisionRadius()+_thisThing->getCollisionRadius(); collided=false; if(abs(pos.vx-thisThingPos.vx)getCollisionArea(); +CRECT const &thisRect=getCollisionArea(); +CRECT const &thatRect=_thisThing->getCollisionArea(); if(((thisRect.x1>=thatRect.x1&&thisRect.x1<=thatRect.x2)||(thisRect.x2>=thatRect.x1&&thisRect.x2<=thatRect.x2)||(thisRect.x1<=thatRect.x1&&thisRect.x2>=thatRect.x2))&& ((thisRect.y1>=thatRect.y1&&thisRect.y1<=thatRect.y2)||(thisRect.y2>=thatRect.y1&&thisRect.y2<=thatRect.y2)||(thisRect.y1<=thatRect.y1&&thisRect.y2>=thatRect.y2))) @@ -1411,10 +1388,10 @@ int CThing::checkCollisionAgainst(CThing *_thisThing, int _frames) ---------------------------------------------------------------------- */ int CThing::checkCollisionAgainstArea(CRECT *_rect) { - CRECT thisRect; +// CRECT thisRect; int ret; - thisRect=getCollisionArea(); +CRECT const &thisRect=getCollisionArea(); ret=false; if(((thisRect.x1>=_rect->x1&&thisRect.x1<=_rect->x2)||(thisRect.x2>=_rect->x1&&thisRect.x2<=_rect->x2)||(thisRect.x1<=_rect->x1&&thisRect.x2>=_rect->x2))&& diff --git a/source/thing/thing.h b/source/thing/thing.h index 1cbce7772..52bffcf8e 100644 --- a/source/thing/thing.h +++ b/source/thing/thing.h @@ -127,7 +127,7 @@ public: } virtual ~CThing() {;} -/*virtual*/ void initDef() + void initDef() { Pos.vx=0; Pos.vy=0; PosDelta=Pos; @@ -138,13 +138,12 @@ virtual ~CThing() {;} virtual TYPE getThingType()=0; -/*virtual */void setThingSubType(int T) {m_SubType=T;} -/*virtual */int getThingSubType() {return(m_SubType);} + void setThingSubType(int T) {m_SubType=T;} + int getThingSubType() {return(m_SubType);} + +virtual void init(); +virtual void shutdown(); -//virtual void create() {;} // Once only init (for mem alloc) -virtual void init(); // re-usable init -virtual void shutdown(); // re-usable shutdown -//virtual void destroy() {;} // memory clean up when totally killing the poor things virtual void think(int _frames); virtual void render(); @@ -161,8 +160,8 @@ virtual int dontKillDuringLevelRespawn() {return false;} int getNumChildren() {return( m_numChildren );} DVECTOR const &getPos() {return Pos;} - void setPos(DVECTOR newPos) {Pos=newPos;} - DVECTOR getPosDelta() {return PosDelta;} + void setPos(DVECTOR const &newPos) {Pos=newPos;} + DVECTOR const &getPosDelta() {return PosDelta;} CThing *getParent() {return ParentThing;} CThing *getNext() {return NextThing;} @@ -190,13 +189,12 @@ virtual CRECT const *getRenderBBox() {return &m_collisionArea;} virtual CRECT const *getThinkBBox() {return &m_collisionArea;} virtual bool alwaysThink() {return(false);} virtual void leftThinkZone(int _frames) {} -//virtual void enterThinkZone(int _frames) {} void ShowBBox(); DVECTOR const &getCollisionCentre() {return m_collisionCentre;} DVECTOR const &getCollisionCentreOffset() {return m_collisionCentreOffset;} int getCollisionRadius() {return m_collisionRadius;} -/*virtual */CRECT const &getCollisionArea() {return m_collisionArea;} + CRECT const &getCollisionArea() {return m_collisionArea;} DVECTOR const &getCollisionSize() {return m_collisionSize;} virtual int canCollide() {return true;} @@ -204,7 +202,6 @@ virtual int checkCollisionAgainst(CThing *_thisThing, int _frames); int checkCollisionAgainstArea(CRECT *_rect); void updateCollisionArea(); virtual void collidedWith(CThing *_thisThing) {;} -//virtual s32 getNewYPos( CThing *_thisThing ); public: // Thing states @@ -222,9 +219,9 @@ protected: u8 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;} + void setCollisionSize(int _w,int _h); + void setCollisionCentreOffset(int _x,int _y) {m_collisionCentreOffset.vx=_x;m_collisionCentreOffset.vy=_y;} + void setCollisionCentreOffset(DVECTOR const &xy) {m_collisionCentreOffset=xy;} private: DVECTOR m_collisionSize; @@ -307,7 +304,16 @@ public: virtual TYPE getThingType() {return TYPE_FX;} }; +inline bool CheckRect2Rect(CRECT const &Rect0,CRECT const &Rect1) +{ + if (Rect0.x2Rect1.x2) return(false); + if (Rect0.y2Rect1.y2) return(false); + return(true); +} + #endif /* __THING_THING_H__ */ + /*=========================================================================== + end */ diff --git a/source/triggers/trestart.cpp b/source/triggers/trestart.cpp index 1742251af..2c4db8061 100644 --- a/source/triggers/trestart.cpp +++ b/source/triggers/trestart.cpp @@ -54,14 +54,14 @@ ---------------------------------------------------------------------- */ void CRestartPointTrigger::collidedWith(CThing *_thisThing) { - CRECT collisionArea; +// CRECT collisionArea; DVECTOR respawnPos; switch( _thisThing->getThingType() ) { case TYPE_PLAYER: { - collisionArea=getCollisionArea(); +CRECT const &collisionArea=getCollisionArea(); respawnPos.vx=collisionArea.x1+((collisionArea.x2-collisionArea.x1)/2); respawnPos.vy=collisionArea.y2; ((CPlayer*)_thisThing)->setRespawnPos(respawnPos);