summaryrefslogtreecommitdiffstats
path: root/src/Entities/Minecart.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entities/Minecart.cpp')
-rw-r--r--src/Entities/Minecart.cpp81
1 files changed, 41 insertions, 40 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index bc9e21d8e..5833cb4ae 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -13,6 +13,7 @@
#include "Player.h"
#include "../BoundingBox.h"
+#define NO_SPEED 0.0
#define MAX_SPEED 8
#define MAX_SPEED_NEGATIVE -MAX_SPEED
@@ -220,7 +221,7 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return;
- if (GetSpeedZ() != 0) // Don't do anything if cart is stationary
+ if (GetSpeedZ() != NO_SPEED) // Don't do anything if cart is stationary
{
if (GetSpeedZ() > 0)
{
@@ -239,13 +240,13 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
{
SetYaw(180);
SetPosY(floor(GetPosY()) + 0.55);
- SetSpeedY(0);
- SetSpeedZ(0);
+ SetSpeedY(NO_SPEED);
+ SetSpeedZ(NO_SPEED);
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return;
- if (GetSpeedX() != 0)
+ if (GetSpeedX() != NO_SPEED)
{
if (GetSpeedX() > 0)
{
@@ -305,9 +306,9 @@ void cMinecart::HandleRailPhysics(NIBBLETYPE a_RailMeta, float a_Dt)
case E_META_RAIL_ASCEND_XM: // ASCEND EAST
{
SetYaw(180);
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
- if (GetSpeedX() >= 0)
+ if (GetSpeedX() >= NO_SPEED)
{
if (GetSpeedX() <= MAX_SPEED)
{
@@ -424,9 +425,9 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return;
- if (GetSpeedZ() != 0)
+ if (GetSpeedZ() != NO_SPEED)
{
- if (GetSpeedZ() > 0)
+ if (GetSpeedZ() > NO_SPEED)
{
AddSpeedZ(AccelDecelSpeed);
}
@@ -441,15 +442,15 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
{
SetYaw(180);
SetPosY(floor(GetPosY()) + 0.55);
- SetSpeedY(0);
- SetSpeedZ(0);
+ SetSpeedY(NO_SPEED);
+ SetSpeedZ(NO_SPEED);
bool BlckCol = TestBlockCollision(a_RailMeta), EntCol = TestEntityCollision(a_RailMeta);
if (EntCol || BlckCol) return;
- if (GetSpeedX() != 0)
+ if (GetSpeedX() != NO_SPEED)
{
- if (GetSpeedX() > 0)
+ if (GetSpeedX() > NO_SPEED)
{
AddSpeedX(AccelDecelSpeed);
}
@@ -463,9 +464,9 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
case E_META_RAIL_ASCEND_XM: // ASCEND EAST
{
SetYaw(180);
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
- if (GetSpeedX() >= 0)
+ if (GetSpeedX() >= NO_SPEED)
{
if (GetSpeedX() <= MAX_SPEED)
{
@@ -483,9 +484,9 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
case E_META_RAIL_ASCEND_XP: // ASCEND WEST
{
SetYaw(180);
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
- if (GetSpeedX() > 0)
+ if (GetSpeedX() > NO_SPEED)
{
AddSpeedX(AccelDecelSpeed);
SetSpeedY(GetSpeedX());
@@ -503,9 +504,9 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
case E_META_RAIL_ASCEND_ZM: // ASCEND NORTH
{
SetYaw(270);
- SetSpeedX(0);
+ SetSpeedX(NO_SPEED);
- if (GetSpeedZ() >= 0)
+ if (GetSpeedZ() >= NO_SPEED)
{
if (GetSpeedZ() <= MAX_SPEED)
{
@@ -523,9 +524,9 @@ void cMinecart::HandlePoweredRailPhysics(NIBBLETYPE a_RailMeta)
case E_META_RAIL_ASCEND_ZP: // ASCEND SOUTH
{
SetYaw(270);
- SetSpeedX(0);
+ SetSpeedX(NO_SPEED);
- if (GetSpeedZ() > 0)
+ if (GetSpeedZ() > NO_SPEED)
{
AddSpeedZ(AccelDecelSpeed);
SetSpeedY(GetSpeedZ());
@@ -576,7 +577,7 @@ void cMinecart::SnapToRail(NIBBLETYPE a_RailMeta)
case E_META_RAIL_ASCEND_XP:
case E_META_RAIL_XM_XP:
{
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
SetPosZ(floor(GetPosZ()) + 0.5);
break;
}
@@ -584,7 +585,7 @@ void cMinecart::SnapToRail(NIBBLETYPE a_RailMeta)
case E_META_RAIL_ASCEND_ZP:
case E_META_RAIL_ZM_ZP:
{
- SetSpeedX(0);
+ SetSpeedX(NO_SPEED);
SetPosX(floor(GetPosX()) + 0.5);
break;
}
@@ -593,12 +594,12 @@ void cMinecart::SnapToRail(NIBBLETYPE a_RailMeta)
{
if (GetPosZ() > floor(GetPosZ()) + 0.5)
{
- if (GetSpeedZ() > 0)
+ if (GetSpeedZ() > NO_SPEED)
{
SetSpeedX(-GetSpeedZ() * 0.7);
}
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
SetPosZ(floor(GetPosZ()) + 0.5);
}
else if (GetPosX() > floor(GetPosX()) + 0.5)
@@ -608,82 +609,82 @@ void cMinecart::SnapToRail(NIBBLETYPE a_RailMeta)
SetSpeedZ(-GetSpeedX() * 0.7);
}
- SetSpeedX(0);
+ SetSpeedX(NO_SPEED);
SetPosX(floor(GetPosX()) + 0.5);
}
- SetSpeedY(0);
+ SetSpeedY(NO_SPEED);
break;
}
case E_META_RAIL_CURVED_ZM_XP:
{
if (GetPosZ() > floor(GetPosZ()) + 0.5)
{
- if (GetSpeedZ() > 0)
+ if (GetSpeedZ() > NO_SPEED)
{
SetSpeedX(GetSpeedZ() * 0.7);
}
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
SetPosZ(floor(GetPosZ()) + 0.5);
}
else if (GetPosX() < floor(GetPosX()) + 0.5)
{
- if (GetSpeedX() < 0)
+ if (GetSpeedX() < NO_SPEED)
{
SetSpeedZ(GetSpeedX() * 0.7);
}
- SetSpeedX(0);
+ SetSpeedX(NO_SPEED);
SetPosX(floor(GetPosX()) + 0.5);
}
- SetSpeedY(0);
+ SetSpeedY(NO_SPEED);
break;
}
case E_META_RAIL_CURVED_ZP_XM:
{
if (GetPosZ() < floor(GetPosZ()) + 0.5)
{
- if (GetSpeedZ() < 0)
+ if (GetSpeedZ() < NO_SPEED)
{
SetSpeedX(GetSpeedZ() * 0.7);
}
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
SetPosZ(floor(GetPosZ()) + 0.5);
}
else if (GetPosX() > floor(GetPosX()) + 0.5)
{
- if (GetSpeedX() > 0)
+ if (GetSpeedX() > NO_SPEED)
{
SetSpeedZ(GetSpeedX() * 0.7);
}
- SetSpeedX(0);
+ SetSpeedX(NO_SPEED);
SetPosX(floor(GetPosX()) + 0.5);
}
- SetSpeedY(0);
+ SetSpeedY(NO_SPEED);
break;
}
case E_META_RAIL_CURVED_ZP_XP:
{
if (GetPosZ() < floor(GetPosZ()) + 0.5)
{
- if (GetSpeedZ() < 0)
+ if (GetSpeedZ() < NO_SPEED)
{
SetSpeedX(-GetSpeedZ() * 0.7);
}
- SetSpeedZ(0);
+ SetSpeedZ(NO_SPEED);
SetPosZ(floor(GetPosZ()) + 0.5);
}
else if (GetPosX() < floor(GetPosX()) + 0.5)
{
- if (GetSpeedX() < 0)
+ if (GetSpeedX() < NO_SPEED)
{
SetSpeedZ(-GetSpeedX() * 0.7);
}
- SetSpeedX(0);
+ SetSpeedX(NO_SPEED);
SetPosX(floor(GetPosX()) + 0.5);
}
SetSpeedY(0);