BIG REFACTOR

This commit is contained in:
2022-02-16 17:54:33 +01:00
parent 387cff36ad
commit bdebabb79e
13 changed files with 111 additions and 74 deletions

View File

@@ -192,7 +192,7 @@ DataBuffer WorldDataPacket::SerializeCustom() const {
game::ChunkCoord coords = pair.first;
game::ChunkPtr chunk = pair.second;
data << coords.first << coords.second << (std::uint64_t)chunk->palette.size();
data << coords.x << coords.y << (std::uint64_t)chunk->palette.size();
std::size_t bufferSize = data.GetSize();
data.Resize(data.GetSize() + chunk->palette.size() * sizeof(game::ChunkPalette::value_type));
@@ -200,7 +200,7 @@ DataBuffer WorldDataPacket::SerializeCustom() const {
std::uint8_t bitsPerTile = countBits(chunk->palette.size());
game::ChunkData::value_type individualValueMask = ((1 << bitsPerTile) - 1);
game::Chunk::ChunkData::value_type individualValueMask = ((1 << bitsPerTile) - 1);
ChunkPackedData chunkData(game::Chunk::ChunkSize / (BITS_IN_BYTE * sizeof(ChunkPackedData::value_type) / bitsPerTile), 0);
@@ -235,7 +235,7 @@ DataBuffer WorldDataPacket::Serialize() const {
game::ChunkCoord coords = pair.first;
game::ChunkPtr chunk = pair.second;
data << coords.first << coords.second << (std::uint64_t)chunk->palette.size();
data << coords.x << coords.y << (std::uint64_t)chunk->palette.size();
std::size_t bufferSize = data.GetSize();
data.Resize(data.GetSize() + chunk->palette.size() * sizeof(game::ChunkPalette::value_type));
@@ -243,7 +243,7 @@ DataBuffer WorldDataPacket::Serialize() const {
std::uint8_t bitsPerTile = countBits(chunk->palette.size());
game::ChunkData::value_type individualValueMask = ((1 << bitsPerTile) - 1);
game::Chunk::ChunkData::value_type individualValueMask = ((1 << bitsPerTile) - 1);
ChunkPackedData chunkData(game::Chunk::ChunkSize / (BITS_IN_BYTE * sizeof(ChunkPackedData::value_type) / bitsPerTile), 0);
@@ -278,7 +278,7 @@ void WorldDataPacket::Deserialize(DataBuffer& data) {
for (std::uint64_t chunkNumber = 0; chunkNumber < chunkCount; chunkNumber++) {
game::ChunkPtr chunk = std::make_shared<game::Chunk>();
game::ChunkCoord::first_type chunkX, chunkY;
decltype(game::ChunkCoord::x) chunkX, chunkY;
data >> chunkX >> chunkY;
std::uint64_t chunkPaletteSize;
@@ -294,7 +294,7 @@ void WorldDataPacket::Deserialize(DataBuffer& data) {
std::uint8_t bitsPerTile = countBits(chunkPaletteSize);
// A bitmask that contains bitsPerTile set bits
game::ChunkData::value_type individualValueMask = ((1 << bitsPerTile) - 1);
game::Chunk::ChunkData::value_type individualValueMask = ((1 << bitsPerTile) - 1);
ChunkPackedData chunkData(game::Chunk::ChunkSize / (BITS_IN_BYTE * sizeof(ChunkPackedData::value_type) / bitsPerTile), 0);
@@ -306,7 +306,7 @@ void WorldDataPacket::Deserialize(DataBuffer& data) {
int startOffset = (tileNumber * bitsPerTile) % BITS_IN_LONG;
int endLong = ((tileNumber + 1) * bitsPerTile - 1) / BITS_IN_LONG;
game::ChunkData::value_type value;
game::Chunk::ChunkData::value_type value;
if (startLong == endLong) {
value = (chunkData[startLong] >> startOffset);
} else {