diff --git a/source/platform/pbubtube.cpp b/source/platform/pbubtube.cpp index 960867440..df1948c77 100644 --- a/source/platform/pbubtube.cpp +++ b/source/platform/pbubtube.cpp @@ -156,10 +156,12 @@ void CNpcBubbleTubePlatform::collidedWith( CThing *_thisThing ) CPlayer *player; 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(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -169,7 +171,8 @@ void CNpcBubbleTubePlatform::collidedWith( CThing *_thisThing ) threshold = 16; } - if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) { if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) { diff --git a/source/platform/pcart.cpp b/source/platform/pcart.cpp index 6ca1a1815..e2f9eff64 100644 --- a/source/platform/pcart.cpp +++ b/source/platform/pcart.cpp @@ -360,10 +360,12 @@ void CNpcCartPlatform::collidedWith( CThing *_thisThing ) CPlayer *player; 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(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -373,7 +375,8 @@ void CNpcCartPlatform::collidedWith( CThing *_thisThing ) threshold = 16; } - if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) { if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) { diff --git a/source/platform/pdual.cpp b/source/platform/pdual.cpp index 69d086beb..424b7a111 100644 --- a/source/platform/pdual.cpp +++ b/source/platform/pdual.cpp @@ -345,10 +345,12 @@ void CNpcDualPlatform::collidedWith( CThing *_thisThing ) CPlayer *player; 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(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -358,7 +360,8 @@ void CNpcDualPlatform::collidedWith( CThing *_thisThing ) threshold = 16; } - if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) { if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) { diff --git a/source/platform/pfblock.cpp b/source/platform/pfblock.cpp index 7398d9a81..7a53fad2c 100644 --- a/source/platform/pfblock.cpp +++ b/source/platform/pfblock.cpp @@ -101,10 +101,12 @@ void CNpcFallingBlockPlatform::collidedWith( CThing *_thisThing ) CPlayer *player; 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(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -114,7 +116,8 @@ void CNpcFallingBlockPlatform::collidedWith( CThing *_thisThing ) threshold = 16; } - if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) { if ( m_isFalling ) { diff --git a/source/platform/pjellfsh.cpp b/source/platform/pjellfsh.cpp index 8114ab7a8..ea20ae2f8 100644 --- a/source/platform/pjellfsh.cpp +++ b/source/platform/pjellfsh.cpp @@ -75,7 +75,7 @@ void CNpcJellyfishPlatform::collidedWith( CThing *_thisThing ) s32 height = getHeightFromPlatformAtPosition(playerPos.vx,playerPos.vy); - if(playerPos.vx>=collisionArea.x1&&playerPos.vx<=collisionArea.x2&& + if(playerArea.x2>=collisionArea.x1&&playerArea.x1<=collisionArea.x2&& playerPos.vy>=collisionArea.y1&&playerPos.vy<=collisionArea.y2) //if(((playerArea.x1>=collisionArea.x1&&playerArea.x1<=collisionArea.x2)||(playerArea.x2>=collisionArea.x1&&playerArea.x2<=collisionArea.x2)||(playerArea.x1<=collisionArea.x1&&playerArea.x2>=collisionArea.x2))&& //((playerArea.y1>=thatRect.y1&&playerArea.y1<=thatRect.y2)||(playerArea.y2>=thatRect.y1&&playerArea.y2<=thatRect.y2)||(playerArea.y1<=thatRect.y1&&playerArea.y2>=thatRect.y2))) diff --git a/source/platform/platform.cpp b/source/platform/platform.cpp index e60e3bb4e..8fb0c88ae 100644 --- a/source/platform/platform.cpp +++ b/source/platform/platform.cpp @@ -1064,13 +1064,20 @@ u8 CNpcPlatform::checkCollisionDelta( CThing *_thisThing, int threshold, CRECT c s32 oldXPos = otherPos.vx - otherPosDelta.vx; s32 oldYPos = otherPos.vy - otherPosDelta.vy; + CRECT otherCollisionArea = _thisThing->getCollisionArea(); + otherCollisionArea.x1 -= otherPosDelta.vx; + otherCollisionArea.x2 -= otherPosDelta.vx; + otherCollisionArea.y1 -= otherPosDelta.vy; + otherCollisionArea.y2 -= otherPosDelta.vy; + collisionArea.x1 -= posDelta.vx; collisionArea.x2 -= posDelta.vx; collisionArea.y1 -= posDelta.vy; s32 oldCollisionY = collisionArea.y2; collisionArea.y2 -= posDelta.vy; - if ( oldXPos >= collisionArea.x1 && oldXPos <= collisionArea.x2 ) + //if ( oldXPos >= collisionArea.x1 && oldXPos <= collisionArea.x2 ) + if ( otherCollisionArea.x2 >= collisionArea.x1 && otherCollisionArea.x1 <= collisionArea.x2 ) { //if ( oldYPos < collisionArea.y1 + threshold ) //&& otherPos.vy > oldCollisionY ) if ( getHeightFromPlatformAtPosition( oldXPos, oldYPos, -posDelta.vx, -posDelta.vy ) > 0 ) @@ -1099,10 +1106,12 @@ void CNpcPlatform::collidedWith( CThing *_thisThing ) CPlayer *player; 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(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -1112,7 +1121,8 @@ void CNpcPlatform::collidedWith( CThing *_thisThing ) threshold = 16; } - if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) { if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) { @@ -1296,6 +1306,15 @@ int CNpcPlatform::getHeightFromPlatformAtPosition(int _x,int _y, int offsetX, in top.vx = offsetX + collisionArea.x2; } + if ( _x > collisionArea.x2 ) + { + _x = collisionArea.x2; + } + else if ( _x < collisionArea.x1 ) + { + _x = collisionArea.x1; + } + // Rotate backwards to find height at current position s16 cosVal = rcos( angle ); diff --git a/source/platform/plift.cpp b/source/platform/plift.cpp index 83cc355e8..837b1ebbe 100644 --- a/source/platform/plift.cpp +++ b/source/platform/plift.cpp @@ -167,10 +167,12 @@ void CNpcLiftPlatform::collidedWith( CThing *_thisThing ) CPlayer *player; 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(); s32 threshold = abs( collisionArea.y2 - collisionArea.y1 ); @@ -180,7 +182,8 @@ void CNpcLiftPlatform::collidedWith( CThing *_thisThing ) threshold = 16; } - if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) { if ( checkCollisionDelta( _thisThing, threshold, collisionArea ) ) { diff --git a/source/platform/psbarrel.cpp b/source/platform/psbarrel.cpp index eb4ae2d6e..651f985b6 100644 --- a/source/platform/psbarrel.cpp +++ b/source/platform/psbarrel.cpp @@ -229,13 +229,16 @@ void CNpcSteerableBarrelPlatform::collidedWith( CThing *_thisThing ) CPlayer *player; 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(); - if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + //if( playerPos.vx >= collisionArea.x1 && playerPos.vx <= collisionArea.x2 ) + if( playerCollisionArea.x2 >= collisionArea.x1 && playerCollisionArea.x1 <= collisionArea.x2 ) { if ( checkCollisionDelta( _thisThing, 0, collisionArea ) ) {