summaryrefslogtreecommitdiffstats
path: root/source/cChunk.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'source/cChunk.cpp')
-rw-r--r--source/cChunk.cpp113
1 files changed, 8 insertions, 105 deletions
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index a5f3943f7..fae2c2507 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -435,108 +435,6 @@ void cChunk::CreateBlockEntities()
m_pState->BlockListCriticalSection.Unlock();
}
-char cChunk::GetLight(char* a_Buffer, int a_BlockIdx)
-{
- if( a_BlockIdx > -1 && a_BlockIdx < c_NumBlocks )
- {
- const int cindex = (a_BlockIdx/2);
- if( (a_BlockIdx & 1) == 0 )
- { // First half byte
- return (a_Buffer[cindex] & 0x0f);
- }
- else
- {
- return ((a_Buffer[cindex] & 0xf0) >> 4);
- }
- }
- return 0;
-}
-
-char cChunk::GetLight(char* a_Buffer, int x, int y, int z)
-{
- if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 )
- {
- const int cindex = (y/2) + (z * 64) + (x * 64 * 16);
- if( (y & 1) == 0 )
- { // First half byte
- return (a_Buffer[cindex] & 0x0f);
- }
- else
- {
- return ((a_Buffer[cindex] & 0xf0) >> 4);
- }
- }
- return 0;
-}
-
-void cChunk::SetLight(char* a_Buffer, int a_BlockIdx, char a_Light)
-{
- if( a_BlockIdx > -1 && a_BlockIdx < c_NumBlocks )
- {
- const int cindex = (a_BlockIdx/2);
- if( (a_BlockIdx & 1) == 0 )
- { // First half byte
- a_Buffer[cindex] &= 0xf0; // Set first half to 0
- a_Buffer[cindex] |= (a_Light) & 0x0f;
- }
- else
- {
- a_Buffer[cindex] &= 0x0f; // Set second half to 0
- a_Buffer[cindex] |= (a_Light << 4) & 0xf0;
- }
- }
-}
-
-void cChunk::SetLight(char* a_Buffer, int x, int y, int z, char light)
-{
- if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 )
- {
- int cindex = (y/2) + (z * 64) + (x * 64 * 16);
- if( (y & 1) == 0 )
- { // First half byte
- a_Buffer[cindex] &= 0xf0; // Set first half to 0
- a_Buffer[cindex] |= (light) & 0x0f;
- }
- else
- {
- a_Buffer[cindex] &= 0x0f; // Set second half to 0
- a_Buffer[cindex] |= (light << 4) & 0xf0;
- }
- }
-}
-
-inline void cChunk::SpreadLightOfBlock(char* a_LightBuffer, int a_X, int a_Y, int a_Z, char a_Falloff)
-{
- unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
- SetLight( a_LightBuffer, a_X-1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X-1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
- SetLight( a_LightBuffer, a_X+1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X+1, a_Y, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
- SetLight( a_LightBuffer, a_X, a_Y-1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y-1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
- SetLight( a_LightBuffer, a_X, a_Y+1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y+1, a_Z ), MAX(0,CurrentLight-a_Falloff) ) );
- SetLight( a_LightBuffer, a_X, a_Y, a_Z-1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z-1 ), MAX(0,CurrentLight-a_Falloff) ) );
- SetLight( a_LightBuffer, a_X, a_Y, a_Z+1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z+1 ), MAX(0,CurrentLight-a_Falloff) ) );
-}
-
-inline void cChunk::SpreadLightOfBlockX(char* a_LightBuffer, int a_X, int a_Y, int a_Z)
-{
- unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
- SetLight( a_LightBuffer, a_X-1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X-1, a_Y, a_Z ), CurrentLight-1) );
- SetLight( a_LightBuffer, a_X+1, a_Y, a_Z, MAX(GetLight( a_LightBuffer, a_X+1, a_Y, a_Z ), CurrentLight-1) );
-}
-
-inline void cChunk::SpreadLightOfBlockY(char* a_LightBuffer, int a_X, int a_Y, int a_Z)
-{
- unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
- SetLight( a_LightBuffer, a_X, a_Y-1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y-1, a_Z ), CurrentLight-1) );
- SetLight( a_LightBuffer, a_X, a_Y+1, a_Z, MAX(GetLight( a_LightBuffer, a_X, a_Y+1, a_Z ), CurrentLight-1) );
-}
-
-inline void cChunk::SpreadLightOfBlockZ(char* a_LightBuffer, int a_X, int a_Y, int a_Z)
-{
- unsigned char CurrentLight = GetLight( a_LightBuffer, a_X, a_Y, a_Z );
- SetLight( a_LightBuffer, a_X, a_Y, a_Z-1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z-1 ), CurrentLight-1) );
- SetLight( a_LightBuffer, a_X, a_Y, a_Z+1, MAX(GetLight( a_LightBuffer, a_X, a_Y, a_Z+1 ), CurrentLight-1) );
-}
-
void cChunk::CalculateHeightmap()
{
m_bCalculateHeightmap = false;
@@ -783,8 +681,8 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
m_pState->BlockListCriticalSection.Unlock();
}
- CalculateHeightmap();
- RecalculateLighting();
+ //RecalculateHeightmap();
+ //RecalculateLighting();
}
void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
@@ -1258,4 +1156,9 @@ void cChunk::PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, i
a_Y = a_ChunkY;
a_X = m_PosX * 16 + a_ChunkX;
a_Z = m_PosZ * 16 + a_ChunkZ;
-} \ No newline at end of file
+}
+
+
+#if !C_CHUNK_USE_INLINE
+# include "cChunk.inc"
+#endif \ No newline at end of file