1
0

Renamed cChunkBuffer to cChunkData

This commit is contained in:
Tycho 2014-05-21 19:58:48 +01:00
parent cdd3d11496
commit 024027db89
15 changed files with 87 additions and 87 deletions

View File

@ -9,7 +9,7 @@
#include "OSSupport/GZipFile.h" #include "OSSupport/GZipFile.h"
#include "Blocks/BlockHandler.h" #include "Blocks/BlockHandler.h"
#include "Cuboid.h" #include "Cuboid.h"
#include "ChunkBuffer.h" #include "ChunkData.h"
@ -1835,7 +1835,7 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ)
void cBlockArea::cChunkReader::ChunkBuffer(const cChunkBuffer & a_BlockBuffer) void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
{ {
{ {
if (!(m_Area.m_BlockTypes == NULL)) if (!(m_Area.m_BlockTypes == NULL))

View File

@ -318,7 +318,7 @@ protected:
// cChunkDataCallback overrides: // cChunkDataCallback overrides:
virtual bool Coords(int a_ChunkX, int a_ChunkZ) override; virtual bool Coords(int a_ChunkX, int a_ChunkZ) override;
virtual void ChunkBuffer(const cChunkBuffer & a_BlockTypes) override; virtual void ChunkData(const cChunkData & a_BlockTypes) override;
} ; } ;
typedef NIBBLETYPE * NIBBLEARRAY; typedef NIBBLETYPE * NIBBLEARRAY;

View File

@ -238,12 +238,12 @@ void cChunk::MarkLoadFailed(void)
void cChunk::GetAllData(cChunkDataCallback & a_Callback) void cChunk::GetAllData(cChunkDataCallback & a_Callback)
{ {
a_Callback.HeightMap (&m_HeightMap); a_Callback.HeightMap(&m_HeightMap);
a_Callback.BiomeData (&m_BiomeMap); a_Callback.BiomeData(&m_BiomeMap);
a_Callback.LightIsValid (m_IsLightValid); a_Callback.LightIsValid(m_IsLightValid);
a_Callback.ChunkBuffer (m_ChunkBuffer); a_Callback.ChunkData(m_ChunkData);
for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr) for (cEntityList::iterator itr = m_Entities.begin(); itr != m_Entities.end(); ++itr)
{ {
@ -282,10 +282,10 @@ void cChunk::SetAllData(
CalculateHeightmap(a_BlockTypes); CalculateHeightmap(a_BlockTypes);
} }
m_ChunkBuffer.SetBlocks(a_BlockTypes); m_ChunkData.SetBlocks(a_BlockTypes);
m_ChunkBuffer.SetMeta(a_BlockMeta); m_ChunkData.SetMeta(a_BlockMeta);
m_ChunkBuffer.SetLight(a_BlockLight); m_ChunkData.SetLight(a_BlockLight);
m_ChunkBuffer.SetSkyLight(a_BlockSkyLight); m_ChunkData.SetSkyLight(a_BlockSkyLight);
m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL); m_IsLightValid = (a_BlockLight != NULL) && (a_BlockSkyLight != NULL);
@ -326,9 +326,9 @@ void cChunk::SetLight(
// TODO: We might get cases of wrong lighting when a chunk changes in the middle of a lighting calculation. // TODO: We might get cases of wrong lighting when a chunk changes in the middle of a lighting calculation.
// Postponing until we see how bad it is :) // Postponing until we see how bad it is :)
m_ChunkBuffer.SetLight (a_BlockLight); m_ChunkData.SetLight (a_BlockLight);
m_ChunkBuffer.SetSkyLight (a_SkyLight); m_ChunkData.SetSkyLight (a_SkyLight);
m_IsLightValid = true; m_IsLightValid = true;
} }
@ -339,7 +339,7 @@ void cChunk::SetLight(
void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes) void cChunk::GetBlockTypes(BLOCKTYPE * a_BlockTypes)
{ {
m_ChunkBuffer.CopyBlocks(a_BlockTypes); m_ChunkData.CopyBlocks(a_BlockTypes);
} }
@ -1507,7 +1507,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
ASSERT(IsValid()); ASSERT(IsValid());
const BLOCKTYPE OldBlockType = GetBlock(a_RelX, a_RelY, a_RelZ); const BLOCKTYPE OldBlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
const BLOCKTYPE OldBlockMeta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); const BLOCKTYPE OldBlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta)) if ((OldBlockType == a_BlockType) && (OldBlockMeta == a_BlockMeta))
{ {
return; return;
@ -1515,7 +1515,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
MarkDirty(); MarkDirty();
m_ChunkBuffer.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType); m_ChunkData.SetBlock(a_RelX, a_RelY, a_RelZ, a_BlockType);
// The client doesn't need to distinguish between stationary and nonstationary fluids: // The client doesn't need to distinguish between stationary and nonstationary fluids:
if ( if (
@ -1531,7 +1531,7 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta)); m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, a_BlockType, a_BlockMeta));
} }
m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta); m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_BlockMeta);
// ONLY recalculate lighting if it's necessary! // ONLY recalculate lighting if it's necessary!
if ( if (
@ -2438,7 +2438,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
return 0; // Clip return 0; // Clip
} }
return m_ChunkBuffer.GetBlock(a_RelX, a_RelY, a_RelZ); return m_ChunkData.GetBlock(a_RelX, a_RelY, a_RelZ);
} }
@ -2448,7 +2448,7 @@ BLOCKTYPE cChunk::GetBlock(int a_RelX, int a_RelY, int a_RelZ) const
void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{ {
a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ); a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
a_BlockMeta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); a_BlockMeta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
} }
@ -2458,9 +2458,9 @@ void cChunk::GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_
void cChunk::GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight) void cChunk::GetBlockInfo(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_Meta, NIBBLETYPE & a_SkyLight, NIBBLETYPE & a_BlockLight)
{ {
a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ); a_BlockType = GetBlock(a_RelX, a_RelY, a_RelZ);
a_Meta = m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); a_Meta = m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
a_SkyLight = m_ChunkBuffer.GetSkyLight(a_RelX, a_RelY, a_RelZ); a_SkyLight = m_ChunkData.GetSkyLight(a_RelX, a_RelY, a_RelZ);
a_BlockLight = m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); a_BlockLight = m_ChunkData.GetBlockLight(a_RelX, a_RelY, a_RelZ);
} }

