MCPcopy Create free account
hub / github.com/cuberite/cuberite / HandleServerMapChunkBulk

Method HandleServerMapChunkBulk

Tools/ProtoProxy/Connection.cpp:1874–1917  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1872
1873
1874bool cConnection::HandleServerMapChunkBulk(void)
1875{
1876 HANDLE_SERVER_PACKET_READ(ReadBEShort, short, ChunkCount);
1877 HANDLE_SERVER_PACKET_READ(ReadBEInt, int, CompressedSize);
1878 HANDLE_SERVER_PACKET_READ(ReadBool, bool, IsSkyLightSent);
1879 AString CompressedData;
1880 if (!m_ServerBuffer.ReadString(CompressedData, CompressedSize))
1881 {
1882 return false;
1883 }
1884
1885 // Read individual chunk metas.
1886 // Need to read them first and only then start logging (in case we don't have the full packet yet)
1887 typedef std::vector<sChunkMeta> sChunkMetas;
1888 sChunkMetas ChunkMetas;
1889 ChunkMetas.reserve(ChunkCount);
1890 for (short i = 0; i < ChunkCount; i++)
1891 {
1892 HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkX);
1893 HANDLE_SERVER_PACKET_READ(ReadBEInt, int, ChunkZ);
1894 HANDLE_SERVER_PACKET_READ(ReadBEShort, short, PrimaryBitmap);
1895 HANDLE_SERVER_PACKET_READ(ReadBEShort, short, AddBitmap);
1896 ChunkMetas.push_back(sChunkMeta(ChunkX, ChunkZ, PrimaryBitmap, AddBitmap));
1897 }
1898
1899 Log("Received a PACKET_MAP_CHUNK_BULK from the server:");
1900 Log(" ChunkCount = %d", ChunkCount);
1901 Log(" Compressed size = %d (0x%x)", CompressedSize, CompressedSize);
1902 Log(" IsSkyLightSent = %s", IsSkyLightSent ? "true" : "false");
1903
1904 // Log individual chunk coords:
1905 int idx = 0;
1906 for (sChunkMetas::iterator itr = ChunkMetas.begin(), end = ChunkMetas.end(); itr != end; ++itr, ++idx)
1907 {
1908 Log(" [%d]: [%d, %d], primary bitmap 0x%02x, add bitmap 0x%02x",
1909 idx, itr->m_ChunkX, itr->m_ChunkZ, itr->m_PrimaryBitmap, itr->m_AddBitmap
1910 );
1911 } // for itr - ChunkMetas[]
1912
1913 // TODO: Save the compressed data into a file for later analysis
1914
1915 COPY_TO_CLIENT();
1916 return true;
1917}
1918
1919
1920

Callers

nothing calls this directly

Calls 4

sChunkMetaClass · 0.85
beginMethod · 0.80
endMethod · 0.80
ReadStringMethod · 0.45

Tested by

no test coverage detected