#include "client/packets/WorldPackets.h" #include "client/Game.h" #include "client/World.h" #include "common/BlockStorage.h" #include "common/network/Packets.h" #include "utils/Logger.h" void WorldPackets::receiveChunk(InPacket& in) { LOG_DEBUG("received chunk from server"); int32 ox; int32 oz; if(in.readS32(ox) || in.readS32(oz)) { LOG_WARNING("missing chunk offset in packet"); return; } uint16 counter = 0; Block::Id b = 0; for(int y = 0; y < World::getHeight(); y++) { for(int x = 0; x < BlockStorage::SEGMENT; x++) { for(int z = 0; z < BlockStorage::SEGMENT; z++) { if(counter == 0 && (in.readU16(b) || in.readU16(counter))) { LOG_WARNING("missing block data in packet"); return; } World::setBlock(ox + x, y, oz + z, b); counter--; } } } }