Manage packet opcodes in a single header file
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:
- [ ] Combine all packet opcodes into a single header file that will be shared with all projects (we can temporarily put it into N3Base)
- [ ] Make all projects use that packet opcodes file
- [ ] Search for instances where constants values are hardcoded, rather than using actual opcode's defines
- [ ] Ensure that all packet opcode defines are prefixed with
N3PKT_*
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?