Protocol info

Discuss and share everything else.., it's the trash-section.
Forum rules
Please follow the common behaviour rules (viewtopic.php?f=113&t=2199) and write english-only.
Post Reply
moien007
Posts: 4
Joined: Thu Sep 14, 2017 9:23 am

Protocol info

Post 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
User avatar
deen
TECHNICAL Team
Posts: 3576
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: Protocol info

Post by deen »

Maybe this Rust reimplementation will help you: https://github.com/heinrich5991/libtw2
moien007
Posts: 4
Joined: Thu Sep 14, 2017 9:23 am

Re: Protocol info

Post by moien007 »

deen wrote: Thu Sep 14, 2017 9:46 am Maybe this Rust reimplementation will help you: https://github.com/heinrich5991/libtw2
LOL, tnx dude but i don't know Rust :? , just give 2/3 minute and tell me about tw protocol, please :D
User avatar
deen
TECHNICAL Team
Posts: 3576
Joined: Mon May 05, 2014 2:30 pm
Player profile: https://ddnet.org/players/deen/
Discord: deen#5910

Re: Protocol info

Post 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.
moien007
Posts: 4
Joined: Thu Sep 14, 2017 9:23 am

Re: Protocol info

Post by moien007 »

deen wrote: Thu Sep 14, 2017 10:07 am 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.
oh yeah that packets structure tnx, where's message definitions ?
User avatar
Ryozuki
Posts: 1748
Joined: Tue Feb 24, 2015 7:28 am
Location: Catalonia
Player profile: http://ddnet.tw/players/Ryozuki/
Mapper profile: http://ddnet.tw/mappers/Ryozuki/
Clan: Unique
Website: https://edgarluque.com
Discord: Ryozuki#2188

Re: Protocol info

Post 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

Code: Select all

CNetMsg_Cl_*
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);
heinrich5991
Posts: 47
Joined: Sat Sep 05, 2015 7:18 pm

Re: Protocol info

Post 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).
User avatar
mokuz
Posts: 755
Joined: Sat Apr 30, 2016 5:34 pm
Location: Finland
Player profile: https://ddnet.tw/players/Mokuz/
Mapper profile: https://ddnet.tw/mappers/Mokuz/
Clan: Legendary

Re: Protocol info

Post by mokuz »

Neat!
SpoilerShow
Nothing to see here uwu
mods banned my previous sig :( this is censorship freedom of speech is dead xoxox
moien007
Posts: 4
Joined: Thu Sep 14, 2017 9:23 am

Re: Protocol info

Post by moien007 »

thanks, very useful. :)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest