mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 16:10:36 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user