From ab1dd4032253634730b49814185c310f5c1ad3fa Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 24 Oct 2026 12:53:52 +0000 Subject: [PATCH] Coding rules: cast chains mean the types are wrong --- CODING_RULES.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CODING_RULES.md b/CODING_RULES.md index 6750f31..a046537 100644 --- a/CODING_RULES.md +++ b/CODING_RULES.md @@ -83,6 +83,22 @@ static void BuildFullKeyName(const char* keyname, char* buffer) { - Do not add WoW `// VERIFY:` hashes or use `re/tools/verify.py`; neither is this project's verification workflow. - Claims, submission scope and peer-review procedure follow `AGENTS.md` and current server guidance. +## 2b. Cast chains mean the types are wrong + +A chain of casts (`static_cast(static_cast(...))`, `std::bit_cast` round trips) usually +reproduces the compiler's output instead of the original source. Fix the declared types of the field, +parameter or return value so the code reads naturally. + +```cpp +// Wrong: hides that the value is stored as a 32-bit int +return static_cast(static_cast(this->render.instant.Get(key))); + +// Right: the getter returns the original type +return this->render.instant.Get(key); +``` + +Keep a cast only where the original source evidently had one (an explicit narrowing or a sign change). + ## 3. Every field carries its offset Every recovered instance data member of a struct, class or union is prefixed with its evidenced x86 offset: