1
0

Fixed stylistic issues

This commit is contained in:
Tycho 2014-05-21 20:08:34 +01:00
parent 024027db89
commit 5929ffbc40
4 changed files with 25 additions and 25 deletions

View File

@ -1838,7 +1838,7 @@ bool cBlockArea::cChunkReader::Coords(int a_ChunkX, int a_ChunkZ)
void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer) void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
{ {
{ {
if (!(m_Area.m_BlockTypes == NULL)) if (m_Area.m_BlockTypes != NULL)
{ {
int SizeY = m_Area.m_Size.y; int SizeY = m_Area.m_Size.y;
int MinY = m_Origin.y; int MinY = m_Origin.y;
@ -1901,17 +1901,17 @@ void cBlockArea::cChunkReader::ChunkData(const cChunkData & a_BlockBuffer)
} }
} }
if (m_Area.m_BlockMetas) if (m_Area.m_BlockMetas != NULL)
{ {
a_BlockBuffer.CopyMeta(m_Area.m_BlockMetas); a_BlockBuffer.CopyMeta(m_Area.m_BlockMetas);
} }
if (m_Area.m_BlockLight) if (m_Area.m_BlockLight != NULL)
{ {
a_BlockBuffer.CopyLight(m_Area.m_BlockLight); a_BlockBuffer.CopyLight(m_Area.m_BlockLight);
} }
if (m_Area.m_BlockSkyLight) if (m_Area.m_BlockSkyLight != NULL)
{ {
a_BlockBuffer.CopySkyLight(m_Area.m_BlockSkyLight); a_BlockBuffer.CopySkyLight(m_Area.m_BlockSkyLight);
} }

View File

@ -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_ChunkData.SetLight (a_BlockLight); m_ChunkData.SetLight(a_BlockLight);
m_ChunkData.SetSkyLight (a_SkyLight); m_ChunkData.SetSkyLight(a_SkyLight);
m_IsLightValid = true; m_IsLightValid = true;
} }

View File

