MilkeeyCat / ddnet_protocol

DDNet network parsing library in C
GNU Affero General Public License v3.0
0 stars 1 forks source link

Add js script for generating game messages #8

Open MilkeeyCat opened 1 week ago

ChillerDragon commented 2 hours ago

I actually switched away from message generation in my newer projects. The core 0.6 protocol is not too big an can be done manually quite quickly. But I think generation is nice to keep up with the new ddnet extensions if you plan to support those it would also require to introduce the uuid manager code.

One obvious problem with message generation is its complexity overhead. And another one is its correctness. Because some protocol messages are never correctly defined anywhere other than where they are packed or unpacked in the client or server code.

But if you decide to go with automatic generation I recommend using libtw2's json spec as input. This way the maintenance can be reduced because libtw2 manages updating to newer protocol versions and exposing them as one stable json api. I did that for twnet_parser but tbh my generation code became quite messy. But that being said libtw2's protocol spec is not fully correct/complete at the moment. Because of the edge cased nature of the protocol. But it works well enough for most cases.

And even if you really decide to go with message generation I recommend drafting out a few messages by hand and tweak their api until it becomes smooth for the use cases this library is trying to provide. Once a few messages work well their shape can be auto generated if needed.