heinrich5991 / libtw2

Some Teeworlds stuff in Rust.™
Apache License 2.0
49 stars 17 forks source link

gamenet: Add 0.7 connless inf3 (closed #77) #78

Closed ChillerDragon closed 1 year ago

ChillerDragon commented 1 year ago

Generated using

cd gamenet/generate
python3 serialize.py --version 0.7 raw/teeworlds-0.7.5.py > spec/teeworlds-0.7.5.json
ChillerDragon commented 1 year ago

Changes to 0.6 are the IntStrins got changed to regular ints. And the hostname field was added.

How it was in 0.6 https://github.com/teeworlds/teeworlds/blob/93f5bf632a3859e97d527fc93a26b6dced767fbc/src/engine/server/server.cpp#L1082-L1145

How it is in 0.7 https://github.com/teeworlds/teeworlds/blob/26d24ec061d44e6084b2d77a9b8a0a48e354eba6/src/engine/server/server.cpp#L1091-L1149

I did not touch the client list since from what I understood its fields like name, clan, score are not implemented for 0.6 either. But the fields country, score, is player also changed from IntString to regular int

The hostname field is unpacked by the client like this. So I assume the NetStringStrict is fitting. The client defaulting it to m_aAddress is probably irrelevant.

str_copy(pInfo->m_aName, pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(pInfo->m_aName));
str_clean_whitespaces(pInfo->m_aName);
str_copy(pInfo->m_aHostname, pUnpacker->GetString(CUnpacker::SANITIZE_CC|CUnpacker::SKIP_START_WHITESPACES), sizeof(pInfo->m_aHostname));
if(pInfo->m_aHostname[0] == 0)
    str_copy(pInfo->m_aHostname, pInfo->m_aAddress, sizeof(pInfo->m_aHostname));

The num_client fields could be capped to MAX_CLIENTS but I think it would be nicer if there is space for 128+ servers in this spec.

ChillerDragon commented 1 year ago

Current state untested. I was hoping to verify it with the dissector but it does not seem to work yet.

ChillerDragon commented 1 year ago

Ah nice seems like the token fixed the dissector looks kinda correct now. Seems to count bots as players but that is the intended 0.7 way of doing it I think.

image