Version of OpenTTD
master (at least since a2051ba)
Details
Packet::CanWriteToPacket treats Packet::limit as an exclusive bound on the packet size, such that the packet size must always be < the limit.
Other functions such as Packet::Send_bytes and Packet::ParsePacketSize treat Packet::limit as an inclusive bound on the packet size, such that the packet size must always be <= the limit.
The latter interpretation would make more sense as the "correct" behaviour, so it would seem better to correct Packet::CanWriteToPacket to match the others instead of the other way around?
If data to send is sized to fill the packet limit exactly using the latter interpretation of the limit (I made this assumption before noticing the discrepancy) an assertion is triggered.
Version of OpenTTD
master (at least since a2051ba)
Details
Packet::CanWriteToPacket treats Packet::limit as an exclusive bound on the packet size, such that the packet size must always be < the limit.
Other functions such as Packet::Send_bytes and Packet::ParsePacketSize treat Packet::limit as an inclusive bound on the packet size, such that the packet size must always be <= the limit.
The latter interpretation would make more sense as the "correct" behaviour, so it would seem better to correct Packet::CanWriteToPacket to match the others instead of the other way around?
If data to send is sized to fill the packet limit exactly using the latter interpretation of the limit (I made this assumption before noticing the discrepancy) an assertion is triggered.