@ -7,7 +7,7 @@ cChunkData cChunkData::Copy() const
cChunkData 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] == NULL)
{ {
copy.m_Sections[i] = Allocate(); copy.m_Sections[i] = Allocate();
*copy.m_Sections[i] = *m_Sections[i]; *copy.m_Sections[i] = *m_Sections[i];
@ -30,7 +30,7 @@ void cChunkData::CopyBlocks (BLOCKTYPE * a_dest, size_t a_Idx, size_t length)
{ {
size_t tocopy = length > segment_length ? segment_length : length; size_t tocopy = length > segment_length ? segment_length : length;
length -= tocopy; length -= tocopy;
if(m_Sections[i]) if(m_Sections[i] == NULL)
{ {
memcpy( memcpy(
&a_dest[i * segment_length], &a_dest[i * segment_length],
@ -59,7 +59,7 @@ 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++)
{ {
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
if(m_Sections[i]) if(m_Sections[i] == NULL)
{ {
memcpy( memcpy(
&a_dest[i * segment_length], &a_dest[i * segment_length],
@ -86,7 +86,7 @@ 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++)
{ {
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
if(m_Sections[i]) if(m_Sections[i] == NULL)
{ {
memcpy( memcpy(
&a_dest[i * segment_length], &a_dest[i * segment_length],
@ -114,7 +114,7 @@ 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++)
{ {
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
if(m_Sections[i]) if(m_Sections[i] == NULL)
{ {
memcpy( memcpy(
&a_dest[i * segment_length], &a_dest[i * segment_length],
@ -142,7 +142,7 @@ 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++)
{ {
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16; const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16;
if (m_Sections[i]) if (m_Sections[i] == NULL)
{ {
memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length); memcpy(&m_Sections[i]->m_BlockTypes, &a_src[i * segment_length], sizeof(BLOCKTYPE) * segment_length);
} }
@ -180,7 +180,7 @@ 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++)
{ {
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
if (m_Sections[i]) if (m_Sections[i] == NULL)
{ {
memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); memcpy(&m_Sections[i]->m_BlockMeta, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length);
} }
@ -219,7 +219,7 @@ void cChunkData::SetLight(const NIBBLETYPE * a_src)
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
if (m_Sections[i]) if (m_Sections[i] == NULL)
{ {
memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); memcpy(&m_Sections[i]->m_BlockLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length);
} }
@ -258,7 +258,7 @@ void cChunkData::SetSkyLight (const NIBBLETYPE * a_src)
for (size_t i = 0; i < CHUNK_SECTION_NUM; i++) for (size_t i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2; const size_t segment_length = CHUNK_SECTION_HEIGHT * 16 * 16 / 2;
if (m_Sections[i]) if (m_Sections[i] == NULL)
{ {
memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length); memcpy(&m_Sections[i]->m_BlockSkyLight, &a_src[i * segment_length], sizeof(NIBBLETYPE) * segment_length);
} }

View File

@ -37,7 +37,7 @@ public:
#endif #endif
for (int i = 0; i < CHUNK_SECTION_NUM; i++) for (int i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
if(m_Sections[i]) Free(m_Sections[i]);; if(m_Sections[i] == NULL) Free(m_Sections[i]);;
} }
} }
@ -91,7 +91,7 @@ public:
{ {
for (int i = 0; i < CHUNK_SECTION_NUM; i++) for (int i = 0; i < CHUNK_SECTION_NUM; i++)
{ {
if(m_Sections[i]) Free(m_Sections[i]);; Free(m_Sections[i]);;
m_Sections[i] = other.m_Sections[i]; m_Sections[i] = other.m_Sections[i];
other.m_Sections[i] = 0; other.m_Sections[i] = 0;
} }
@ -106,7 +106,7 @@ public:
ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height)); ASSERT((a_Y >= 0) && (a_Y < cChunkDef::Height));
ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width)); ASSERT((a_Z >= 0) && (a_Z < cChunkDef::Width));
int Section = a_Y / CHUNK_SECTION_HEIGHT; int Section = a_Y / CHUNK_SECTION_HEIGHT;
if(m_Sections[Section]) if(m_Sections[Section] == NULL)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z); int Index = cChunkDef::MakeIndexNoCheck(a_X, a_Y - (Section * CHUNK_SECTION_HEIGHT), a_Z);
return m_Sections[Section]->m_BlockTypes[Index]; return m_Sections[Section]->m_BlockTypes[Index];
@ -130,14 +130,14 @@ public:
} }
int Section = a_RelY / CHUNK_SECTION_HEIGHT; int Section = a_RelY / CHUNK_SECTION_HEIGHT;
if(!m_Sections[Section]) if(m_Sections[Section] != NULL)
{ {
if(a_Block == 0x00) if(a_Block == 0x00)
{ {
return; return;
} }
m_Sections[Section] = Allocate(); m_Sections[Section] = Allocate();
if(!m_Sections[Section]) if(m_Sections[Section] != NULL)
{ {
ASSERT(!"Failed to allocate a new section in Chunkbuffer"); ASSERT(!"Failed to allocate a new section in Chunkbuffer");
return; return;
@ -153,7 +153,7 @@ public:
if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
{ {
int Section = a_RelY / CHUNK_SECTION_HEIGHT; int Section = a_RelY / CHUNK_SECTION_HEIGHT;
if(m_Sections[Section]) if(m_Sections[Section] == NULL)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ);
return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f; return (m_Sections[Section]->m_BlockMeta[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
@ -180,14 +180,14 @@ public:
} }
int Section = a_RelY / CHUNK_SECTION_HEIGHT; int Section = a_RelY / CHUNK_SECTION_HEIGHT;
if(!m_Sections[Section]) if(m_Sections[Section] != NULL)
{ {
if((a_Nibble & 0xf) == 0x00) if((a_Nibble & 0xf) == 0x00)
{ {
return; return;
} }
m_Sections[Section] = Allocate(); m_Sections[Section] = Allocate();
if(!m_Sections[Section]) if(m_Sections[Section] != NULL)
{ {
ASSERT(!"Failed to allocate a new section in Chunkbuffer"); ASSERT(!"Failed to allocate a new section in Chunkbuffer");
return; return;
@ -206,7 +206,7 @@ public:
if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
{ {
int Section = a_RelY / CHUNK_SECTION_HEIGHT; int Section = a_RelY / CHUNK_SECTION_HEIGHT;
if(m_Sections[Section]) if(m_Sections[Section] == NULL)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ);
return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;
@ -225,7 +225,7 @@ public:
if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1)) if ((a_RelX < cChunkDef::Width) && (a_RelX > -1) && (a_RelY < cChunkDef::Height) && (a_RelY > -1) && (a_RelZ < cChunkDef::Width) && (a_RelZ > -1))
{ {
int Section = a_RelY / CHUNK_SECTION_HEIGHT; int Section = a_RelY / CHUNK_SECTION_HEIGHT;
if(m_Sections[Section]) if(m_Sections[Section] == NULL)
{ {
int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ); int Index = cChunkDef::MakeIndexNoCheck(a_RelX, a_RelY - (Section * CHUNK_SECTION_HEIGHT), a_RelZ);
return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f; return (m_Sections[Section]->m_BlockLight[Index / 2] >> ((Index & 1) * 4)) & 0x0f;