ko4life-net / ko

Open source development of the game Knight Online. This is a reversed engineered old version of the game aiming to replicate the nostalgic experience we all once had <3
MIT License
52 stars 21 forks source link

Manage packet opcodes in a single header file #109

Open stevewgr opened 2 years ago

stevewgr commented 2 years ago

Description

When searching for "packet" in this url: https://github.com/ko4life-net/ko/find/master

It shows a bunch of files that store the same packet opcodes that the server files, as well as the client communicating with each other.

This is difficult to maintain, as well as doesn't scale nicely. It also makes it difficult to find things in the codebase, such as references to a specific opcode.

Tasks

This task requires some patience and being pedantic. There are also some places when RECV or SEND check for opcodes that don't use proper defines, rather constant values. I would imagine to tackle it, the following tasks should follow:

twostars commented 4 months ago

As an addendum to this, I think they should be converted to relevant enums (e.g. login, game, AI, whatever), rather than macros or constants. Also, unless they were added at some point in this repo's history, there shouldn't be any packets using magic numbers for the opcodes. Not by mgame, at least.

EDIT: I didn't see you mention you see it was done in some places with specific checks. Can you give an example of this? You're not referring to the encryption checks are you?