Page 1 of 1
Protocol info
Posted: Thu Sep 14, 2017 9:33 am
by moien007
Hi
I wanted to remake tw in C#.
I'm reading tw and ddnet source code about 2 days.
i didn't any info about tw protocol definitions, like packet structure or packing method or any info.
Please tell what files i have to read in repo also more info mean how client authentication works.
So.. just tell what i should read and do
Note: I'm not C\C++ expert, that's why i'm here
Re: Protocol info
Posted: Thu Sep 14, 2017 9:46 am
by deen
Maybe this Rust reimplementation will help you:
https://github.com/heinrich5991/libtw2
Re: Protocol info
Posted: Thu Sep 14, 2017 9:51 am
by moien007
LOL, tnx dude but i don't know Rust

, just give 2/3 minute and tell me about tw protocol, please

Re: Protocol info
Posted: Thu Sep 14, 2017 10:07 am
by deen
There is also
https://github.com/ddnet/ddnet/blob/mas ... .h#L15-L28
Other than that, just reading the code, maybe stepping through with a debugger, could help.
Re: Protocol info
Posted: Thu Sep 14, 2017 10:24 am
by moien007
oh yeah that packets structure tnx, where's message definitions ?
Re: Protocol info
Posted: Thu Sep 14, 2017 12:06 pm
by Ryozuki
The structs used to send/recieve messages are generated by a
python script, here is the generated file:
From my experience with it, the client uses
for outgoing messages from the client.
e.g:
Code: Select all
CNetMsg_Cl_Say // used to send a chat message.
I think its CNetMsg_Sv_* for outgoing messages from server to client.
Also from what i saw you use CNetObj_* structs to convert the data recieved (e.g projectile info CNetObj_Projectile)
To send a packet, the
CMsgPacker is used.
Example sending a chat packet:
Code: Select all
// send chat message
CNetMsg_Cl_Say Msg;
Msg.m_Team = Team;
Msg.m_pMessage = pLine;
CMsgPacker packet(Msg.MsgID());
Msg.Pack(&packet);
Client()->SendMsg(&packet, MSGFLAG_VITAL);
// or a shorter version
CNetMsg_Cl_Say Msg;
Msg.m_Team = Team;
Msg.m_pMessage = pLine;
Client()->SendPackMsg(&Msg, MSGFLAG_VITAL);
Re: Protocol info
Posted: Thu Sep 14, 2017 12:56 pm
by heinrich5991
Packet header:
https://github.com/heinrich5991/libtw2/ ... /packet.md
If you want, we could work together to create some documentation. You can find me on IRC, or on many instant messengers.
Code I use to generate the system messages:
https://github.com/heinrich5991/libtw2/ ... _system.py (original code does ad-hoc parsing).
Re: Protocol info
Posted: Thu Sep 14, 2017 2:08 pm
by mokuz
Neat!
Re: Protocol info
Posted: Thu Sep 14, 2017 2:45 pm
by moien007
thanks, very useful.
