James Pae
James Pae

Reputation: 51

Sending terrain height data with RakNet

I generate a string like so:

std::string str = "";
str += std::to_string(MapSize);

for (int x = 0; x < MapSize; x++) {
    for (int z = 0; z < MapSize; z++) {
        str += " ";
        str += std::to_string(x);
        str += " ";
        str += std::to_string(heights[x][z]);
        str += " ";
        str += std::to_string(z);
    }
}

The amount of height data is MapSize^2 (MapSize is usually 256x256). But th question is- Is this a sane amount of data to send through RakNet (UDP)? I could split the data into chunks, but i would like to avoid doing that.

Upvotes: 0

Views: 135

Answers (1)

Lee Mccarthy
Lee Mccarthy

Reputation: 11

RakNet automatically breaks packets up into sane sizes for UDP, somewhere between 574 and 1492 bytes. This is called the MTU size. accounting for reliability headers or string serialization bloat, 256x256/574=115 packets minimum 256x256/1492=44 packets minimum I recommend setting the reliability type to RELIABLE_ORDERED, so that the packets are guaranteed to arrive, and in order.

Source: RakNet manual & doxygen, especially a certain page

Upvotes: 1

Related Questions