View File

@ -3,7 +3,7 @@
#include "Entities/Entity.h" #include "Entities/Entity.h"
#include "ChunkDef.h" #include "ChunkDef.h"
#include "ChunkBuffer.h" #include "ChunkData.h"
#include "Simulator/FireSimulator.h" #include "Simulator/FireSimulator.h"
#include "Simulator/SandSimulator.h" #include "Simulator/SandSimulator.h"
@ -324,21 +324,21 @@ public:
inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const inline NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const
{ {
return m_ChunkBuffer.GetMeta(a_RelX, a_RelY, a_RelZ); return m_ChunkData.GetMeta(a_RelX, a_RelY, a_RelZ);
} }
inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) inline void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
{ {
if (!(GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta)) if (!(GetMeta(a_RelX, a_RelY, a_RelZ) == a_Meta))
{ {
MarkDirty(); MarkDirty();
m_ChunkBuffer.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta); m_ChunkData.SetMeta(a_RelX, a_RelY, a_RelZ, a_Meta);
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta)); m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelX, a_RelY, a_RelZ, GetBlock(a_RelX, a_RelY, a_RelZ), a_Meta));
} }
} }
inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkBuffer.GetBlockLight(a_RelX, a_RelY, a_RelZ); } inline NIBBLETYPE GetBlockLight(int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkData.GetBlockLight(a_RelX, a_RelY, a_RelZ); }
inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkBuffer.GetSkyLight(a_RelX, a_RelY, a_RelZ); } inline NIBBLETYPE GetSkyLight (int a_RelX, int a_RelY, int a_RelZ) const {return m_ChunkData.GetSkyLight(a_RelX, a_RelY, a_RelZ); }
/** Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case); returns true on success */ /** Same as GetBlock(), but relative coords needn't be in this chunk (uses m_Neighbor-s or m_ChunkMap in such a case); returns true on success */
bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const; bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const;
@ -430,7 +430,7 @@ private:
cWorld * m_World; cWorld * m_World;
cChunkMap * m_ChunkMap; cChunkMap * m_ChunkMap;
cChunkBuffer m_ChunkBuffer; cChunkData m_ChunkData;
cChunkDef::HeightMap m_HeightMap; cChunkDef::HeightMap m_HeightMap;
cChunkDef::BiomeMap m_BiomeMap; cChunkDef::BiomeMap m_BiomeMap;

