summaryrefslogtreecommitdiffstats
path: root/src/ChunkDef.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-04-30 15:23:46 +0200
committerGitHub <noreply@github.com>2021-04-30 15:23:46 +0200
commit9b97d63f8f939dbc431cc2dcd9eddf959f86603a (patch)
tree98aada7aa4e7fc57e0fb0bf9a1bc84e996f483b1 /src/ChunkDef.h
parentFix: GetPhysicalRamUsage on FreeBSD (UNIX) - webadmin display (#5213) (diff)
downloadcuberite-9b97d63f8f939dbc431cc2dcd9eddf959f86603a.tar
cuberite-9b97d63f8f939dbc431cc2dcd9eddf959f86603a.tar.gz
cuberite-9b97d63f8f939dbc431cc2dcd9eddf959f86603a.tar.bz2
cuberite-9b97d63f8f939dbc431cc2dcd9eddf959f86603a.tar.lz
cuberite-9b97d63f8f939dbc431cc2dcd9eddf959f86603a.tar.xz
cuberite-9b97d63f8f939dbc431cc2dcd9eddf959f86603a.tar.zst
cuberite-9b97d63f8f939dbc431cc2dcd9eddf959f86603a.zip
Diffstat (limited to 'src/ChunkDef.h')
-rw-r--r--src/ChunkDef.h58
1 files changed, 10 insertions, 48 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index 673ae347a..12036cdbe 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -207,36 +207,22 @@ public:
}
- inline static int MakeIndex(int x, int y, int z)
+ inline static size_t MakeIndex(int x, int y, int z)
{
- if (
- (x < Width) && (x > -1) &&
- (y < Height) && (y > -1) &&
- (z < Width) && (z > -1)
- )
- {
- return MakeIndexNoCheck(x, y, z);
- }
- FLOGERROR("cChunkDef::MakeIndex(): coords out of range: {0}; returning fake index 0", Vector3i{x, y, z});
- ASSERT(!"cChunkDef::MakeIndex(): coords out of chunk range!");
- return 0;
- }
-
+ ASSERT(IsValidRelPos({ x, y, z }));
- inline static 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 uses XZY
+ return static_cast<size_t>(x + (z * Width) + (y * Width * Width)); // 1.2 uses XZY
#elif AXIS_ORDER == AXIS_ORDER_YZX
- return y + (z * cChunkDef::Width) + (x * cChunkDef::Height * cChunkDef::Width); // 1.1 uses YZX
+ return static_cast<size_t>(y + (z * Width) + (x * Height * Width)); // 1.1 uses YZX
#endif
}
- inline static int MakeIndexNoCheck(Vector3i a_RelPos)
+ inline static size_t MakeIndex(Vector3i a_RelPos)
{
- return MakeIndexNoCheck(a_RelPos.x, a_RelPos.y, a_RelPos.z);
+ return MakeIndex(a_RelPos.x, a_RelPos.y, a_RelPos.z);
}
@@ -263,7 +249,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(a_X, a_Y, a_Z)] = a_Type;
+ a_BlockTypes[MakeIndex(a_X, a_Y, a_Z)] = a_Type;
}
@@ -277,7 +263,7 @@ public:
inline static BLOCKTYPE GetBlock(const BLOCKTYPE * a_BlockTypes, Vector3i a_RelPos)
{
ASSERT(IsValidRelPos(a_RelPos));
- return a_BlockTypes[MakeIndexNoCheck(a_RelPos)];
+ return a_BlockTypes[MakeIndex(a_RelPos)];
}
@@ -286,7 +272,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(a_X, a_Y, a_Z)];
+ return a_BlockTypes[MakeIndex(a_X, a_Y, a_Z)];
}
@@ -333,8 +319,7 @@ public:
{
if ((x < Width) && (x > -1) && (y < Height) && (y > -1) && (z < Width) && (z > -1))
{
- int Index = MakeIndexNoCheck(x, y, z);
- return ExpandNibble(a_Buffer, static_cast<size_t>(Index));
+ return ExpandNibble(a_Buffer, MakeIndex(x, y, z));
}
ASSERT(!"cChunkDef::GetNibble(): coords out of chunk range!");
return 0;
@@ -436,7 +421,6 @@ struct sSetBlock
}
};
-typedef std::list<sSetBlock> sSetBlockList;
typedef std::vector<sSetBlock> sSetBlockVector;
typedef std::list<cChunkCoords> cChunkCoordsList;
@@ -461,27 +445,6 @@ public:
-class cChunkCoordsWithBool
-{
-public:
- int m_ChunkX;
- int m_ChunkZ;
- bool m_ForceGenerate;
-
- cChunkCoordsWithBool(int a_ChunkX, int a_ChunkZ, bool a_ForceGenerate) : m_ChunkX(a_ChunkX), m_ChunkZ(a_ChunkZ), m_ForceGenerate(a_ForceGenerate){}
-
- bool operator == (const cChunkCoordsWithBool & a_Other) const
- {
- return ((m_ChunkX == a_Other.m_ChunkX) && (m_ChunkZ == a_Other.m_ChunkZ) && (m_ForceGenerate == a_Other.m_ForceGenerate));
- }
-};
-
-typedef std::list<cChunkCoordsWithBool> cChunkCoordsWithBoolList;
-
-
-
-
-
/** Interface class used as a callback for operations that involve chunk coords */
class cChunkCoordCallback
{
@@ -518,7 +481,6 @@ public:
} ;
typedef cCoordWithData<int> cCoordWithInt;
-typedef cCoordWithData<BLOCKTYPE> cCoordWithBlock;
typedef std::list<cCoordWithInt> cCoordWithIntList;
typedef std::vector<cCoordWithInt> cCoordWithIntVector;