While trying to send map tiles from a server to a client, I noticed that there were other values interspersed throughout the packet that really should not be there.
The data at the top is the map that should be sent. The data near the bottom is the data that was received. I have highlighted some of the anomalies
To clarify a bit, I am trying to load the entire map onto a single packet, with this bit here
// sending client map data
sf::Packet data;
// sending command (map data)
sf::Uint8 cmd = 0;
data << cmd;
// sending map size
sf::Uint8 size = server->map.size();
data << size;
// sending tiles
for (unsigned int x = 0; x < server->map.size(); x++) {
for (unsigned int y = 0; y < server->map[y].size(); y++) {
sf::Uint8 type = (int) server->map[x][y];
data << type;
}
}
When pulling out the code, I just do the opposite, extract the "code" telling the client what to do with the info, grab the size of the map, then load all the tiles sent into the map. The issue occurs when there are numbers in the received data that shouldn't be in there, as seen in the image.
Has anyone else experienced this? Does anyone know what this data is / how it gets into the packet or received / how to remove it or prevent it?