View File

@ -1,10 +1,10 @@
#include "Globals.h" #include "Globals.h"
#include "ChunkBuffer.h" #include "ChunkData.h"
cChunkBuffer cChunkBuffer::Copy() const cChunkData cChunkData::Copy() const
{ {
cChunkBuffer copy; cChunkData copy;
for (int i = 0; i < CHUNK_SECTION_NUM; i++) for (int i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
if(m_Sections[i]) if(m_Sections[i])
@ -20,7 +20,7 @@ cChunkBuffer cChunkBuffer::Copy() const
void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length) const
{ {
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
@ -54,7 +54,7 @@ void cChunkBuffer::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length
void cChunkBuffer::CopyMeta(NIBBLETYPE * a_dest) const void cChunkData::CopyMeta(NIBBLETYPE * a_dest) const
{ {
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
@ -81,7 +81,7 @@ void cChunkBuffer::CopyMeta(NIBBLETYPE * a_dest) const
void cChunkBuffer::CopyLight(NIBBLETYPE * a_dest) const void cChunkData::CopyLight(NIBBLETYPE * a_dest) const
{ {
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
@ -109,7 +109,7 @@ void cChunkBuffer::CopyLight(NIBBLETYPE * a_dest) const
void cChunkBuffer::CopySkyLight(NIBBLETYPE * a_dest) const void cChunkData::CopySkyLight(NIBBLETYPE * a_dest) const
{ {
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
@ -137,7 +137,7 @@ void cChunkBuffer::CopySkyLight(NIBBLETYPE * a_dest) const
void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src) void cChunkData::SetBlocks(const BLOCKTYPE * a_src)
{ {
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
@ -175,7 +175,7 @@ void cChunkBuffer::SetBlocks(const BLOCKTYPE * a_src)
void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src) void cChunkData::SetMeta(const NIBBLETYPE * a_src)
{ {
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
@ -213,7 +213,7 @@ void cChunkBuffer::SetMeta(const NIBBLETYPE * a_src)
void cChunkBuffer::SetLight(const NIBBLETYPE * a_src) void cChunkData::SetLight(const NIBBLETYPE * a_src)
{ {
if (!a_src) return; if (!a_src) return;
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
@ -252,7 +252,7 @@ void cChunkBuffer::SetLight(const NIBBLETYPE * a_src)
void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src) void cChunkData::SetSkyLight (const NIBBLETYPE * a_src)
{ {
if (!a_src) return; if (!a_src) return;
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
@ -292,22 +292,22 @@ void cChunkBuffer::SetSkyLight (const NIBBLETYPE * a_src)
cChunkBuffer::sChunkSection * cChunkBuffer::Allocate() const cChunkData::sChunkSection * cChunkData::Allocate() const
{ {
// TODO: use a allocation pool // TODO: use a allocation pool
return new cChunkBuffer::sChunkSection; return new cChunkData::sChunkSection;
} }
void cChunkBuffer::Free(cChunkBuffer::sChunkSection * ptr) const void cChunkData::Free(cChunkData::sChunkSection * ptr) const
{ {
delete ptr; delete ptr;
} }
void cChunkBuffer::ZeroSection(cChunkBuffer::sChunkSection * ptr) const void cChunkData::ZeroSection(cChunkData::sChunkSection * ptr) const
{ {
memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes)); memset(ptr->m_BlockTypes,0x00,sizeof(ptr->m_BlockTypes));
memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta)); memset(ptr->m_BlockMeta,0x00,sizeof(ptr->m_BlockMeta));

View File

@ -17,11 +17,11 @@
// unique_ptr style interface for memory management // unique_ptr style interface for memory management
#endif #endif
class cChunkBuffer class cChunkData
{ {
public: public:
cChunkBuffer() cChunkData()
#if __cplusplus < 201103L #if __cplusplus < 201103L
// auto_ptr style interface for memory management // auto_ptr style interface for memory management
: IsOwner(true) : IsOwner(true)
@ -29,7 +29,7 @@ public:
{ {
memset(m_Sections, 0, sizeof(m_Sections)); memset(m_Sections, 0, sizeof(m_Sections));
} }
~cChunkBuffer() ~cChunkData()
{ {
#if __cplusplus < 201103L #if __cplusplus < 201103L
// auto_ptr style interface for memory management // auto_ptr style interface for memory management
@ -43,7 +43,7 @@ public:
#if __cplusplus < 201103L #if __cplusplus < 201103L
// auto_ptr style interface for memory management // auto_ptr style interface for memory management
cChunkBuffer(const cChunkBuffer& other) : cChunkData(const cChunkData& other) :
IsOwner(true) IsOwner(true)
{ {
for (int i = 0; i < CHUNK_SECTION_NUM; i++) for (int i = 0; i < CHUNK_SECTION_NUM; i++)
@ -53,7 +53,7 @@ public:
other.IsOwner = false; other.IsOwner = false;
} }
cChunkBuffer& operator=(const cChunkBuffer& other) cChunkData& operator=(const cChunkData& other)
{ {
if(&other != this) if(&other != this)
{ {
@ -76,7 +76,7 @@ public:
} }
#else #else
// unique_ptr style interface for memory management // unique_ptr style interface for memory management
cChunkBuffer(cChunkBuffer&& other) cChunkData(cChunkData&& other)
{ {
for (int i = 0; i < CHUNK_SECTION_NUM; i++) for (int i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
@ -85,7 +85,7 @@ public:
} }
} }
cChunkBuffer& operator=(cChunkBuffer&& other) cChunkData& operator=(cChunkData&& other)
{ {
if(&other != this) if(&other != this)
{ {
@ -125,7 +125,7 @@ public:
(a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0)
) )
{ {
ASSERT(!"cChunkBuffer::SetMeta(): index out of range!"); ASSERT(!"cChunkData::SetMeta(): index out of range!");
return; return;
} }
@ -163,7 +163,7 @@ public:
return 0; return 0;
} }
} }
ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
return 0; return 0;
} }
@ -175,7 +175,7 @@ public:
(a_RelZ >= cChunkDef::Width) || (a_RelZ < 0) (a_RelZ >= cChunkDef::Width) || (a_RelZ < 0)
) )
{ {
ASSERT(!"cChunkBuffer::SetMeta(): index out of range!"); ASSERT(!"cChunkData::SetMeta(): index out of range!");
return; return;
} }
@ -216,7 +216,7 @@ public:
return 0; return 0;
} }
} }
ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
return 0; return 0;
} }
@ -235,11 +235,11 @@ public:
return 0xF; return 0xF;
} }
} }
ASSERT(!"cChunkBuffer::GetMeta(): coords out of chunk range!"); ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
return 0; return 0;
} }
cChunkBuffer Copy() const; cChunkData Copy() const;
void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const; void CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx = 0, size_t length = cChunkDef::NumBlocks) const;
void CopyMeta (NIBBLETYPE * a_dest) const; void CopyMeta (NIBBLETYPE * a_dest) const;
void CopyLight (NIBBLETYPE * a_dest) const; void CopyLight (NIBBLETYPE * a_dest) const;

