blurite / rsprot

RSProt is an all-in-one networking package for RuneScape Private Servers, primarily targeted at the OldSchool scene.
MIT License
27 stars 5 forks source link

Buffer documentation #17

Open Z-Kris opened 2 months ago

Z-Kris commented 2 months ago

Buffer functions have incomplete documentation right now. Additionally, the documentation that does exist is rather confusing (even to myself as I wrote them). Ideally the documentation should provide a breakdown of the bytes in a table format, e.g. as an example:

| Byte | Modification | Shift |
|:----:|:------------:|:-----:|
|   0  |       0      |   8   |
|   1  |     +128     |   0   |

Which would be the documentation for the p2Alt2 function:

public fun ByteBuf.p2Alt2(value: Int): ByteBuf {
    writeByte(value shr 8)
    writeByte(value + 128)
    return this
}

I believe this is much easier to understand than trying to break down the modifications to each byte in text format, particularly for the more complex cases such as p4Alt* where there are four bytes to try to explain.