summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/cChunk.cpp174
-rw-r--r--source/cChunk.h10
-rw-r--r--source/cChunk.inl.h8
-rw-r--r--source/cChunkMap.h12
-rw-r--r--source/cClientHandle.cpp4
-rw-r--r--source/cEntity.cpp2
-rw-r--r--source/cWorld.cpp12
-rw-r--r--source/cWorld.h27
-rw-r--r--source/cWorldGenerator.cpp26
-rw-r--r--source/cWorldGenerator_Test.cpp4
-rw-r--r--source/packets/cPacket_MapChunk.cpp17
11 files changed, 151 insertions, 145 deletions
diff --git a/source/cChunk.cpp b/source/cChunk.cpp
index 0578f3d20..c6813d90b 100644
--- a/source/cChunk.cpp
+++ b/source/cChunk.cpp
@@ -353,9 +353,9 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
for( unsigned int i = 0; i < PendingSendBlocks; i++)
{
unsigned int index = m_PendingSendBlocks[i];
- unsigned int Y = index % 128;
- unsigned int Z = (index / 128) % 16;
- unsigned int X = (index / (128*16));
+ unsigned int Y = index % c_ChunkHeight;
+ unsigned int Z = (index / c_ChunkHeight) % c_ChunkWidth;
+ unsigned int X = (index / (c_ChunkHeight*c_ChunkWidth));
#if (MINECRAFT_1_2_2 == 1)
unsigned int Coords = Y | Z << 8 | X << 12;
@@ -377,14 +377,14 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
for( unsigned int i = 0; i < PendingSendBlocks; i++)
{
unsigned int index = m_PendingSendBlocks[i];
- int Y = index % 128;
- int Z = (index / 128) % 16;
- int X = (index / (128*16));
+ int Y = index % c_ChunkHeight;
+ int Z = (index / c_ChunkHeight) % c_ChunkWidth;
+ int X = (index / (c_ChunkHeight*c_ChunkWidth));
cPacket_BlockChange BlockChange;
- BlockChange.m_PosX = X + m_PosX*16;
- BlockChange.m_PosY = (char)(Y + m_PosY*128);
- BlockChange.m_PosZ = Z + m_PosZ*16;
+ BlockChange.m_PosX = X + m_PosX*c_ChunkWidth;
+ BlockChange.m_PosY = (char)(Y + m_PosY*c_ChunkHeight);
+ BlockChange.m_PosZ = Z + m_PosZ*c_ChunkWidth;
BlockChange.m_BlockType = m_BlockType[index];
BlockChange.m_BlockMeta = GetLight( m_BlockMeta, index );
Broadcast( BlockChange );
@@ -418,9 +418,9 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
for( std::deque< unsigned int >::iterator itr = ToTickBlocks.begin(); itr != ToTickBlocks.end(); ++itr )
{
unsigned int index = (*itr);
- int Y = index % 128;
- int Z = (index / 128) % 16;
- int X = (index / (128*16));
+ int Y = index % c_ChunkHeight;
+ int Z = (index / c_ChunkHeight) % c_ChunkWidth;
+ int X = (index / (c_ChunkHeight*c_ChunkWidth));
char BlockID = GetBlock( index );
switch( BlockID )
@@ -454,9 +454,9 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
m_World->GetSimulatorManager()->WakeUp(wX, wY, wZ);
if (isRedstone) {
cRedstone Redstone(m_World);
- Redstone.ChangeRedstone( (X+m_PosX*16), (Y+m_PosY*16), (Z+m_PosZ*16), false );
+ Redstone.ChangeRedstone( (X+m_PosX*c_ChunkWidth), (Y+m_PosY*c_ChunkWidth), (Z+m_PosZ*c_ChunkWidth), false );
}
- cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( cBlockToPickup::ToPickup( (ENUM_ITEM_ID)BlockID, E_ITEM_EMPTY) , 1 ) );
+ cPickup* Pickup = new cPickup( (X+m_PosX*c_ChunkWidth) * 32 + 16, (Y+m_PosY*c_ChunkHeight) * 32 + 16, (Z+m_PosZ*c_ChunkWidth) * 32 + 16, cItem( cBlockToPickup::ToPickup( (ENUM_ITEM_ID)BlockID, E_ITEM_EMPTY) , 1 ) );
Pickup->Initialize( m_World );
}
}
@@ -468,9 +468,9 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
{
char Dir = cTorch::MetaDataToDirection( GetLight( m_BlockMeta, X, Y, Z ) );
LOG("MetaData: %i", Dir );
- int XX = X + m_PosX*16;
+ int XX = X + m_PosX*c_ChunkWidth;
char YY = (char)Y;
- int ZZ = Z + m_PosZ*16;
+ int ZZ = Z + m_PosZ*c_ChunkWidth;
AddDirection( XX, YY, ZZ, Dir, true );
if( m_World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
{
@@ -481,9 +481,9 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
m_World->GetSimulatorManager()->WakeUp(wPos.x, wPos.y, wPos.z);
if (isRedstone) {
cRedstone Redstone(m_World);
- Redstone.ChangeRedstone( (X+m_PosX*16), (Y+m_PosY*16), (Z+m_PosZ*16), false );
+ Redstone.ChangeRedstone( (X+m_PosX*c_ChunkWidth), (Y+m_PosY*c_ChunkWidth), (Z+m_PosZ*c_ChunkWidth), false );
}
- cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( cBlockToPickup::ToPickup( (ENUM_ITEM_ID)BlockID, E_ITEM_EMPTY) , 1 ) );
+ cPickup* Pickup = new cPickup( (X+m_PosX*c_ChunkWidth) * 32 + 16, (Y+m_PosY*c_ChunkHeight) * 32 + 16, (Z+m_PosZ*c_ChunkWidth) * 32 + 16, cItem( cBlockToPickup::ToPickup( (ENUM_ITEM_ID)BlockID, E_ITEM_EMPTY) , 1 ) );
Pickup->Initialize( m_World );
}
}
@@ -491,14 +491,14 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
case E_BLOCK_LADDER:
{
char Dir = cLadder::MetaDataToDirection( GetLight( m_BlockMeta, X, Y, Z ) );
- int XX = X + m_PosX*16;
+ int XX = X + m_PosX*c_ChunkWidth;
char YY = (char)Y;
- int ZZ = Z + m_PosZ*16;
+ int ZZ = Z + m_PosZ*c_ChunkWidth;
AddDirection( XX, YY, ZZ, Dir, true );
if( m_World->GetBlock( XX, YY, ZZ ) == E_BLOCK_AIR )
{
SetBlock( X, Y, Z, E_BLOCK_AIR, 0 );
- cPickup* Pickup = new cPickup( (X+m_PosX*16) * 32 + 16, (Y+m_PosY*128) * 32 + 16, (Z+m_PosZ*16) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
+ cPickup* Pickup = new cPickup( (X+m_PosX*c_ChunkWidth) * 32 + 16, (Y+m_PosY*c_ChunkHeight) * 32 + 16, (Z+m_PosZ*c_ChunkWidth) * 32 + 16, cItem( (ENUM_ITEM_ID)BlockID, 1 ) );
Pickup->Initialize( m_World );
}
}
@@ -516,13 +516,13 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
for(int i = 0; i < 50; i++)
{
- m_BlockTickX = (m_BlockTickX + RandomX) % 16;
- m_BlockTickY = (m_BlockTickY + RandomY) % 128;
- m_BlockTickZ = (m_BlockTickZ + RandomZ) % 16;
+ m_BlockTickX = (m_BlockTickX + RandomX) % c_ChunkWidth;
+ m_BlockTickY = (m_BlockTickY + RandomY) % c_ChunkHeight;
+ m_BlockTickZ = (m_BlockTickZ + RandomZ) % c_ChunkWidth;
//LOG("%03i %03i %03i", m_BlockTickX, m_BlockTickY, m_BlockTickZ);
- if( m_BlockTickY > m_HeightMap[ m_BlockTickX + m_BlockTickZ*16 ] ) continue; // It's all air up here
+ if( m_BlockTickY > m_HeightMap[ m_BlockTickX + m_BlockTickZ*c_ChunkWidth ] ) continue; // It's all air up here
//m_BlockTickNum = (m_BlockTickNum + 1 ) % c_NumBlocks;
unsigned int Index = MakeIndex( m_BlockTickX, m_BlockTickY, m_BlockTickZ );
@@ -559,7 +559,7 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
case E_BLOCK_SAPLING: //todo: check meta of sapling. change m_World->GrowTree to look change trunk and leaves based on meta of sapling
{
FastSetBlock( m_BlockTickX, m_BlockTickY, m_BlockTickZ, E_BLOCK_AIR, GetLight( m_BlockMeta, Index ) );
- m_World->GrowTree( m_BlockTickX + m_PosX*16, m_BlockTickY, m_BlockTickZ + m_PosZ*16 );
+ m_World->GrowTree( m_BlockTickX + m_PosX*c_ChunkWidth, m_BlockTickY, m_BlockTickZ + m_PosZ*c_ChunkWidth );
}
break;
case E_BLOCK_LEAVES: //todo, http://www.minecraftwiki.net/wiki/Data_values#Leaves
@@ -587,11 +587,11 @@ void cChunk::Tick(float a_Dt, MTRand & a_TickRandom)
int cChunk::GetHeight( int a_X, int a_Z )
{
- ASSERT((a_X >= 0) && (a_X < 16) && (a_Z >= 0) && (a_Z < 16));
+ ASSERT((a_X >= 0) && (a_X < c_ChunkWidth) && (a_Z >= 0) && (a_Z < c_ChunkWidth));
- if ((a_X >= 0) && (a_X < 16) && (a_Z >= 0) && (a_Z < 16))
+ if ((a_X >= 0) && (a_X < c_ChunkWidth) && (a_Z >= 0) && (a_Z < c_ChunkWidth))
{
- return m_HeightMap[a_X + a_Z * 16];
+ return m_HeightMap[a_X + a_Z * c_ChunkWidth];
}
return 0;
}
@@ -602,29 +602,29 @@ int cChunk::GetHeight( int a_X, int a_Z )
void cChunk::CreateBlockEntities(void)
{
- for (int x = 0; x < 16; x++)
+ for (int x = 0; x < c_ChunkWidth; x++)
{
- for (int z = 0; z < 16; z++)
+ for (int z = 0; z < c_ChunkWidth; z++)
{
- for (int y = 0; y < 128; y++)
+ for (int y = 0; y < c_ChunkHeight; y++)
{
ENUM_BLOCK_ID BlockType = (ENUM_BLOCK_ID)m_BlockData[ MakeIndex( x, y, z ) ];
switch ( BlockType )
{
case E_BLOCK_CHEST:
{
- if (!HasBlockEntityAt(x + m_PosX * 16, y + m_PosY * 128, z + m_PosZ * 16))
+ if (!HasBlockEntityAt(x + m_PosX * c_ChunkWidth, y + m_PosY * c_ChunkHeight, z + m_PosZ * c_ChunkWidth))
{
- m_BlockEntities.push_back( new cChestEntity( x + m_PosX * 16, y + m_PosY * 128, z + m_PosZ * 16, m_World) );
+ m_BlockEntities.push_back( new cChestEntity( x + m_PosX * c_ChunkWidth, y + m_PosY * c_ChunkHeight, z + m_PosZ * c_ChunkWidth, m_World) );
}
break;
}
case E_BLOCK_FURNACE:
{
- if (!HasBlockEntityAt(x + m_PosX * 16, y + m_PosY * 128, z + m_PosZ * 16))
+ if (!HasBlockEntityAt(x + m_PosX * c_ChunkWidth, y + m_PosY * c_ChunkHeight, z + m_PosZ * c_ChunkWidth))
{
- m_BlockEntities.push_back( new cFurnaceEntity( x + m_PosX * 16, y + m_PosY * 128, z + m_PosZ * 16, m_World) );
+ m_BlockEntities.push_back( new cFurnaceEntity( x + m_PosX * c_ChunkWidth, y + m_PosY * c_ChunkHeight, z + m_PosZ * c_ChunkWidth, m_World) );
}
break;
}
@@ -632,9 +632,9 @@ void cChunk::CreateBlockEntities(void)
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN:
{
- if (!HasBlockEntityAt(x + m_PosX * 16, y + m_PosY * 128, z + m_PosZ * 16))
+ if (!HasBlockEntityAt(x + m_PosX * c_ChunkWidth, y + m_PosY * c_ChunkHeight, z + m_PosZ * c_ChunkWidth))
{
- m_BlockEntities.push_back( new cSignEntity( BlockType, x + m_PosX * 16, y + m_PosY * 128, z + m_PosZ * 16, m_World) );
+ m_BlockEntities.push_back( new cSignEntity( BlockType, x + m_PosX * c_ChunkWidth, y + m_PosY * c_ChunkHeight, z + m_PosZ * c_ChunkWidth, m_World) );
}
break;
}
@@ -650,16 +650,16 @@ void cChunk::CreateBlockEntities(void)
void cChunk::CalculateHeightmap()
{
- for (int x = 0; x < 16; x++)
+ for (int x = 0; x < c_ChunkWidth; x++)
{
- for (int z = 0; z < 16; z++)
+ for (int z = 0; z < c_ChunkWidth; z++)
{
- for (int y = 127; y > -1; y--)
+ for (int y = c_ChunkHeight-1; y > -1; y--)
{
int index = MakeIndex( x, y, z );
if (m_BlockData[index] != E_BLOCK_AIR)
{
- m_HeightMap[x + z * 16] = (char)y;
+ m_HeightMap[x + z * c_ChunkWidth] = (char)y;
break;
}
} // for y
@@ -675,14 +675,14 @@ void cChunk::CalculateLighting()
{
// Calculate sunlight
memset(m_BlockSkyLight, 0xff, c_NumBlocks / 2 ); // Set all to fully lit, so everything above HeightMap is lit
- for(int x = 0; x < 16; x++)
+ for(int x = 0; x < c_ChunkWidth; x++)
{
- for(int z = 0; z < 16; z++)
+ for(int z = 0; z < c_ChunkWidth; z++)
{
char sunlight = 0xf;
- for(int y = m_HeightMap[x + z*16]; y > -1; y--)
+ for(int y = m_HeightMap[x + z*c_ChunkWidth]; y > -1; y--)
{
- int index = y + (z * 128) + (x * 128 * 16);
+ int index = y + (z * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth);
if( g_BlockTransparent[ (int)m_BlockData[index] ] == false )
{
@@ -694,11 +694,11 @@ void cChunk::CalculateLighting()
}
// Calculate blocklights
- for(int x = 0; x < 16; x++)
+ for(int x = 0; x < c_ChunkWidth; x++)
{
- for(int z = 0; z < 16; z++)
+ for(int z = 0; z < c_ChunkWidth; z++)
{
- int MaxHeight = m_HeightMap[x + z*16];
+ int MaxHeight = m_HeightMap[x + z*c_ChunkWidth];
for(int y = 0; y < MaxHeight; y++)
{
char BlockID = GetBlock(x, y, z);
@@ -721,18 +721,18 @@ void cChunk::CalculateLighting()
void cChunk::SpreadLight(char* a_LightBuffer)
{
// Spread the sunlight
- for(int x = 0; x < 16; x++) for(int z = 0; z < 16; z++) for(int y = 0; y < 128; y++)
+ for(int x = 0; x < c_ChunkWidth; x++) for(int z = 0; z < c_ChunkWidth; z++) for(int y = 0; y < c_ChunkHeight; y++)
{
- int index = y + (z * 128) + (x * 128 * 16);
+ int index = y + (z * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth);
if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
{
SpreadLightOfBlock(a_LightBuffer, x, y, z, g_BlockSpreadLightFalloff[ m_BlockData[index] ]);
}
}
- for(int x = 15; x > -1; x--) for(int z = 15; z > -1; z--) for(int y = 127; y > -1; y--)
+ for(int x = c_ChunkWidth-1; x > -1; x--) for(int z = c_ChunkWidth-1; z > -1; z--) for(int y = c_ChunkHeight-1; y > -1; y--)
{
- int index = y + (z * 128) + (x * 128 * 16);
+ int index = y + (z * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth);
if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
{
SpreadLightOfBlock(a_LightBuffer, x, y, z, g_BlockSpreadLightFalloff[ m_BlockData[index] ]);
@@ -755,28 +755,28 @@ void cChunk::SpreadLight(char* a_LightBuffer)
RightSky = (a_LightBuffer == m_BlockSkyLight) ? RightChunk->pGetSkyLight() : RightChunk->pGetLight();
}
- for (int z = 0; z < 16; z++) for(int y = 0; y < 128; y++)
+ for (int z = 0; z < c_ChunkWidth; z++) for(int y = 0; y < c_ChunkHeight; y++)
{
if (LeftSky != NULL)
{
- int index = y + (z * 128) + (0 * 128 * 16);
+ int index = y + (z * c_ChunkHeight) + (0 * c_ChunkHeight * c_ChunkWidth);
if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
{
char CurrentLight = GetLight( a_LightBuffer, 0, y, z );
- char LeftLight = GetLight( LeftSky, 15, y, z );
+ char LeftLight = GetLight( LeftSky, c_ChunkWidth-1, y, z );
if( LeftLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
{
- SetLight( LeftSky, 15, y, z, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
+ SetLight( LeftSky, c_ChunkWidth-1, y, z, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
bCalcLeft = true;
}
}
}
if (RightSky != NULL)
{
- int index = y + (z * 128) + (15 * 128 * 16);
+ int index = y + (z * c_ChunkHeight) + ((c_ChunkWidth-1) * c_ChunkHeight * c_ChunkWidth);
if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
{
- char CurrentLight = GetLight( a_LightBuffer, 15, y, z );
+ char CurrentLight = GetLight( a_LightBuffer, c_ChunkWidth-1, y, z );
char RightLight = GetLight( RightSky, 0, y, z );
if( RightLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
{
@@ -799,28 +799,28 @@ void cChunk::SpreadLight(char* a_LightBuffer)
{
BackSky = (a_LightBuffer == m_BlockSkyLight) ? BackChunk->pGetSkyLight() : BackChunk->pGetLight();
}
- for(int x = 0; x < 16; x++) for(int y = 0; y < 128; y++)
+ for(int x = 0; x < c_ChunkWidth; x++) for(int y = 0; y < c_ChunkHeight; y++)
{
if (FrontSky != NULL)
{
- int index = y + (0 * 128) + (x * 128 * 16);
+ int index = y + (0 * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth);
if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
{
char CurrentLight = GetLight( a_LightBuffer, x, y, 0 );
- char FrontLight = GetLight( FrontSky, x, y, 15 );
+ char FrontLight = GetLight( FrontSky, x, y, c_ChunkWidth-1 );
if( FrontLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
{
- SetLight( FrontSky, x, y, 15, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
+ SetLight( FrontSky, x, y, c_ChunkWidth-1, MAX(0, CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ]) );
bCalcFront = true;
}
}
}
if (BackSky != NULL)
{
- int index = y + (15 * 128) + (x * 128 * 16);
+ int index = y + ((c_ChunkWidth-1) * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth);
if( g_BlockSpreadLightFalloff[ m_BlockData[index] ] > 0 )
{
- char CurrentLight = GetLight( a_LightBuffer, x, y, 15 );
+ char CurrentLight = GetLight( a_LightBuffer, x, y, c_ChunkWidth-1 );
char BackLight = GetLight( BackSky, x, y, 0 );
if ( BackLight < CurrentLight-g_BlockSpreadLightFalloff[ m_BlockData[index] ] )
{
@@ -863,14 +863,14 @@ void cChunk::SendTo(cClientHandle* a_Client)
void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta )
{
- if (a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16)
+ if (a_X < 0 || a_X >= c_ChunkWidth || a_Y < 0 || a_Y >= c_ChunkHeight || a_Z < 0 || a_Z >= c_ChunkWidth)
{
return; // Clip
}
ASSERT(IsValid()); // Is this chunk loaded / generated?
- int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
+ int index = a_Y + (a_Z * c_ChunkHeight) + (a_X * c_ChunkHeight * c_ChunkWidth);
char OldBlockMeta = GetLight( m_BlockMeta, index );
char OldBlockType = m_BlockType[index];
m_BlockType[index] = a_BlockType;
@@ -901,11 +901,11 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
}
// Update heightmap, if needed:
- if (a_Y >= m_HeightMap[a_X + a_Z * 16])
+ if (a_Y >= m_HeightMap[a_X + a_Z * c_ChunkWidth])
{
if (a_BlockType != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * 16] = a_Y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = a_Y;
}
else
{
@@ -913,7 +913,7 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
{
if (m_BlockData[MakeIndex(a_X, y, a_Z)] != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * 16] = y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = y;
break;
}
} // for y - column in m_BlockData
@@ -928,7 +928,7 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
m_ToTickBlocks.push_back( MakeIndex( a_X, a_Y, a_Z+1 ) );
m_ToTickBlocks.push_back( MakeIndex( a_X, a_Y, a_Z-1 ) );
- cBlockEntity* BlockEntity = GetBlockEntity( a_X + m_PosX * 16, a_Y + m_PosY * 128, a_Z + m_PosZ * 16 );
+ cBlockEntity* BlockEntity = GetBlockEntity( a_X + m_PosX * c_ChunkWidth, a_Y + m_PosY * c_ChunkHeight, a_Z + m_PosZ * c_ChunkWidth );
if( BlockEntity )
{
BlockEntity->Destroy();
@@ -939,18 +939,18 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
{
case E_BLOCK_CHEST:
{
- AddBlockEntity( new cChestEntity( a_X + m_PosX * 16, a_Y + m_PosY * 128, a_Z + m_PosZ * 16, m_World) );
+ AddBlockEntity( new cChestEntity( a_X + m_PosX * c_ChunkWidth, a_Y + m_PosY * c_ChunkHeight, a_Z + m_PosZ * c_ChunkWidth, m_World) );
break;
}
case E_BLOCK_FURNACE:
{
- AddBlockEntity( new cFurnaceEntity( a_X + m_PosX * 16, a_Y + m_PosY * 128, a_Z + m_PosZ * 16, m_World) );
+ AddBlockEntity( new cFurnaceEntity( a_X + m_PosX * c_ChunkWidth, a_Y + m_PosY * c_ChunkHeight, a_Z + m_PosZ * c_ChunkWidth, m_World) );
break;
}
case E_BLOCK_SIGN_POST:
case E_BLOCK_WALLSIGN:
{
- AddBlockEntity( new cSignEntity( (ENUM_BLOCK_ID)a_BlockType, a_X + m_PosX * 16, a_Y + m_PosY * 128, a_Z + m_PosZ * 16, m_World) );
+ AddBlockEntity( new cSignEntity( (ENUM_BLOCK_ID)a_BlockType, a_X + m_PosX * c_ChunkWidth, a_Y + m_PosY * c_ChunkHeight, a_Z + m_PosZ * c_ChunkWidth, m_World) );
break;
}
} // switch (a_BlockType)
@@ -962,11 +962,11 @@ void cChunk::SetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_Block
void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_BlockMeta)
{
- ASSERT(!((a_X < 0 || a_X >= 16 || a_Y < 0 || a_Y >= 128 || a_Z < 0 || a_Z >= 16)));
+ ASSERT(!((a_X < 0 || a_X >= c_ChunkWidth || a_Y < 0 || a_Y >= c_ChunkHeight || a_Z < 0 || a_Z >= c_ChunkWidth)));
ASSERT(IsValid());
- const int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
+ const int index = a_Y + (a_Z * c_ChunkHeight) + (a_X * c_ChunkHeight * c_ChunkWidth);
const char OldBlock = m_BlockType[index];
const char OldBlockMeta = GetLight( m_BlockMeta, index );
if (OldBlock == a_BlockType && OldBlockMeta == a_BlockMeta)
@@ -997,11 +997,11 @@ void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B
}
// Update heightmap, if needed:
- if (a_Y >= m_HeightMap[a_X + a_Z * 16])
+ if (a_Y >= m_HeightMap[a_X + a_Z * c_ChunkWidth])
{
if (a_BlockType != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * 16] = a_Y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = a_Y;
}
else
{
@@ -1009,7 +1009,7 @@ void cChunk::FastSetBlock( int a_X, int a_Y, int a_Z, char a_BlockType, char a_B
{
if (m_BlockData[MakeIndex(a_X, y, a_Z)] != E_BLOCK_AIR)
{
- m_HeightMap[a_X + a_Z * 16] = y;
+ m_HeightMap[a_X + a_Z * c_ChunkWidth] = y;
break;
}
} // for y - column in m_BlockData
@@ -1036,9 +1036,9 @@ void cChunk::SendBlockTo( int a_X, int a_Y, int a_Z, cClientHandle* a_Client )
{
unsigned int index = MakeIndex( a_X, a_Y, a_Z );
cPacket_BlockChange BlockChange;
- BlockChange.m_PosX = a_X + m_PosX*16;
- BlockChange.m_PosY = (char)(a_Y + m_PosY*128);
- BlockChange.m_PosZ = a_Z + m_PosZ*16;
+ BlockChange.m_PosX = a_X + m_PosX*c_ChunkWidth;
+ BlockChange.m_PosY = (char)(a_Y + m_PosY*c_ChunkHeight);
+ BlockChange.m_PosZ = a_Z + m_PosZ*c_ChunkWidth;
BlockChange.m_BlockType = m_BlockType[ index ];
BlockChange.m_BlockMeta = GetLight( m_BlockMeta, index );
a_Client->Send( BlockChange );
@@ -1264,9 +1264,9 @@ void cChunk::RemoveEntity(cEntity * a_Entity)
char cChunk::GetBlock( int a_X, int a_Y, int a_Z )
{
- if ((a_X < 0) || (a_X >= 16) || (a_Y < 0) || (a_Y >= 128) || (a_Z < 0) || (a_Z >= 16)) return 0; // Clip
+ if ((a_X < 0) || (a_X >= c_ChunkWidth) || (a_Y < 0) || (a_Y >= c_ChunkHeight) || (a_Z < 0) || (a_Z >= c_ChunkWidth)) return 0; // Clip
- int index = a_Y + (a_Z * 128) + (a_X * 128 * 16);
+ int index = a_Y + (a_Z * c_ChunkHeight) + (a_X * c_ChunkHeight * c_ChunkWidth);
return m_BlockType[index];
}
@@ -1407,8 +1407,8 @@ void cChunk::CopyBlockDataFrom(const char * a_NewBlockData)
void cChunk::PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, int & a_X, int & a_Y, int & a_Z)
{
a_Y = a_ChunkY;
- a_X = m_PosX * 16 + a_ChunkX;
- a_Z = m_PosZ * 16 + a_ChunkZ;
+ a_X = m_PosX * c_ChunkWidth + a_ChunkX;
+ a_Z = m_PosZ * c_ChunkWidth + a_ChunkZ;
}
@@ -1417,7 +1417,7 @@ void cChunk::PositionToWorldPosition(int a_ChunkX, int a_ChunkY, int a_ChunkZ, i
Vector3i cChunk::PositionToWorldPosition( const Vector3i & a_InChunkPos )
{
- return Vector3i( m_PosX * 16 + a_InChunkPos.x, a_InChunkPos.y, m_PosZ * 16 + a_InChunkPos.z );
+ return Vector3i( m_PosX * c_ChunkWidth + a_InChunkPos.x, m_PosY * c_ChunkHeight + a_InChunkPos.y, m_PosZ * c_ChunkWidth + a_InChunkPos.z );
}
diff --git a/source/cChunk.h b/source/cChunk.h
index 7e1a8493d..cbf3b3b85 100644
--- a/source/cChunk.h
+++ b/source/cChunk.h
@@ -112,7 +112,9 @@ typedef std::list< sSetBlock > sSetBlockList;
class cChunk
{
public:
- static const int c_NumBlocks = 16 * 128 * 16;
+ static const int c_ChunkWidth = 16;
+ static const int c_ChunkHeight = 128;
+ static const int c_NumBlocks = c_ChunkWidth * c_ChunkHeight * c_ChunkWidth;
static const int c_BlockDataSize = c_NumBlocks * 2 + (c_NumBlocks/2); // 2.5 * numblocks
cChunk(int a_X, int a_Y, int a_Z, cChunkMap * a_ChunkMap, cWorld * a_World);
@@ -214,9 +216,9 @@ public:
inline static unsigned int MakeIndex(int x, int y, int z )
{
- if( x < 16 && x > -1 && y < 128 && y > -1 && z < 16 && z > -1 )
+ if( x < c_ChunkWidth && x > -1 && y < c_ChunkHeight && y > -1 && z < c_ChunkWidth && z > -1 )
{
- return y + (z * 128) + (x * 128 * 16);
+ return y + (z * c_ChunkHeight) + (x * c_ChunkHeight * c_ChunkWidth);
}
return 0;
}
@@ -261,7 +263,7 @@ private:
char *m_BlockLight; // += NumBlocks/2
char *m_BlockSkyLight; // += NumBlocks/2
- unsigned char m_HeightMap[16 * 16];
+ unsigned char m_HeightMap[c_ChunkWidth * c_ChunkWidth];
unsigned int m_BlockTickNum;
unsigned int m_BlockTickX, m_BlockTickY, m_BlockTickZ;
diff --git a/source/cChunk.inl.h b/source/cChunk.inl.h
index 36a116e75..36643a87c 100644
--- a/source/cChunk.inl.h
+++ b/source/cChunk.inl.h
@@ -35,9 +35,9 @@ char cChunk::GetLight(char* a_Buffer, int a_BlockIdx)
__C_CHUNK_INLINE__
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 )
+ if( x < c_ChunkWidth && x > -1 && y < c_ChunkHeight && y > -1 && z < c_ChunkWidth && z > -1 )
{
- const int cindex = (y/2) + (z * 64) + (x * 64 * 16);
+ const int cindex = (y/2) + (z * (c_ChunkHeight/2)) + (x * (c_ChunkHeight/2) * c_ChunkWidth);
if( (y & 1) == 0 )
{ // First half byte
return (a_Buffer[cindex] & 0x0f);
@@ -81,9 +81,9 @@ void cChunk::SetLight(char* a_Buffer, int a_BlockIdx, char a_Light)
__C_CHUNK_INLINE__
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 )
+ if( x < c_ChunkWidth && x > -1 && y < c_ChunkHeight && y > -1 && z < c_ChunkWidth && z > -1 )
{
- int cindex = (y/2) + (z * 64) + (x * 64 * 16);
+ int cindex = (y/2) + (z * (c_ChunkHeight/2)) + (x * (c_ChunkHeight/2) * c_ChunkWidth);
if( (y & 1) == 0 )
{ // First half byte
a_Buffer[cindex] &= 0xf0; // Set first half to 0
diff --git a/source/cChunkMap.h b/source/cChunkMap.h
index a4593529b..32ae4da6e 100644
--- a/source/cChunkMap.h
+++ b/source/cChunkMap.h
@@ -111,21 +111,21 @@ public:
{
BlockToChunk(a_X, a_Y, a_Z, a_ChunkX, a_ChunkZ);
- a_X = a_X - a_ChunkX * 16;
- a_Z = a_Z - a_ChunkZ * 16;
+ a_X = a_X - a_ChunkX * cChunk::c_ChunkWidth;
+ a_Z = a_Z - a_ChunkZ * cChunk::c_ChunkWidth;
}
/// Converts absolute block coords to chunk coords:
inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkZ )
{
(void)a_Y;
- a_ChunkX = a_X / 16;
- if ((a_X < 0) && (a_X % 16 != 0))
+ a_ChunkX = a_X / cChunk::c_ChunkWidth;
+ if ((a_X < 0) && (a_X % cChunk::c_ChunkWidth != 0))
{
a_ChunkX--;
}
- a_ChunkZ = a_Z / 16;
- if ((a_Z < 0) && (a_Z % 16 != 0))
+ a_ChunkZ = a_Z / cChunk::c_ChunkWidth;
+ if ((a_Z < 0) && (a_Z % cChunk::c_ChunkWidth != 0))
{
a_ChunkZ--;
}
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 1c318d463..9f054aec2 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -339,8 +339,8 @@ void cClientHandle::StreamChunks(void)
ASSERT(m_Player != NULL);
- int ChunkPosX = FAST_FLOOR_DIV(m_Player->GetPosX(), 16);
- int ChunkPosZ = FAST_FLOOR_DIV(m_Player->GetPosZ(), 16);
+ int ChunkPosX = FAST_FLOOR_DIV(m_Player->GetPosX(), cChunk::c_ChunkWidth);
+ int ChunkPosZ = FAST_FLOOR_DIV(m_Player->GetPosZ(), cChunk::c_ChunkWidth);
if ((ChunkPosX == m_LastStreamedChunkX) && (ChunkPosZ == m_LastStreamedChunkZ))
{
// Already streamed for this position
diff --git a/source/cEntity.cpp b/source/cEntity.cpp
index 3df995d59..d75c35002 100644
--- a/source/cEntity.cpp
+++ b/source/cEntity.cpp
@@ -54,7 +54,7 @@ cEntity::~cEntity()
LOG("Deleting entity %d at pos {%.2f, %.2f} ~ [%d, %d]; ptr %p",
m_UniqueID,
m_Pos.x, m_Pos.z,
- (int)(m_Pos.x / 16), (int)(m_Pos.z / 16),
+ (int)(m_Pos.x / cChunk::c_ChunkWidth), (int)(m_Pos.z / cChunk::c_ChunkWidth),
this
);
diff --git a/source/cWorld.cpp b/source/cWorld.cpp
index 608477d71..2b0f4ab2b 100644
--- a/source/cWorld.cpp
+++ b/source/cWorld.cpp
@@ -188,7 +188,7 @@ cWorld::cWorld( const AString & a_WorldName )
MTRand r1;
m_SpawnX = (double)((r1.randInt()%1000)-500);
- m_SpawnY = 128;
+ m_SpawnY = cChunk::c_ChunkHeight;
m_SpawnZ = (double)((r1.randInt()%1000)-500);
m_WorldSeed = r1.randInt();
m_GameMode = 0;
@@ -259,11 +259,11 @@ cWorld::cWorld( const AString & a_WorldName )
m_SimulatorManager->RegisterSimulator(m_FireSimulator, 10);
m_SimulatorManager->RegisterSimulator(m_RedstoneSimulator, 1);
- memset( g_BlockLightValue, 0x0, 128 );
- memset( g_BlockSpreadLightFalloff, 0xf, 128 ); // 0xf means total falloff
- memset( g_BlockTransparent, 0x0, 128 );
- memset( g_BlockOneHitDig, 0x0, 128 );
- memset( g_BlockPistonBreakable, 0x0, 128 );
+ memset( g_BlockLightValue, 0x0, ARRAYSIZE( g_BlockLightValue ) );
+ memset( g_BlockSpreadLightFalloff, 0xf, ARRAYSIZE( g_BlockSpreadLightFalloff ) ); // 0xf means total falloff
+ memset( g_BlockTransparent, 0x0, ARRAYSIZE( g_BlockTransparent ) );
+ memset( g_BlockOneHitDig, 0x0, ARRAYSIZE( g_BlockOneHitDig ) );
+ memset( g_BlockPistonBreakable, 0x0, ARRAYSIZE( g_BlockPistonBreakable ) );
// Emissive blocks
g_BlockLightValue[ E_BLOCK_TORCH ] = 14;
diff --git a/source/cWorld.h b/source/cWorld.h
index 3b8f7b059..60b393ab8 100644
--- a/source/cWorld.h
+++ b/source/cWorld.h
@@ -179,26 +179,29 @@ public:
inline static void AbsoluteToRelative( int & a_X, int & a_Y, int & a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
{
- (void)a_Y; // not unused anymore
- a_ChunkX = a_X/16;
- if(a_X < 0 && a_X % 16 != 0) a_ChunkX--;
+ // TODO: Use floor() instead of weird if statements
+ // Also fix Y
+ a_ChunkX = a_X/cChunk::c_ChunkWidth;
+ if(a_X < 0 && a_X % cChunk::c_ChunkWidth != 0) a_ChunkX--;
a_ChunkY = 0;
- a_ChunkZ = a_Z/16;
- if(a_Z < 0 && a_Z % 16 != 0) a_ChunkZ--;
+ a_ChunkZ = a_Z/cChunk::c_ChunkWidth;
+ if(a_Z < 0 && a_Z % cChunk::c_ChunkWidth != 0) a_ChunkZ--;
- a_X = a_X - a_ChunkX*16;
- //a_Y = a_Y - a_ChunkY*16;
- a_Z = a_Z - a_ChunkZ*16;
+ a_X = a_X - a_ChunkX*cChunk::c_ChunkWidth;
+ a_Y = a_Y - a_ChunkY*cChunk::c_ChunkHeight;
+ a_Z = a_Z - a_ChunkZ*cChunk::c_ChunkWidth;
}
inline static void BlockToChunk( int a_X, int a_Y, int a_Z, int & a_ChunkX, int & a_ChunkY, int & a_ChunkZ )
{
+ // TODO: Use floor() instead of weird if statements
+ // Also fix Y
(void)a_Y; // not unused anymore
- a_ChunkX = a_X/16;
- if(a_X < 0 && a_X % 16 != 0) a_ChunkX--;
+ a_ChunkX = a_X/cChunk::c_ChunkWidth;
+ if(a_X < 0 && a_X % cChunk::c_ChunkWidth != 0) a_ChunkX--;
a_ChunkY = 0;
- a_ChunkZ = a_Z/16;
- if(a_Z < 0 && a_Z % 16 != 0) a_ChunkZ--;
+ a_ChunkZ = a_Z/cChunk::c_ChunkWidth;
+ if(a_Z < 0 && a_Z % cChunk::c_ChunkWidth != 0) a_ChunkZ--;
}
void SaveAllChunks(); //tolua_export
diff --git a/source/cWorldGenerator.cpp b/source/cWorldGenerator.cpp
index a0c670eae..2dfd3a8ee 100644
--- a/source/cWorldGenerator.cpp
+++ b/source/cWorldGenerator.cpp
@@ -199,9 +199,9 @@ static float GetOreNoise( float x, float y, float z, cNoise & a_Noise )
unsigned int cWorldGenerator::MakeIndex(int x, int y, int z )
{
- ASSERT((x < 16) && (x > -1) && (y < 128) && (y > -1) && (z < 16) && (z > -1));
+ ASSERT((x < cChunk::c_ChunkWidth) && (x > -1) && (y < cChunk::c_ChunkHeight) && (y > -1) && (z < cChunk::c_ChunkWidth) && (z > -1));
- return y + (z * 128) + (x * 128 * 16);
+ return y + (z * cChunk::c_ChunkHeight) + (x * cChunk::c_ChunkHeight * cChunk::c_ChunkWidth);
}
@@ -217,15 +217,15 @@ void cWorldGenerator::GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ,
cNoise Noise(m_World->GetWorldSeed());
- for (int z = 0; z < 16; z++)
+ for (int z = 0; z < cChunk::c_ChunkWidth; z++)
{
- const float zz = (float)(a_ChunkZ * 16 + z);
- for (int x = 0; x < 16; x++)
+ const float zz = (float)(a_ChunkZ * cChunk::c_ChunkWidth + z);
+ for (int x = 0; x < cChunk::c_ChunkWidth; x++)
{
// Place bedrock on bottom layer
a_BlockData[MakeIndex(x, 0, z)] = E_BLOCK_BEDROCK;
- const float xx = (float)(a_ChunkX * 16 + x);
+ const float xx = (float)(a_ChunkX * cChunk::c_ChunkWidth + x);
int Height = (int)(GetNoise( xx * 0.05f, zz * 0.05f, Noise ) * 16);
const int Lower = 64;
@@ -353,9 +353,9 @@ void cWorldGenerator::GenerateOre(char a_OreType, int a_MaxHeight, int a_NumNest
// Only stone gets replaced with ore, all other blocks stay (so the nest can actually be smaller than specified).
for (int i = 0; i < a_NumNests; i++)
{
- int BaseX = r1.randInt(16);
+ int BaseX = r1.randInt(cChunk::c_ChunkWidth);
int BaseY = r1.randInt(a_MaxHeight);
- int BaseZ = r1.randInt(16);
+ int BaseZ = r1.randInt(cChunk::c_ChunkWidth);
sSetBlockList OreBlocks;
size_t NestSize = (size_t)(a_NestSize + r1.randInt(a_NestSize / 4)); // The actual nest size may be up to 1/4 larger
while (OreBlocks.size() < NestSize)
@@ -396,7 +396,7 @@ void cWorldGenerator::GenerateOre(char a_OreType, int a_MaxHeight, int a_NumNest
// Replace stone with the queued ore blocks:
for (sSetBlockList::iterator itr = OreBlocks.begin(); itr != OreBlocks.end(); ++itr)
{
- if ((itr->x < 0) || (itr->y < 0) || (itr->z < 0) || (itr->x >= 16) || (itr->y >= 127) || (itr->z >= 16))
+ if ((itr->x < 0) || (itr->y < 0) || (itr->z < 0) || (itr->x >= cChunk::c_ChunkWidth) || (itr->y >= cChunk::c_ChunkHeight-1) || (itr->z >= cChunk::c_ChunkWidth))
{
continue;
}
@@ -425,12 +425,12 @@ void cWorldGenerator::GenerateFoliage(int a_ChunkX, int a_ChunkY, int a_ChunkZ)
}
cNoise Noise(m_World->GetWorldSeed());
- for (int z = 0; z < 16; z++)
+ for (int z = 0; z < cChunk::c_ChunkWidth; z++)
{
- int zz = z + a_ChunkZ * 16;
- for (int x = 0; x < 16; x++)
+ int zz = z + a_ChunkZ * cChunk::c_ChunkWidth;
+ for (int x = 0; x < cChunk::c_ChunkWidth; x++)
{
- int xx = x + a_ChunkX * 16;
+ int xx = x + a_ChunkX * cChunk::c_ChunkWidth;
int TopY = m_World->GetHeight(xx, zz);
int index = MakeIndex(x, TopY - 1, z);
diff --git a/source/cWorldGenerator_Test.cpp b/source/cWorldGenerator_Test.cpp
index 7f0c58bb8..37ac9025c 100644
--- a/source/cWorldGenerator_Test.cpp
+++ b/source/cWorldGenerator_Test.cpp
@@ -12,9 +12,9 @@
void cWorldGenerator_Test::GenerateTerrain(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData)
{
memset(a_BlockData, E_BLOCK_DIRT, cChunk::c_NumBlocks);
- for(int x = 0; x < 16; x++)
+ for(int x = 0; x < cChunk::c_ChunkWidth; x++)
{
- for(int z = 0; z < 16; z++)
+ for(int z = 0; z < cChunk::c_ChunkWidth; z++)
{
a_BlockData[MakeIndex(x, 0, z)] = E_BLOCK_BEDROCK;
}
diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp
index 24d7b8d88..d602007e3 100644
--- a/source/packets/cPacket_MapChunk.cpp
+++ b/source/packets/cPacket_MapChunk.cpp
@@ -36,12 +36,13 @@ cPacket_MapChunk::cPacket_MapChunk(cChunk * a_Chunk)
m_UnusedInt = 0;
- unsigned int DataSize = 16 * (4096 + 2048 + 2048 + 2048);
+
+ unsigned int DataSize = (cChunk::c_ChunkHeight/16) * (4096 + 2048 + 2048 + 2048);
char* AllData = new char[ DataSize ];
memset( AllData, 0, DataSize );
unsigned int iterator = 0;
- for( int i = 0; i < 8; ++i ) // Old world is only 8*16 high (should be 16*16)
+ for( int i = 0; i < (cChunk::c_ChunkHeight/16); ++i ) // Old world is only 8*16 high (should be 16*16)
{
m_BitMap1 |= (1 << i); // This tells what chunks are sent. Use this to NOT send air only chunks (right now everything is sent)
for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z ) for( int x = 0; x < 16; ++x )
@@ -51,7 +52,7 @@ cPacket_MapChunk::cPacket_MapChunk(cChunk * a_Chunk)
}
}
//Send block metadata
- for( int i = 0; i < 8; ++i )
+ for( int i = 0; i < (cChunk::c_ChunkHeight/16); ++i )
{
for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z )
{
@@ -63,7 +64,7 @@ cPacket_MapChunk::cPacket_MapChunk(cChunk * a_Chunk)
}
}
//Send block light
- for( int i = 0; i < 8; ++i )
+ for( int i = 0; i < (cChunk::c_ChunkHeight/16); ++i )
{
for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z )
{
@@ -75,7 +76,7 @@ cPacket_MapChunk::cPacket_MapChunk(cChunk * a_Chunk)
}
}
//Send sky light
- for( int i = 0; i < 8; ++i )
+ for( int i = 0; i < (cChunk::c_ChunkHeight/16); ++i )
{
for( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z )
{
@@ -98,9 +99,9 @@ cPacket_MapChunk::cPacket_MapChunk(cChunk * a_Chunk)
m_CompressedSize = CompressedSize;
#else
- m_PosX = a_Chunk->GetPosX() * 16; // It has to be block coordinates
- m_PosY = (short)(a_Chunk->GetPosY() * 128);
- m_PosZ = a_Chunk->GetPosZ() * 16;
+ m_PosX = a_Chunk->GetPosX() * cChunk::c_ChunkWidth; // It has to be block coordinates
+ m_PosY = (short)(a_Chunk->GetPosY() * cChunk::c_ChunkHeight);
+ m_PosZ = a_Chunk->GetPosZ() * cChunk::c_ChunkWidth;
m_SizeX = 15;
m_SizeY = 127;