fixed spaces
This commit is contained in:
parent
0310a50192
commit
6b99e55646
@ -4,7 +4,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
template<class T, size_t NumElementsInReserve>
|
template<class T, size_t NumElementsInReserve>
|
||||||
class cAllocationPool {
|
class cAllocationPool
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
class cStarvationCallbacks
|
class cStarvationCallbacks
|
||||||
@ -17,7 +18,7 @@ class cAllocationPool {
|
|||||||
};
|
};
|
||||||
|
|
||||||
cAllocationPool(std::auto_ptr<cStarvationCallbacks> a_Callbacks) :
|
cAllocationPool(std::auto_ptr<cStarvationCallbacks> a_Callbacks) :
|
||||||
m_Callbacks(a_Callbacks)
|
m_Callbacks(a_Callbacks)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < NumElementsInReserve; i++)
|
for (size_t i = 0; i < NumElementsInReserve; i++)
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ class cAllocationPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
T* Allocate()
|
T * Allocate()
|
||||||
{
|
{
|
||||||
if (m_FreeList.size() <= NumElementsInReserve)
|
if (m_FreeList.size() <= NumElementsInReserve)
|
||||||
{
|
{
|
||||||
@ -61,11 +62,11 @@ class cAllocationPool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// placement new, used to initalize the object
|
// placement new, used to initalize the object
|
||||||
T* ret = new (m_FreeList.front()) T;
|
T * ret = new (m_FreeList.front()) T;
|
||||||
m_FreeList.pop_front();
|
m_FreeList.pop_front();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
void Free(T* ptr)
|
void Free(T * ptr)
|
||||||
{
|
{
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
{
|
{
|
||||||
|
@ -65,7 +65,7 @@ cChunk::cChunk(
|
|||||||
int a_ChunkX, int a_ChunkY, int a_ChunkZ,
|
int a_ChunkX, int a_ChunkY, int a_ChunkZ,
|
||||||
cChunkMap * a_ChunkMap, cWorld * a_World,
|
cChunkMap * a_ChunkMap, cWorld * a_World,
|
||||||
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP,
|
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP,
|
||||||
cAllocationPool<cChunkData::sChunkSection,1600>& a_Pool
|
cAllocationPool<cChunkData::sChunkSection, 1600> & a_Pool
|
||||||
) :
|
) :
|
||||||
m_IsValid(false),
|
m_IsValid(false),
|
||||||
m_IsLightValid(false),
|
m_IsLightValid(false),
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
int a_ChunkX, int a_ChunkY, int a_ChunkZ, // Chunk coords
|
int a_ChunkX, int a_ChunkY, int a_ChunkZ, // Chunk coords
|
||||||
cChunkMap * a_ChunkMap, cWorld * a_World, // Parent objects
|
cChunkMap * a_ChunkMap, cWorld * a_World, // Parent objects
|
||||||
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, // Neighbor chunks
|
cChunk * a_NeighborXM, cChunk * a_NeighborXP, cChunk * a_NeighborZM, cChunk * a_NeighborZP, // Neighbor chunks
|
||||||
cAllocationPool<cChunkData::sChunkSection,1600>& a_Pool
|
cAllocationPool<cChunkData::sChunkSection, 1600> & a_Pool
|
||||||
);
|
);
|
||||||
cChunk(cChunk & other);
|
cChunk(cChunk & other);
|
||||||
~cChunk();
|
~cChunk();
|
||||||
|
@ -27,7 +27,7 @@ template <typename T> inline bool IsAllValue(const T * a_Array, size_t a_NumElem
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
cChunkData::cChunkData(cAllocationPool<cChunkData::sChunkSection, 1600>& a_Pool) :
|
cChunkData::cChunkData(cAllocationPool<cChunkData::sChunkSection, 1600> & a_Pool) :
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus < 201103L
|
||||||
// auto_ptr style interface for memory management
|
// auto_ptr style interface for memory management
|
||||||
m_IsOwner(true),
|
m_IsOwner(true),
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
|
|
||||||
struct sChunkSection;
|
struct sChunkSection;
|
||||||
|
|
||||||
cChunkData(cAllocationPool<cChunkData::sChunkSection, 1600>& a_Pool);
|
cChunkData(cAllocationPool<cChunkData::sChunkSection, 1600> & a_Pool);
|
||||||
~cChunkData();
|
~cChunkData();
|
||||||
|
|
||||||
#if __cplusplus < 201103L
|
#if __cplusplus < 201103L
|
||||||
@ -96,7 +96,8 @@ public:
|
|||||||
Allows a_Src to be NULL, in which case it doesn't do anything. */
|
Allows a_Src to be NULL, in which case it doesn't do anything. */
|
||||||
void SetSkyLight(const NIBBLETYPE * a_Src);
|
void SetSkyLight(const NIBBLETYPE * a_Src);
|
||||||
|
|
||||||
struct sChunkSection {
|
struct sChunkSection
|
||||||
|
{
|
||||||
BLOCKTYPE m_BlockTypes [SectionHeight * 16 * 16] ;
|
BLOCKTYPE m_BlockTypes [SectionHeight * 16 * 16] ;
|
||||||
NIBBLETYPE m_BlockMetas [SectionHeight * 16 * 16 / 2];
|
NIBBLETYPE m_BlockMetas [SectionHeight * 16 * 16 / 2];
|
||||||
NIBBLETYPE m_BlockLight [SectionHeight * 16 * 16 / 2];
|
NIBBLETYPE m_BlockLight [SectionHeight * 16 * 16 / 2];
|
||||||
@ -121,7 +122,7 @@ private:
|
|||||||
/** Sets the data in the specified section to their default values. */
|
/** Sets the data in the specified section to their default values. */
|
||||||
void ZeroSection(sChunkSection * a_Section) const;
|
void ZeroSection(sChunkSection * a_Section) const;
|
||||||
|
|
||||||
cAllocationPool<cChunkData::sChunkSection, 1600>& m_Pool;
|
cAllocationPool<cChunkData::sChunkSection, 1600> & m_Pool;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -2672,7 +2672,7 @@ void cChunkMap::QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
|
|||||||
// cChunkMap::cChunkLayer:
|
// cChunkMap::cChunkLayer:
|
||||||
|
|
||||||
cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent,
|
cChunkMap::cChunkLayer::cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent,
|
||||||
cAllocationPool<cChunkData::sChunkSection,1600>& a_Pool)
|
cAllocationPool<cChunkData::sChunkSection, 1600> & a_Pool)
|
||||||
: m_LayerX( a_LayerX )
|
: m_LayerX( a_LayerX )
|
||||||
, m_LayerZ( a_LayerZ )
|
, m_LayerZ( a_LayerZ )
|
||||||
, m_Parent( a_Parent )
|
, m_Parent( a_Parent )
|
||||||
|
@ -352,7 +352,7 @@ private:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent,
|
cChunkLayer(int a_LayerX, int a_LayerZ, cChunkMap * a_Parent,
|
||||||
cAllocationPool<cChunkData::sChunkSection, 1600>& a_Pool);
|
cAllocationPool<cChunkData::sChunkSection, 1600> & a_Pool);
|
||||||
~cChunkLayer();
|
~cChunkLayer();
|
||||||
|
|
||||||
/** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */
|
/** Always returns an assigned chunkptr, but the chunk needn't be valid (loaded / generated) - callers must check */
|
||||||
|
@ -144,7 +144,7 @@ int main(int argc, char** argv)
|
|||||||
#else
|
#else
|
||||||
copy = std::move(copy);
|
copy = std::move(copy);
|
||||||
#endif
|
#endif
|
||||||
testassert(copy.GetBlock(0,0,0) == 0x42);
|
testassert(copy.GetBlock(0, 0, 0) == 0x42);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user