summaryrefslogtreecommitdiffstats
path: root/src/ChunkDef.h
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-03-10 21:18:53 +0100
committerTycho <work.tycho+git@gmail.com>2014-03-10 21:18:53 +0100
commit98e15a34a416c31d4689836f4f38161f1270513c (patch)
tree1ae50f2ff4748ac22c810f1f631002b223e02c62 /src/ChunkDef.h
parentFixed test asserts (diff)
downloadcuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.gz
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.bz2
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.lz
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.xz
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.tar.zst
cuberite-98e15a34a416c31d4689836f4f38161f1270513c.zip
Diffstat (limited to 'src/ChunkDef.h')
-rw-r--r--src/ChunkDef.h26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index a5059348c..fcda64f5c 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -124,9 +124,7 @@ public:
(z < Width) && (z > -1)
)
{
- return MakeIndexNoCheck(static_cast<unsigned int>(x),
- static_cast<unsigned int>(y),
- static_cast<unsigned int>(z));
+ return MakeIndexNoCheck(x, y, z);
}
LOGERROR("cChunkDef::MakeIndex(): coords out of range: {%d, %d, %d}; returning fake index 0", x, y, z);
ASSERT(!"cChunkDef::MakeIndex(): coords out of chunk range!");
@@ -134,13 +132,13 @@ public:
}
- inline static unsigned int MakeIndexNoCheck(unsigned int x, unsigned int y, unsigned int z)
+ inline static unsigned int MakeIndexNoCheck(int x, int y, int z)
{
#if AXIS_ORDER == AXIS_ORDER_XZY
// For some reason, NOT using the Horner schema is faster. Weird.
- return x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width); // 1.2 is XZY
+ return static_cast<unsigned int>(x + (z * cChunkDef::Width) + (y * cChunkDef::Width * cChunkDef::Width)); // 1.2 is XZY
#elif AXIS_ORDER == AXIS_ORDER_YZX
- return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 is YZX
+ return static_cast<unsigned int>(y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width)); // 1.1 is YZX
#endif
}
@@ -168,9 +166,7 @@ public:
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Y >= 0) && (a_Y < Height));
ASSERT((a_Z >= 0) && (a_Z < Width));
- a_BlockTypes[MakeIndexNoCheck(static_cast<unsigned int>(a_X),
- static_cast<unsigned int>(a_Y),
- static_cast<unsigned int>(a_Z))] = a_Type;
+ a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)] = a_Type;
}
@@ -186,9 +182,7 @@ public:
ASSERT((a_X >= 0) && (a_X < Width));
ASSERT((a_Y >= 0) && (a_Y < Height));
ASSERT((a_Z >= 0) && (a_Z < Width));
- return a_BlockTypes[MakeIndexNoCheck(static_cast<unsigned int>(a_X),
- static_cast<unsigned int>(a_Y),
- static_cast<unsigned int>(a_Z))];
+ return a_BlockTypes[MakeIndexNoCheck(a_X, a_Y, a_Z)];
}
@@ -246,9 +240,7 @@ public:
{
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
- unsigned int Index = MakeIndexNoCheck(static_cast<unsigned int>(x),
- static_cast<unsigned int>(y),
- static_cast<unsigned int>(z));
+ unsigned int Index = MakeIndexNoCheck(x, y, z);
return (a_Buffer[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
}
ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!");
@@ -282,9 +274,7 @@ public:
return;
}
- unsigned int Index = MakeIndexNoCheck(static_cast<unsigned int>(x),
- static_cast<unsigned int>(y),
- static_cast<unsigned int>(z));
+ unsigned int Index = MakeIndexNoCheck(x, y, z);
a_Buffer[Index / 2] = static_cast<NIBBLETYPE>(
(a_Buffer[Index / 2] & (0xf0 >> ((Index & 1) * 4))) | // The untouched nibble
((a_Nibble & 0x0f) << ((Index & 1) * 4)) // The nibble being set