View File

@ -3,7 +3,7 @@
#pragma once #pragma once
#include "ChunkBuffer.h" #include "ChunkData.h"
/** Interface class used for getting data out of a chunk using the GetAllData() function. /** Interface class used for getting data out of a chunk using the GetAllData() function.
@ -26,13 +26,13 @@ public:
virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); }; virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) {UNUSED(a_HeightMap); };
/// Called once to provide biome data /// Called once to provide biome data
virtual void BiomeData (const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); }; virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) {UNUSED(a_BiomeMap); };
/// Called once to let know if the chunk lighting is valid. Return value is ignored /// Called once to let know if the chunk lighting is valid. Return value is ignored
virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); }; virtual void LightIsValid(bool a_IsLightValid) {UNUSED(a_IsLightValid); };
/// Called once to export block info /// Called once to export block info
virtual void ChunkBuffer (const cChunkBuffer & a_Buffer) {UNUSED(a_Buffer); }; virtual void ChunkData(const cChunkData & a_Buffer) {UNUSED(a_Buffer); };
/// Called for each entity in the chunk /// Called for each entity in the chunk
virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); }; virtual void Entity(cEntity * a_Entity) {UNUSED(a_Entity); };
@ -43,16 +43,16 @@ public:
/** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer /** A simple implementation of the cChunkDataCallback interface that collects all block data into a buffer
*/ */
class cChunkBufferCollector : class cChunkDataCollector :
public cChunkDataCallback public cChunkDataCallback
{ {
public: public:
cChunkBuffer m_BlockData; cChunkData m_BlockData;
protected: protected:
virtual void ChunkBuffer(const cChunkBuffer & a_BlockData) override virtual void ChunkData(const cChunkData & a_BlockData) override
{ {
m_BlockData = a_BlockData.Copy(); m_BlockData = a_BlockData.Copy();
} }
@ -61,7 +61,7 @@ protected:
/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer /** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer
*/ */
class cChunkDataCollector : class cChunkDataArrayCollector :
public cChunkDataCallback public cChunkDataCallback
{ {
public: public:
@ -71,7 +71,7 @@ public:
protected: protected:
virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
{ {
a_ChunkBuffer.CopyBlocks(m_BlockData); a_ChunkBuffer.CopyBlocks(m_BlockData);
a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks); a_ChunkBuffer.CopyMeta(m_BlockData + cChunkDef::NumBlocks);
@ -94,7 +94,7 @@ public:
protected: protected:
virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
{ {
a_ChunkBuffer.CopyBlocks(m_BlockTypes); a_ChunkBuffer.CopyBlocks(m_BlockTypes);
a_ChunkBuffer.CopyMeta(m_BlockMetas); a_ChunkBuffer.CopyMeta(m_BlockMetas);

View File

@ -18,7 +18,7 @@
class cReader : class cReader :
public cChunkDataCallback public cChunkDataCallback
{ {
virtual void ChunkBuffer(const cChunkBuffer & a_ChunkBuffer) override virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
{ {
BLOCKTYPE * OutputRows = m_BlockTypes; BLOCKTYPE * OutputRows = m_BlockTypes;
int InputIdx = 0; int InputIdx = 0;

View File

@ -22,7 +22,7 @@
/// Helper class for serializing a chunk into Json /// Helper class for serializing a chunk into Json
class cJsonChunkSerializer : class cJsonChunkSerializer :
public cChunkDataCollector public cChunkDataArrayCollector
{ {
public: public:

View File

@ -4,4 +4,4 @@ enable_testing()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}) include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(ChunkBuffer) add_subdirectory(ChunkData)

View File

@ -1,6 +1,6 @@
#include "TestGlobals.h" #include "TestGlobals.h"
#include "ChunkBuffer.h" #include "ChunkData.h"
@ -8,7 +8,7 @@ int main(int argc, char** argv)
{ {
{ {
// Test first segment // Test first segment
cChunkBuffer buffer; cChunkData buffer;
BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
@ -45,7 +45,7 @@ int main(int argc, char** argv)
{ {
// test following segment // test following segment
cChunkBuffer buffer; cChunkData buffer;
BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
@ -82,7 +82,7 @@ int main(int argc, char** argv)
{ {
// test zeros // test zeros
cChunkBuffer buffer; cChunkData buffer;
BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; BLOCKTYPE* SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);

View File

@ -4,7 +4,7 @@ enable_testing()
include_directories(${CMAKE_SOURCE_DIR}/src/) include_directories(${CMAKE_SOURCE_DIR}/src/)
add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkBuffer.cpp) add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp)
add_executable(creatable-exe creatable.cpp) add_executable(creatable-exe creatable.cpp)

View File

@ -1,13 +1,13 @@
#include "TestGlobals.h" #include "TestGlobals.h"
#include "ChunkBuffer.h" #include "ChunkData.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
{ {
cChunkBuffer buffer; cChunkData buffer;
// Empty chunks // Empty chunks
buffer.SetBlock(0,0,0, 0xAB); buffer.SetBlock(0,0,0, 0xAB);
@ -105,7 +105,7 @@ int main(int argc, char** argv)
} }
{ {
cChunkBuffer buffer; cChunkData buffer;
// Zero's // Zero's
buffer.SetBlock(0,0,0, 0x0); buffer.SetBlock(0,0,0, 0x0);
@ -122,9 +122,9 @@ int main(int argc, char** argv)
{ {
// Operator = // Operator =
cChunkBuffer buffer; cChunkData buffer;
buffer.SetBlock(0,0,0,0x42); buffer.SetBlock(0,0,0,0x42);
cChunkBuffer copy; cChunkData copy;
#if __cplusplus < 201103L #if __cplusplus < 201103L
copy = buffer; copy = buffer;
#else #else

View File

@ -1,18 +1,18 @@
#include "TestGlobals.h" #include "TestGlobals.h"
#include "ChunkBuffer.h" #include "ChunkData.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
{ {
cChunkBuffer buffer; cChunkData buffer;
buffer.SetBlock(3,1,4,0xDE); buffer.SetBlock(3,1,4,0xDE);
buffer.SetMeta(3,1,4,0xA); buffer.SetMeta(3,1,4,0xA);
cChunkBuffer copy = buffer.Copy(); cChunkData copy = buffer.Copy();
testassert(copy.GetBlock(3,1,4) == 0xDE); testassert(copy.GetBlock(3,1,4) == 0xDE);
testassert(copy.GetMeta(3,1,4) == 0xA); testassert(copy.GetMeta(3,1,4) == 0xA);
@ -47,7 +47,7 @@ int main(int argc, char** argv)
} }
{ {
cChunkBuffer buffer; cChunkData buffer;
NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2]; NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
@ -80,7 +80,7 @@ int main(int argc, char** argv)
} }
{ {
cChunkBuffer buffer; cChunkData buffer;
NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2]; NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
@ -114,7 +114,7 @@ int main(int argc, char** argv)
} }
{ {
cChunkBuffer buffer; cChunkData buffer;
NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2]; NIBBLETYPE * SrcNibbleBuffer = new NIBBLETYPE[16 * 16 * 256/2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4) for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
@ -148,7 +148,7 @@ int main(int argc, char** argv)
} }
{ {
cChunkBuffer buffer; cChunkData buffer;
BLOCKTYPE * SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256]; BLOCKTYPE * SrcBlockBuffer = new BLOCKTYPE[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256); memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);

View File

@ -1,9 +1,9 @@
#include "TestGlobals.h" #include "TestGlobals.h"
#include "ChunkBuffer.h" #include "ChunkData.h"
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
cChunkBuffer buffer; cChunkData buffer;
return 0; return 0;
} }