fix: 32 bit protocol

This commit is contained in:
2021-09-01 16:25:38 +02:00
parent 056534028d
commit 26f060b334
5 changed files with 10 additions and 10 deletions

View File

@@ -8,7 +8,7 @@ namespace utils {
DataBuffer Compress(const DataBuffer& buffer);
DataBuffer Decompress(DataBuffer& buffer);
DataBuffer Decompress(DataBuffer& buffer, std::size_t packetLength);
DataBuffer Decompress(DataBuffer& buffer, std::uint64_t packetLength);
} // namespace utils
} // namespace td

View File

@@ -33,9 +33,9 @@ bool Connexion::updateSocket(){
return false;
DataBuffer buffer;
m_Socket.Receive(buffer, sizeof(std::size_t));
m_Socket.Receive(buffer, sizeof(std::uint64_t));
if (buffer.GetSize() > 0){
std::size_t packetLenght;
std::uint64_t packetLenght;
buffer >> packetLenght;
m_Socket.Receive(buffer, packetLenght);

View File

@@ -49,12 +49,12 @@ DataBuffer Compress(const DataBuffer& buffer) {
return packet;
}
DataBuffer Decompress(DataBuffer& buffer, std::size_t packetLength){
DataBuffer Decompress(DataBuffer& buffer, std::uint64_t packetLength){
std::uint64_t uncompressedLength;
buffer >> uncompressedLength;
std::size_t compressedLength = packetLength - sizeof(uncompressedLength);
std::uint64_t compressedLength = packetLength - sizeof(uncompressedLength);
if (uncompressedLength == 0) {
// Uncompressed

View File

@@ -9,7 +9,7 @@ void initRandomizer(){
srand(time(0));
}
std::uint64_t getRandomNumber(std::size_t max){
std::uint64_t getRandomNumber(std::uint64_t max){
return rand() % max;
}

View File

@@ -122,7 +122,7 @@ void WorldBeginDataPacket::Deserialize(DataBuffer& data){
data >> m_RedSpawn >> m_RedTower;
data >> m_BlueSpawn >> m_BlueTower;
std::size_t tilePaletteSize;
std::uint64_t tilePaletteSize;
data >> tilePaletteSize;
m_TilePalette.reserve(tilePaletteSize);
@@ -145,7 +145,7 @@ DataBuffer WorldDataPacket::Serialize() const{
game::ChunkCoord coords = pair.first;
game::ChunkPtr chunk = pair.second;
data << coords.first << coords.second << chunk->palette.size();
data << coords.first << coords.second << (std::uint64_t) chunk->palette.size();
std::size_t bufferSize = data.GetSize();
data.Resize(data.GetSize() + chunk->palette.size() * sizeof(game::ChunkPalette::value_type));
@@ -182,7 +182,7 @@ DataBuffer WorldDataPacket::Serialize() const{
}
void WorldDataPacket::Deserialize(DataBuffer& data){
std::size_t chunkCount;
std::uint64_t chunkCount;
data >> chunkCount;
for (int chunkNumber = 0; chunkNumber < chunkCount; chunkNumber++){
@@ -191,7 +191,7 @@ void WorldDataPacket::Deserialize(DataBuffer& data){
game::ChunkCoord::first_type chunkX, chunkY;
data >> chunkX >> chunkY;
std::size_t chunkPaletteSize;
std::uint64_t chunkPaletteSize;
data >> chunkPaletteSize;
game::ChunkPalette chunkPalette(chunkPaletteSize);