diff options
Diffstat (limited to '')
-rw-r--r-- | src/Chunk.cpp | 7 | ||||
-rw-r--r-- | src/ChunkDef.h | 24 | ||||
-rw-r--r-- | src/WorldStorage/WSSCompact.cpp | 6 | ||||
-rw-r--r-- | src/WorldStorage/WSSCompact.h | 8 |
4 files changed, 24 insertions, 21 deletions
diff --git a/src/Chunk.cpp b/src/Chunk.cpp index 3eb46213c..3ae4e36be 100644 --- a/src/Chunk.cpp +++ b/src/Chunk.cpp @@ -633,11 +633,6 @@ void cChunk::Tick(float a_Dt) void cChunk::TickBlock(int a_RelX, int a_RelY, int a_RelZ) { unsigned Index = MakeIndex(a_RelX, a_RelY, a_RelZ); - if (Index == INDEX_OUT_OF_RANGE) - { - // An assert has already been made in MakeIndex() - return; - } cBlockHandler * Handler = BlockHandler(m_BlockTypes[Index]); ASSERT(Handler != NULL); // Happenned on server restart, FS #243 Handler->OnUpdate(*this, a_RelX, a_RelY, a_RelZ); @@ -1492,7 +1487,7 @@ void cChunk::QueueTickBlockNeighbors(int a_RelX, int a_RelY, int a_RelZ) { 0, 0, 1}, { 0, 0, -1}, } ; - for (int i = 0; i < ARRAYCOUNT(Coords); i++) + for (size_t i = 0; i < ARRAYCOUNT(Coords); i++) { UnboundedQueueTickBlock(a_RelX + Coords[i].x, a_RelY + Coords[i].y, a_RelZ + Coords[i].z); } // for i - Coords[] diff --git a/src/ChunkDef.h b/src/ChunkDef.h index d6630df7e..8c37e7907 100644 --- a/src/ChunkDef.h +++ b/src/ChunkDef.h @@ -152,17 +152,16 @@ enum EMCSBiome class cChunkDef { public: - static const int Width = 16; - static const int Height = 256; - static const int NumBlocks = Width * Height * Width; - static const int BlockDataSize = NumBlocks * 2 + (NumBlocks / 2); // 2.5 * numblocks - - // Offsets to individual components in the joined blockdata array - static const int MetaOffset = NumBlocks; - static const int LightOffset = MetaOffset + NumBlocks / 2; - static const int SkyLightOffset = LightOffset + NumBlocks / 2; - - static const unsigned int INDEX_OUT_OF_RANGE = 0xffffffff; + 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 + } ; /// 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]; @@ -216,8 +215,9 @@ public: { 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!"); - return INDEX_OUT_OF_RANGE; + return 0; } diff --git a/src/WorldStorage/WSSCompact.cpp b/src/WorldStorage/WSSCompact.cpp index 287938b24..e2556b96e 100644 --- a/src/WorldStorage/WSSCompact.cpp +++ b/src/WorldStorage/WSSCompact.cpp @@ -871,9 +871,9 @@ bool cWSSCompact::LoadChunkFromData(const cChunkCoords & a_Chunk, int & a_Uncomp } BLOCKTYPE * BlockData = (BLOCKTYPE *)UncompressedData.data(); - NIBBLETYPE * MetaData = (NIBBLETYPE *)(BlockData + cChunkDef::MetaOffset); - NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + cChunkDef::LightOffset); - NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + cChunkDef::SkyLightOffset); + NIBBLETYPE * MetaData = (NIBBLETYPE *)(BlockData + MetaOffset); + NIBBLETYPE * BlockLight = (NIBBLETYPE *)(BlockData + LightOffset); + NIBBLETYPE * SkyLight = (NIBBLETYPE *)(BlockData + SkyLightOffset); a_World->SetChunkData( a_Chunk.m_ChunkX, a_Chunk.m_ChunkZ, diff --git a/src/WorldStorage/WSSCompact.h b/src/WorldStorage/WSSCompact.h index a75c41ccb..3223a986e 100644 --- a/src/WorldStorage/WSSCompact.h +++ b/src/WorldStorage/WSSCompact.h @@ -58,6 +58,14 @@ public: protected: + enum + { + // Offsets to individual components in the joined blockdata array + MetaOffset = cChunkDef::NumBlocks, + LightOffset = MetaOffset + cChunkDef::NumBlocks / 2, + SkyLightOffset = LightOffset + cChunkDef::NumBlocks / 2, + } ; + struct sChunkHeader; typedef std::vector<sChunkHeader *> sChunkHeaders; |