summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-12 20:29:31 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-03-12 20:29:31 +0100
commitcb1edaf6df5575c28b50462bc98c5a6072b449b5 (patch)
treebe827ec4fa198761de5c654dbb8b7514167c5324
parentFixing compilation on Drawin 9 / MacOS X (diff)
downloadcuberite-cb1edaf6df5575c28b50462bc98c5a6072b449b5.tar
cuberite-cb1edaf6df5575c28b50462bc98c5a6072b449b5.tar.gz
cuberite-cb1edaf6df5575c28b50462bc98c5a6072b449b5.tar.bz2
cuberite-cb1edaf6df5575c28b50462bc98c5a6072b449b5.tar.lz
cuberite-cb1edaf6df5575c28b50462bc98c5a6072b449b5.tar.xz
cuberite-cb1edaf6df5575c28b50462bc98c5a6072b449b5.tar.zst
cuberite-cb1edaf6df5575c28b50462bc98c5a6072b449b5.zip
Diffstat (limited to '')
-rw-r--r--source/BlockID.h35
-rw-r--r--source/ChunkSender.cpp3
-rw-r--r--source/ChunkSender.h1
-rw-r--r--source/packets/cPacket_MapChunk.cpp29
-rw-r--r--source/packets/cPacket_MapChunk.h2
5 files changed, 55 insertions, 15 deletions
diff --git a/source/BlockID.h b/source/BlockID.h
index 8122e63b9..3fa4ff867 100644
--- a/source/BlockID.h
+++ b/source/BlockID.h
@@ -395,3 +395,38 @@ enum ENUM_ITEM_ID
E_ITEM_11_DISC = 2266,
};
//tolua_end
+
+
+
+
+/// Biome IDs, as stored in the Anvil format and sent in the MapChunk packet
+enum eBiomeID
+{
+ biOcean = 0,
+ biPlains = 1,
+ biDesert = 2,
+ biExtremeHills = 3,
+ biForest = 4,
+ biTaiga = 5,
+ biSwampland = 6,
+ biRiver = 7,
+ biHell = 8, // Nether?
+ biSky = 9,
+ biFrozenOcean = 10,
+ biFrozenRiver = 11,
+ biIcePlains = 12,
+ biIceMountains = 13,
+ biMushroomIsland = 14,
+ biMushroomShore = 15,
+ biBeach = 16,
+ biDesertHills = 17,
+ biForestHills = 18,
+ biTaigaHills = 19,
+ biExtremeHillsEdge = 20,
+ biJungle = 21,
+ biJungleHills = 22,
+} ;
+
+
+
+
diff --git a/source/ChunkSender.cpp b/source/ChunkSender.cpp
index f73246c98..5d7efbdc8 100644
--- a/source/ChunkSender.cpp
+++ b/source/ChunkSender.cpp
@@ -22,6 +22,7 @@ cChunkSender::cChunkSender(void) :
super("ChunkSender"),
m_World(NULL)
{
+ memset(m_BiomeData, biPlains, sizeof(m_BiomeData));
}
@@ -171,7 +172,7 @@ void cChunkSender::SendChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cClientHa
return;
}
cPacket_PreChunk PreChunk(a_ChunkX, a_ChunkZ, true);
- cPacket_MapChunk MapChunk(a_ChunkX, a_ChunkY, a_ChunkZ, m_BlockData);
+ cPacket_MapChunk MapChunk(a_ChunkX, a_ChunkY, a_ChunkZ, m_BlockData, m_BiomeData);
// Send:
if (a_Client == NULL)
diff --git a/source/ChunkSender.h b/source/ChunkSender.h
index c5c6f7774..3c77c4210 100644
--- a/source/ChunkSender.h
+++ b/source/ChunkSender.h
@@ -102,6 +102,7 @@ protected:
// Data about the chunk that is being sent:
char m_BlockData[cChunk::c_BlockDataSize];
+ char m_BiomeData[cChunk::c_ChunkWidth * cChunk::c_ChunkWidth];
PacketList m_Packets; // Accumulator for the entity-packets to send
// cIsThread override:
diff --git a/source/packets/cPacket_MapChunk.cpp b/source/packets/cPacket_MapChunk.cpp
index 791b81425..18b924f15 100644
--- a/source/packets/cPacket_MapChunk.cpp
+++ b/source/packets/cPacket_MapChunk.cpp
@@ -19,7 +19,7 @@ cPacket_MapChunk::~cPacket_MapChunk()
-cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData)
+cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, const char * a_BiomeData)
{
m_PacketID = E_MAP_CHUNK;
@@ -29,18 +29,19 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cha
m_PosX = a_ChunkX; // Chunk coordinates now, instead of block coordinates
m_PosZ = a_ChunkZ;
- m_bContiguous = false;
+ m_bContiguous = true; // false = no biome data, true = with biome data
m_BitMap1 = 0;
m_BitMap2 = 0;
m_UnusedInt = 0;
- unsigned int DataSize = (cChunk::c_ChunkHeight / 16) * (4096 + 2048 + 2048 + 2048);
- std::auto_ptr<char> AllData(new char[ DataSize ]);
+ const int BlockDataSize = (cChunk::c_ChunkHeight / 16) * (4096 + 2048 + 2048 + 2048);
+ const int BiomeDataSize = cChunk::c_ChunkWidth * cChunk::c_ChunkWidth;
+ char AllData [ BlockDataSize + BiomeDataSize ];
#if AXIS_ORDER == AXIS_ORDER_YZX
- memset( AllData.get(), 0, DataSize );
+ memset( AllData, 0, BlockDataSize );
unsigned int iterator = 0;
for ( int i = 0; i < (cChunk::c_ChunkHeight / 16); ++i )
@@ -49,7 +50,7 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cha
for ( int y = 0; y < 16; ++y ) for( int z = 0; z < 16; ++z ) for( int x = 0; x < 16; ++x )
{
int idx = cChunk::MakeIndex(x, y + i * 16, z);
- AllData.get()[iterator] = a_BlockData[idx];
+ AllData[iterator] = a_BlockData[idx];
++iterator;
} // for y, z, x
}
@@ -62,7 +63,7 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cha
{
for ( int x = 0; x < 8; ++x )
{
- AllData.get()[iterator] = cChunk::GetNibble(Meta, x * 2 + 0, y + i * 16, z) | (cChunk::GetNibble(Meta, x * 2 + 1, y + i * 16, z ) << 4);
+ AllData[iterator] = cChunk::GetNibble(Meta, x * 2 + 0, y + i * 16, z) | (cChunk::GetNibble(Meta, x * 2 + 1, y + i * 16, z ) << 4);
++iterator;
} // for x
} // for y, z
@@ -76,7 +77,7 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cha
{
for ( int x = 0; x < 8; ++x )
{
- AllData.get()[iterator] = cChunk::GetNibble(Light, x * 2 + 0, y + i * 16, z ) | (cChunk::GetNibble(Light, x * 2 + 1, y + i * 16, z ) << 4);
+ AllData[iterator] = cChunk::GetNibble(Light, x * 2 + 0, y + i * 16, z ) | (cChunk::GetNibble(Light, x * 2 + 1, y + i * 16, z ) << 4);
++iterator;
}
}
@@ -90,23 +91,25 @@ cPacket_MapChunk::cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, cha
{
for( int x = 0; x < 8; ++x )
{
- AllData.get()[iterator] = cChunk::GetNibble(SkyLight, x * 2 + 0, y + i * 16, z ) | (cChunk::GetNibble(SkyLight, x * 2 + 1, y + i * 16, z ) << 4);
+ AllData[iterator] = cChunk::GetNibble(SkyLight, x * 2 + 0, y + i * 16, z ) | (cChunk::GetNibble(SkyLight, x * 2 + 1, y + i * 16, z ) << 4);
++iterator;
}
}
}
+ memcpy(AllData + BlockDataSize, a_BiomeData, BiomeDataSize);
#elif AXIS_ORDER == AXIS_ORDER_XZY
for ( int i = 0; i < 16; ++i )
{
m_BitMap1 |= (1 << i);
}
- memcpy( AllData.get(), a_BlockData, DataSize );
-#endif
+ memcpy(AllData, a_BlockData, BlockDataSize);
+ memcpy(AllData + BlockDataSize, a_BiomeData, BiomeDataSize);
+#endif // AXIS_ORDER
- uLongf CompressedSize = compressBound( DataSize );
+ uLongf CompressedSize = compressBound( sizeof(AllData) );
char * CompressedBlockData = new char[CompressedSize];
- compress2( (Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)AllData.get(), DataSize, Z_DEFAULT_COMPRESSION);
+ compress2( (Bytef*)CompressedBlockData, &CompressedSize, (const Bytef*)AllData, sizeof(AllData), Z_DEFAULT_COMPRESSION);
m_CompressedData = CompressedBlockData;
m_CompressedSize = CompressedSize;
diff --git a/source/packets/cPacket_MapChunk.h b/source/packets/cPacket_MapChunk.h
index db4192457..1dd05f9ef 100644
--- a/source/packets/cPacket_MapChunk.h
+++ b/source/packets/cPacket_MapChunk.h
@@ -33,7 +33,7 @@ public:
{ m_PacketID = E_MAP_CHUNK; m_CompressedData = 0; }
cPacket_MapChunk( const cPacket_MapChunk & a_Copy );
- cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, char * a_BlockData);
+ cPacket_MapChunk(int a_ChunkX, int a_ChunkY, int a_ChunkZ, const char * a_BlockData, const char * a_BiomeData);
~cPacket_MapChunk();
virtual cPacket* Clone() const { return new cPacket_MapChunk(*this); }