2014-05-18 10:10:12 -04:00
|
|
|
|
2014-05-29 12:25:08 -04:00
|
|
|
// ChunkDataCallback.h
|
|
|
|
|
|
|
|
// Declares the cChunkDataCallback interface and several trivial descendants, for reading chunk data
|
|
|
|
|
2014-05-18 10:10:12 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-29 12:25:08 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-05-21 14:58:48 -04:00
|
|
|
#include "ChunkData.h"
|
2014-05-18 10:10:12 -04:00
|
|
|
|
|
|
|
|
2014-05-29 12:25:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
2014-05-18 10:10:12 -04:00
|
|
|
/** Interface class used for getting data out of a chunk using the GetAllData() function.
|
|
|
|
Implementation must use the pointers immediately and NOT store any of them for later use
|
2015-07-31 10:49:10 -04:00
|
|
|
The virtual methods are called in the same order as they're declared here. */
|
2014-05-18 10:10:12 -04:00
|
|
|
class cChunkDataCallback abstract
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
virtual ~cChunkDataCallback() {}
|
|
|
|
|
2014-07-17 10:33:09 -04:00
|
|
|
/** Called before any other callbacks to inform of the current coords
|
|
|
|
(only in processes where multiple chunks can be processed, such as cWorld::ForEachChunkInRect()).
|
2015-07-31 10:49:10 -04:00
|
|
|
If false is returned, the chunk is skipped. */
|
2014-07-22 18:36:13 -04:00
|
|
|
virtual bool Coords(int a_ChunkX, int a_ChunkZ) { UNUSED(a_ChunkX); UNUSED(a_ChunkZ); return true; }
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Called once to provide heightmap data */
|
2014-07-22 18:36:13 -04:00
|
|
|
virtual void HeightMap(const cChunkDef::HeightMap * a_HeightMap) { UNUSED(a_HeightMap); }
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Called once to provide biome data */
|
2014-07-22 18:36:13 -04:00
|
|
|
virtual void BiomeData(const cChunkDef::BiomeMap * a_BiomeMap) { UNUSED(a_BiomeMap); }
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Called once to let know if the chunk lighting is valid. Return value is ignored */
|
2014-07-22 18:36:13 -04:00
|
|
|
virtual void LightIsValid(bool a_IsLightValid) { UNUSED(a_IsLightValid); }
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Called once to export block info */
|
2014-07-22 18:36:13 -04:00
|
|
|
virtual void ChunkData(const cChunkData & a_Buffer) { UNUSED(a_Buffer); }
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Called for each entity in the chunk */
|
2014-07-22 18:36:13 -04:00
|
|
|
virtual void Entity(cEntity * a_Entity) { UNUSED(a_Entity); }
|
2016-02-05 16:45:45 -05:00
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** Called for each blockentity in the chunk */
|
2014-07-22 18:36:13 -04:00
|
|
|
virtual void BlockEntity(cBlockEntity * a_Entity) { UNUSED(a_Entity); }
|
2014-05-18 10:10:12 -04:00
|
|
|
} ;
|
|
|
|
|
2014-05-29 12:25:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-31 10:49:10 -04:00
|
|
|
/** A simple implementation of the cChunkDataCallback interface that collects all block data into a single buffer */
|
2014-05-21 14:58:48 -04:00
|
|
|
class cChunkDataArrayCollector :
|
2014-05-24 08:33:40 -04:00
|
|
|
public cChunkDataCallback
|
2014-05-18 10:10:12 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Must be unsigned char instead of BLOCKTYPE or NIBBLETYPE, because it houses both.
|
|
|
|
unsigned char m_BlockData[cChunkDef::BlockDataSize];
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2014-05-21 14:58:48 -04:00
|
|
|
virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
|
2014-05-18 10:10:12 -04:00
|
|
|
{
|
2014-05-29 12:25:08 -04:00
|
|
|
a_ChunkBuffer.CopyBlockTypes(m_BlockData);
|
|
|
|
a_ChunkBuffer.CopyMetas(m_BlockData + cChunkDef::NumBlocks);
|
2014-05-24 08:33:40 -04:00
|
|
|
a_ChunkBuffer.CopyBlockLight(m_BlockData + 3 * cChunkDef::NumBlocks / 2);
|
2014-05-18 10:10:12 -04:00
|
|
|
a_ChunkBuffer.CopySkyLight(m_BlockData + 2 * cChunkDef::NumBlocks);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-05-29 12:25:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** A simple implementation of the cChunkDataCallback interface that collects all block data into separate buffers */
|
2014-05-18 10:10:12 -04:00
|
|
|
class cChunkDataSeparateCollector :
|
2014-05-24 08:33:40 -04:00
|
|
|
public cChunkDataCallback
|
2014-05-18 10:10:12 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
cChunkDef::BlockTypes m_BlockTypes;
|
|
|
|
cChunkDef::BlockNibbles m_BlockMetas;
|
|
|
|
cChunkDef::BlockNibbles m_BlockLight;
|
|
|
|
cChunkDef::BlockNibbles m_BlockSkyLight;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2014-05-21 14:58:48 -04:00
|
|
|
virtual void ChunkData(const cChunkData & a_ChunkBuffer) override
|
2014-05-18 10:10:12 -04:00
|
|
|
{
|
2014-05-29 12:25:08 -04:00
|
|
|
a_ChunkBuffer.CopyBlockTypes(m_BlockTypes);
|
|
|
|
a_ChunkBuffer.CopyMetas(m_BlockMetas);
|
|
|
|
a_ChunkBuffer.CopyBlockLight(m_BlockLight);
|
|
|
|
a_ChunkBuffer.CopySkyLight(m_BlockSkyLight);
|
2014-05-18 10:10:12 -04:00
|
|
|
}
|
|
|
|
} ;
|
|
|
|
|
2014-05-29 12:25:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
|