| id | REF-024 | ||||
|---|---|---|---|---|---|
| workflow | github | ||||
| github_issue | emulebb/emulebb#90 | ||||
| title | Convert | ||||
| status | OPEN | ||||
| priority | Trivial | ||||
| category | refactor | ||||
| labels |
|
||||
| milestone | |||||
| created | 2026-04-08 | ||||
| source | AUDIT-WWMOD.md (WWMOD_022) |
Workflow status is tracked in GitHub: emulebb/emulebb#90. This local document is retained as an engineering spec/evidence record.
srchybrid/Opcodes.h contains 100+ #define constants for protocol opcodes,
limits, and magic numbers. C-style #define bypasses the type system, pollutes
the global macro namespace, and is not debuggable. Replace with constexpr
values in a namespace (or enum class for opcode groups).
// Opcodes.h (excerpt):
#define OP_EDONKEYPROT 0xe3
#define OP_KADEMLIAHEADER 0xe4
#define OP_EMULEPROT 0xc5
#define PARTSIZE 9728000UL
#define EMBLOCKSIZE 180224UL
#define MAXCON5WIN9X 10 // dead Win9x constant — remove (see REF-017)
#define UPLOAD_CLIENT_MAXDATARATE (25*1024) // stale default — see FEAT-015/016
// ... 100+ morenamespace emule::protocol {
inline constexpr uint8_t OP_EDONKEYPROT = 0xe3;
inline constexpr uint8_t OP_KADEMLIAHEADER = 0xe4;
inline constexpr uint8_t OP_EMULEPROT = 0xc5;
// ...
}Or as a typed enum:
enum class ProtocolHeader : uint8_t {
EDonkey = 0xe3,
Kademlia = 0xe4,
eMule = 0xc5,
// ...
};namespace emule::limits {
inline constexpr uint32_t PARTSIZE = 9'728'000UL;
inline constexpr uint32_t EMBLOCKSIZE = 180'224UL;
}Remove during this pass:
MAXCON5WIN9X(dead Win9x — see REF-017)- Constants superseded by FEAT-015/016 modern limits (coordinate with those issues)
A full rename of 100+ defines is a large mechanical diff. Approach:
- Convert one logical group at a time (protocol headers, opcodes per protocol, size limits, timeout values)
- Use
using namespace emule::protocol;in.cppfiles temporarily to avoid mass call-site churn — removeusingdirectives as files are migrated - Keep
Opcodes.has the single include; just change the definitions inside
| File | Change |
|---|---|
srchybrid/Opcodes.h |
Replace #define with constexpr / enum class |
All .cpp files that use opcode constants |
Update if namespace qualification required |
- No protocol-constant
#definemacros remain inOpcodes.h - Opcode values remain bitwise identical (no protocol change)
-
PARTSIZE,EMBLOCKSIZE,UDP_KAD_MAXFRAGMENTconverted to typedconstexpr(these are out of scope for FEAT-016 value changes) - Clean build with zero macro-vs-constexpr collision warnings