Skip to content

Off by one error in Packet::CanWriteToPacket #9361

Description

@JGRennison

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions