summaryrefslogtreecommitdiffstats
path: root/src/ChunkDef.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/ChunkDef.h')
-rw-r--r--src/ChunkDef.h39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/ChunkDef.h b/src/ChunkDef.h
index 7be2fa2df..9c7753820 100644
--- a/src/ChunkDef.h
+++ b/src/ChunkDef.h
@@ -9,7 +9,7 @@
#pragma once
-#include "Vector3i.h"
+#include "Vector3.h"
#include "BiomeDef.h"
@@ -62,16 +62,12 @@ typedef unsigned char HEIGHTTYPE;
class cChunkDef
{
public:
- enum
- {
- // Chunk dimensions:
- Width = 16,
- Height = 256,
- NumBlocks = Width * Height * Width,
-
- /// If the data is collected into a single buffer, how large it needs to be:
- BlockDataSize = cChunkDef::NumBlocks * 2 + (cChunkDef::NumBlocks / 2), // 2.5 * numblocks
- } ;
+ // Chunk dimensions:
+ static const int Width = 16;
+ static const int Height = 256;
+ static const int NumBlocks = Width * Height * Width;
+ /// If the data is collected into a single buffer, how large it needs to be:
+ static const int BlockDataSize = cChunkDef::NumBlocks * 2 + (cChunkDef::NumBlocks / 2); // 2.5 * numblocks
/// The type used for any heightmap operations and storage; idx = x + Width * z; Height points to the highest non-air block in the column
typedef HEIGHTTYPE HeightMap[Width * Width];
@@ -116,7 +112,7 @@ public:
}
- inline static unsigned int MakeIndex(int x, int y, int z )
+ inline static int MakeIndex(int x, int y, int z )
{
if (
(x < Width) && (x > -1) &&
@@ -132,7 +128,7 @@ public:
}
- inline static unsigned int MakeIndexNoCheck(int x, int y, int 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.
@@ -255,7 +251,7 @@ public:
ASSERT(!"cChunkDef::SetNibble(): index out of range!");
return;
}
- a_Buffer[a_BlockIdx / 2] = (
+ a_Buffer[a_BlockIdx / 2] = static_cast<NIBBLETYPE>(
(a_Buffer[a_BlockIdx / 2] & (0xf0 >> ((a_BlockIdx & 1) * 4))) | // The untouched nibble
((a_Nibble & 0x0f) << ((a_BlockIdx & 1) * 4)) // The nibble being set
);
@@ -275,20 +271,20 @@ public:
}
int Index = MakeIndexNoCheck(x, y, z);
- a_Buffer[Index / 2] = (
+ 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
);
}
- inline static char GetNibble(const NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos )
+ inline static NIBBLETYPE GetNibble(const NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos )
{
return GetNibble(a_Buffer, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z );
}
- inline static void SetNibble(NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos, char a_Value )
+ inline static void SetNibble(NIBBLETYPE * a_Buffer, const Vector3i & a_BlockPos, NIBBLETYPE a_Value )
{
SetNibble( a_Buffer, a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, a_Value );
}
@@ -306,6 +302,9 @@ The virtual methods are called in the same order as they're declared here.
class cChunkDataCallback abstract
{
public:
+
+ virtual ~cChunkDataCallback() {}
+
/** Called before any other callbacks to inform of the current coords
(only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
If false is returned, the chunk is skipped.
@@ -432,6 +431,9 @@ Used primarily for entity moving while both chunks are locked.
class cClientDiffCallback
{
public:
+
+ virtual ~cClientDiffCallback() {}
+
/// Called for clients that are in Chunk1 and not in Chunk2,
virtual void Removed(cClientHandle * a_Client) = 0;
@@ -492,6 +494,9 @@ typedef std::vector<cChunkCoords> cChunkCoordsVector;
class cChunkCoordCallback
{
public:
+
+ virtual ~cChunkCoordCallback() {}
+
virtual void Call(int a_ChunkX, int a_ChunkZ) = 0;
} ;