summaryrefslogtreecommitdiffstats
path: root/src/Blocks/BlockRail.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-12-05 16:59:11 +0100
committerMattes D <github@xoft.cz>2014-12-05 16:59:11 +0100
commite2a04f580a0813206f527a61244cb3382248fd12 (patch)
tree39f0a5026d619e89ce353cf8addf18e4a696b067 /src/Blocks/BlockRail.h
parentCheckBasicStyle: Added a check for parentheses around comparisons. (diff)
downloadcuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.gz
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.bz2
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.lz
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.xz
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.tar.zst
cuberite-e2a04f580a0813206f527a61244cb3382248fd12.zip
Diffstat (limited to 'src/Blocks/BlockRail.h')
-rw-r--r--src/Blocks/BlockRail.h88
1 files changed, 72 insertions, 16 deletions
diff --git a/src/Blocks/BlockRail.h b/src/Blocks/BlockRail.h
index 87ce069ab..21a34d8ce 100644
--- a/src/Blocks/BlockRail.h
+++ b/src/Blocks/BlockRail.h
@@ -151,13 +151,21 @@ public:
Neighbors[6] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_NORTH, E_PURE_NONE));
Neighbors[7] = (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY + 1, a_BlockZ, BLOCK_FACE_SOUTH, E_PURE_NONE));
if (IsUnstable(a_ChunkInterface, a_BlockX + 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_EAST))
+ {
Neighbors[0] = true;
+ }
if (IsUnstable(a_ChunkInterface, a_BlockX - 1, a_BlockY - 1, a_BlockZ) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_WEST))
+ {
Neighbors[1] = true;
+ }
if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ - 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_NORTH))
+ {
Neighbors[2] = true;
+ }
if (IsUnstable(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ + 1) || !IsNotConnected(a_ChunkInterface, a_BlockX, a_BlockY - 1, a_BlockZ, BLOCK_FACE_SOUTH))
+ {
Neighbors[3] = true;
+ }
for (int i = 0; i < 8; i++)
{
if (Neighbors[i])
@@ -167,12 +175,30 @@ public:
}
if (RailsCnt == 1)
{
- if (Neighbors[7]) return E_META_RAIL_ASCEND_ZP;
- else if (Neighbors[6]) return E_META_RAIL_ASCEND_ZM;
- else if (Neighbors[5]) return E_META_RAIL_ASCEND_XM;
- else if (Neighbors[4]) return E_META_RAIL_ASCEND_XP;
- else if (Neighbors[0] || Neighbors[1]) return E_META_RAIL_XM_XP;
- else if (Neighbors[2] || Neighbors[3]) return E_META_RAIL_ZM_ZP;
+ if (Neighbors[7])
+ {
+ return E_META_RAIL_ASCEND_ZP;
+ }
+ else if (Neighbors[6])
+ {
+ return E_META_RAIL_ASCEND_ZM;
+ }
+ else if (Neighbors[5])
+ {
+ return E_META_RAIL_ASCEND_XM;
+ }
+ else if (Neighbors[4])
+ {
+ return E_META_RAIL_ASCEND_XP;
+ }
+ else if (Neighbors[0] || Neighbors[1])
+ {
+ return E_META_RAIL_XM_XP;
+ }
+ else if (Neighbors[2] || Neighbors[3])
+ {
+ return E_META_RAIL_ZM_ZP;
+ }
ASSERT(!"Weird neighbor count");
return Meta;
}
@@ -185,16 +211,46 @@ public:
}
if (RailsCnt > 1)
{
- if (Neighbors[3] && Neighbors[0] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZP_XP;
- else if (Neighbors[3] && Neighbors[1] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZP_XM;
- else if (Neighbors[2] && Neighbors[0] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZM_XP;
- else if (Neighbors[2] && Neighbors[1] && CanThisRailCurve()) return E_META_RAIL_CURVED_ZM_XM;
- else if (Neighbors[7] && Neighbors[2]) return E_META_RAIL_ASCEND_ZP;
- else if (Neighbors[3] && Neighbors[6]) return E_META_RAIL_ASCEND_ZM;
- else if (Neighbors[5] && Neighbors[0]) return E_META_RAIL_ASCEND_XM;
- else if (Neighbors[4] && Neighbors[1]) return E_META_RAIL_ASCEND_XP;
- else if (Neighbors[0] && Neighbors[1]) return E_META_RAIL_XM_XP;
- else if (Neighbors[2] && Neighbors[3]) return E_META_RAIL_ZM_ZP;
+ if (Neighbors[3] && Neighbors[0] && CanThisRailCurve())
+ {
+ return E_META_RAIL_CURVED_ZP_XP;
+ }
+ else if (Neighbors[3] && Neighbors[1] && CanThisRailCurve())
+ {
+ return E_META_RAIL_CURVED_ZP_XM;
+ }
+ else if (Neighbors[2] && Neighbors[0] && CanThisRailCurve())
+ {
+ return E_META_RAIL_CURVED_ZM_XP;
+ }
+ else if (Neighbors[2] && Neighbors[1] && CanThisRailCurve())
+ {
+ return E_META_RAIL_CURVED_ZM_XM;
+ }
+ else if (Neighbors[7] && Neighbors[2])
+ {
+ return E_META_RAIL_ASCEND_ZP;
+ }
+ else if (Neighbors[3] && Neighbors[6])
+ {
+ return E_META_RAIL_ASCEND_ZM;
+ }
+ else if (Neighbors[5] && Neighbors[0])
+ {
+ return E_META_RAIL_ASCEND_XM;
+ }
+ else if (Neighbors[4] && Neighbors[1])
+ {
+ return E_META_RAIL_ASCEND_XP;
+ }
+ else if (Neighbors[0] && Neighbors[1])
+ {
+ return E_META_RAIL_XM_XP;
+ }
+ else if (Neighbors[2] && Neighbors[3])
+ {
+ return E_META_RAIL_ZM_ZP;
+ }
if (CanThisRailCurve())
{