refactor: route unit-token resolution through Game::ResolveUnitToken

Sweep the ~35 modules that each hand-rolled a `ResolveUnitToken_t` typedef
plus `reinterpret_cast<…>(Offsets::FUN_RESOLVE_UNIT_TOKEN)` onto the shared
`Game::ResolveUnitToken` helper. Behavior-identical — it is the same engine
function — and net -87 lines. The typedef now lives in exactly one place
(Game.cpp).

unit/Position.h is a header, so it gains an `#include "Game.h"`; every other
touched file already pulled Game.h in. No offsets, logic, or unrelated
typedefs were changed.
This commit is contained in:
Brues
2026-08-30 16:57:04 -05:00
parent 94e77ef5af
commit 993c82cca7
35 changed files with 41 additions and 148 deletions
+1 -4
View File
@@ -19,8 +19,6 @@ namespace Unit::ClassBase {
namespace {
using ResolveUnitToken_t = void *(__fastcall *)(const char *token);
// `UnitClassBase(unit) → (classFile, classID)` — returns the locale-
// independent class token ("WARRIOR", "PALADIN", "HUNTER", "ROGUE",
// "PRIEST", "SHAMAN", "MAGE", "WARLOCK", "DRUID") plus the numeric
@@ -81,8 +79,7 @@ int __fastcall Script_UnitClassBase(void *L) {
if (Unit::Identity::IsPlayerToken(token)) {
classByte = Game::Read<uint8_t>(Offsets::VAR_PLAYER_CLASS_BYTE);
} else {
auto resolve = reinterpret_cast<ResolveUnitToken_t>(Offsets::FUN_RESOLVE_UNIT_TOKEN);
auto *unit = static_cast<const uint8_t *>(resolve(token));
auto *unit = static_cast<const uint8_t *>(Game::ResolveUnitToken(token));
if (unit != nullptr) {
auto *desc =
Game::Read<const uint8_t *>(unit, Offsets::OFF_UNIT_DESCRIPTOR);