gamedig / rust-gamedig

Game Server Query Library.
https://crates.io/crates/gamedig
MIT License
39 stars 12 forks source link

Add the unreal2 protocol #124

Closed Douile closed 11 months ago

Douile commented 11 months ago

First draft of an unreal2 implementation. There's still quite a few TODOs but as it is it works with the killingfloor test I made (I have yet to test the other games that use this protocol).

This is my first protocol implementation, please let me know if I have done anything wrong.

The part that needs the most work for this to be ready is the StringDecoder implementation: unreal2 uses either latin1 or ucs2(?) so that is kind of blocked by #89 as there is already work on adding a latin1 decoder (this work in feat/encoding-latin1 also includes a helper function for finding delimiters which would be used).

Missing from this implementation is the extra response data parsing: the server info packet can contain extra data for certain games. The node implementation detects this based on what mutators the server returns and goes back to the server info buffer and parses the extra data. I haven't looked into whether we would want to do the same thing or parse additional data based on ExtraRequestSettings like we do with valve.

Also of note is that this protocol relies heavily on timeouts, we don't know how many packets we will get in response to each query (for rules, players, and possibly server info). As a result we keep receiving packets until we get a timeout. I would like to look into whether there is a better way to do this: maybe the 4 bytes of header we ignore contain information on how many response packets to expect. If anyone has more information about this protocol please do let me know.

This was in the roadmap: https://github.com/orgs/gamedig/projects/1?pane=issue&itemId=22463327

CosminPerRam commented 11 months ago

This is my first protocol implementation [...]

Great work :) I will come back with a review when I get the time to do so.

Missing from this implementation is the extra response data parsing [...]

Not really a merging-blocking problem, all protocols that are already implemented weren't fully working/completed when I first added them (also applies to next quote response), many smaller steps are better than rare big ones, can't run without walking first.

[...] so that is kind of blocked by https://github.com/gamedig/rust-gamedig/issues/89

Will look into it.

Douile commented 11 months ago

I noticed while implementing latin1 that some ut2003 servers send UTF8 strings when the node implementation expected latin1. When we parse as latin1 in this case the colour stripping is broken and hence random characters are left in the final name. (The same behavior as node-gamedig).