Consolidate all Spell.dbc record offsets into Offsets.h

Extend the single-source-of-truth cleanup to the whole Spell.dbc record
layout. 40 local constexpr offset copies across 16 files (spell/, totem/,
lossofcontrol/, macro/, aura/) redefined field offsets that belong in
Offsets.h: name (0x1E0), icon (0x1D4), effect (0xF4), rank (0x204),
effect implicit targets (0x148/0x154), powerType (0x7C), manaCost (0x80),
rangeIndex (0x90), castingTimeIndex (0x48), maxLevel (0x6C), spellLevel
(0x74), manaCostPercent (0x270).

Add the ones Offsets.h lacked as OFF_SPELL_RECORD_* and repoint every
local use to the Offsets:: constant, deleting the duplicates. Purely
mechanical and behavior-preserving -- every local value already matched
the canonical (verified before repointing). SpellIcon.dbc / SpellRange.dbc
sub-record offsets (0x04/0x08) stay local; they are different structs.
This commit is contained in:
Brues
2026-08-07 17:44:01 -05:00
parent 2a7cbf75ca
commit 8a065481b4
17 changed files with 68 additions and 107 deletions
+14
View File
@@ -5776,6 +5776,20 @@ enum Offsets {
SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS = 0x20000000,
OFF_SPELL_RECORD_INTERRUPT_FLAGS = 0x54, // u32 (column 21)
// Remaining Spell.dbc record fields — the single source of truth for the
// record layout (byte = column * 4). Modules must use these rather than
// redefining local copies.
OFF_SPELL_RECORD_CASTING_TIME_INDEX = 0x48, // u32 → SpellCastTimes.dbc
OFF_SPELL_RECORD_MAX_LEVEL = 0x6C, // u32 (scaling cap level)
OFF_SPELL_RECORD_SPELL_LEVEL = 0x74, // u32 (this rank's effective level)
OFF_SPELL_RECORD_POWER_TYPE = 0x7C, // i32 (0=mana,1=rage,2=focus,3=energy,4=happiness)
OFF_SPELL_RECORD_MANA_COST = 0x80, // u32 base cost
OFF_SPELL_RECORD_RANGE_INDEX = 0x90, // u32 → SpellRange.dbc
OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_A = 0x148,// i32[3] implicit target A
OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_B = 0x154,// i32[3] implicit target B
OFF_SPELL_RECORD_MANA_COST_PERCENT = 0x270, // i32 % of base resource (0 = flat)
OFF_SPELL_RECORD_RANK = 0x204, // char*[9] localized rank text
// Spell.dbc Mechanic field — the spell-level SpellMechanic ID (→
// SpellMechanic.dbc), 0 = none. Field 5 of the record
// (ID, School, Category, castUI, Dispel, Mechanic), which lands at
+4 -6
View File
@@ -30,11 +30,9 @@ namespace Aura::Data {
namespace {
// Spell.dbc record field offsets used locally. `spell/Info.cpp` has
// the same set of locals for `Script_GetSpellInfo`; promoting them
// to `Offsets.h` is a future refactor — for now we mirror its
// convention so both files stay in sync.
constexpr int OFF_SPELL_ICON_ID = 0x1D4;
// SpellIcon.dbc record's path field (char* at +0x04). This is a
// SpellIcon.dbc offset, not a Spell.dbc record field — the Spell.dbc
// offsets are all in `Offsets.h` as OFF_SPELL_RECORD_*.
constexpr int OFF_SPELLICON_PATH = 0x04;
const uint8_t *Descriptor(const uint8_t *unit) {
@@ -74,7 +72,7 @@ const char *SpellIconPath(const uint8_t *spellRecord) {
if (spellRecord == nullptr)
return nullptr;
const int iconID = *reinterpret_cast<const int *>(
spellRecord + OFF_SPELL_ICON_ID);
spellRecord + Offsets::OFF_SPELL_RECORD_ICON_ID);
if (iconID <= 0)
return nullptr;
return DBC::StringField(Offsets::VAR_SPELL_ICON_RECORDS,
+2 -6
View File
@@ -62,19 +62,15 @@ int NowMs() {
reinterpret_cast<TickMs_t>(Offsets::FUN_OS_TICKCOUNT_MS)());
}
// Spell.dbc field readers (mirrors the small locals in Spell::Cast).
constexpr int OFF_NAME = 0x1E0; // localized name[9]
constexpr int OFF_ICON_ID = 0x1D4; // -> SpellIcon.dbc
const char *SpellName(const uint8_t *rec) {
const int locale = *reinterpret_cast<int *>(Offsets::VAR_LOCALE_INDEX);
const char *n =
*reinterpret_cast<const char *const *>(rec + OFF_NAME + locale * 4);
*reinterpret_cast<const char *const *>(rec + Offsets::OFF_SPELL_NAMES + locale * 4);
return (n != nullptr) ? n : "";
}
const char *SpellIconPath(const uint8_t *rec) {
const int iconID = *reinterpret_cast<const int *>(rec + OFF_ICON_ID);
const int iconID = *reinterpret_cast<const int *>(rec + Offsets::OFF_SPELL_RECORD_ICON_ID);
const uint8_t *iconRec = DBC::Record(Offsets::VAR_SPELL_ICON_RECORDS,
Offsets::VAR_SPELL_ICON_COUNT,
static_cast<uint32_t>(iconID));
+1 -2
View File
@@ -46,7 +46,6 @@ namespace Macro::Spell {
namespace {
constexpr int OFF_SPELL_RANK = 0x204; // 9-locale char *[9] in Spell.dbc
using MacroSlotToEntry_t = const uint8_t *(__fastcall *)(unsigned slot0Based);
@@ -88,7 +87,7 @@ int __fastcall Script_GetMacroSpell(void *L) {
if (name == nullptr)
return 0;
const char *rank = *reinterpret_cast<const char *const *>(
record + OFF_SPELL_RANK + locale * 4);
record + Offsets::OFF_SPELL_RECORD_RANK + locale * 4);
Game::Lua::PushString(L, name);
// Rank slot is empty for most non-class spells (racials, procs,
+2 -4
View File
@@ -90,8 +90,6 @@ using GetCastTime_t = uint32_t(__fastcall *)(int spellID, int unit, int flag);
using GetDuration_t = int(__fastcall *)(const uint8_t *spellRecord, int unit, int skipMod);
// Spell.dbc record field offsets (mirrors Spell::Info's locals).
constexpr int OFF_NAME = 0x1E0; // localized name[9]
constexpr int OFF_ICON_ID = 0x1D4; // -> SpellIcon.dbc
constexpr int OFF_SUBRECORD_VALUE = 0x04; // SpellIcon path field
// SPELL_ATTR_TRADESPELL — set on profession recipe casts (enchant,
@@ -210,7 +208,7 @@ int ChannelDurationMs(int spellID) {
const char *SpellName(const uint8_t *rec) {
const int locale = *reinterpret_cast<int *>(Offsets::VAR_LOCALE_INDEX);
return *reinterpret_cast<const char *const *>(rec + OFF_NAME + locale * 4);
return *reinterpret_cast<const char *const *>(rec + Offsets::OFF_SPELL_NAMES + locale * 4);
}
bool IsTradeskill(const uint8_t *rec) {
@@ -222,7 +220,7 @@ bool IsTradeskill(const uint8_t *rec) {
// already stores the full "Interface\Icons\..." path (unlike item icons,
// which are bare filenames) — so it's used verbatim, no prefix.
const char *SpellIconPath(const uint8_t *rec) {
const int iconID = *reinterpret_cast<const int *>(rec + OFF_ICON_ID);
const int iconID = *reinterpret_cast<const int *>(rec + Offsets::OFF_SPELL_RECORD_ICON_ID);
const uint8_t *iconRec = DBC::Record(Offsets::VAR_SPELL_ICON_RECORDS,
Offsets::VAR_SPELL_ICON_COUNT,
static_cast<uint32_t>(iconID));
+1 -3
View File
@@ -19,8 +19,6 @@
namespace Spell::CastByID {
// Offset of the locale-resolved Name[9] table inside a Spell.dbc record.
static constexpr int OFF_NAME = 0x1E0;
using NameToSlot_t = int(__fastcall *)(const char *name, void *out);
static NameToSlot_t NameToSlot_o = nullptr;
@@ -48,7 +46,7 @@ static const char *LocaleNameForID(int spellID) {
return nullptr;
const int locale = *reinterpret_cast<const int *>(
static_cast<uintptr_t>(Offsets::VAR_LOCALE_INDEX));
return *reinterpret_cast<const char *const *>(record + OFF_NAME + locale * 4);
return *reinterpret_cast<const char *const *>(record + Offsets::OFF_SPELL_NAMES + locale * 4);
}
// Hook on the single name → spellbook-slot resolver
+8 -11
View File
@@ -29,9 +29,6 @@ namespace Spell::CastEvents {
namespace {
// Spell.dbc localized string arrays (9 locale slots, 4 bytes each).
constexpr int OFF_NAME = 0x1E0; // Name[9]
constexpr int OFF_RANK = 0x204; // Rank[9]
constexpr const char *kStart = "UNIT_SPELLCAST_START";
constexpr const char *kStop = "UNIT_SPELLCAST_STOP";
@@ -120,8 +117,8 @@ void Fire(const char *eventName, int spellID, int guidNum, int type = 3) {
char castGuid[48];
BuildCastGuid(castGuid, sizeof(castGuid), type, spellID, guidNum);
Event::Custom::Fire(slot, "%s%s%d%s%s", "player", castGuid, spellID,
LocalizedField(rec, OFF_NAME),
LocalizedField(rec, OFF_RANK));
LocalizedField(rec, Offsets::OFF_SPELL_NAMES),
LocalizedField(rec, Offsets::OFF_SPELL_RECORD_RANK));
}
// SENT is the one event whose shape differs from the rest, matching modern:
@@ -138,8 +135,8 @@ void FireSent(int spellID, int guidNum, const char *target) {
char castGuid[48];
BuildCastGuid(castGuid, sizeof(castGuid), /*type=*/3, spellID, guidNum);
Event::Custom::Fire(slot, "%s%s%s%d%s%s", "player", target ? target : "",
castGuid, spellID, LocalizedField(rec, OFF_NAME),
LocalizedField(rec, OFF_RANK));
castGuid, spellID, LocalizedField(rec, Offsets::OFF_SPELL_NAMES),
LocalizedField(rec, Offsets::OFF_SPELL_RECORD_RANK));
}
// Fire a RETICLE event `(unitTarget, castGUID, spellID, spellName, rank)`.
@@ -158,8 +155,8 @@ void FireReticle(const char *eventName, int spellID) {
if (rec == nullptr)
return;
Event::Custom::Fire(slot, "%s%s%d%s%s", "player", "", spellID,
LocalizedField(rec, OFF_NAME),
LocalizedField(rec, OFF_RANK));
LocalizedField(rec, Offsets::OFF_SPELL_NAMES),
LocalizedField(rec, Offsets::OFF_SPELL_RECORD_RANK));
}
// spellID whose reticle we last reported active (0 = no reticle up).
@@ -389,8 +386,8 @@ void FireRemote(const char *eventName, uint64_t casterGuid, int spellID,
return;
char castGuid[48];
BuildCastGuid(castGuid, sizeof(castGuid), /*type=*/3, spellID, guidNum);
const char *name = LocalizedField(rec, OFF_NAME);
const char *rank = LocalizedField(rec, OFF_RANK);
const char *name = LocalizedField(rec, Offsets::OFF_SPELL_NAMES);
const char *rank = LocalizedField(rec, Offsets::OFF_SPELL_RECORD_RANK);
for (int i = 0; i < n; ++i)
Event::Custom::Fire(slot, "%s%s%d%s%s", tokens[i], castGuid, spellID,
name, rank);
+1 -5
View File
@@ -52,10 +52,6 @@ namespace Spell::CastNoToggle {
namespace {
// Offset of the locale-resolved Name[9] table inside a Spell.dbc record
// (same value used by `Spell::Info`; duplicated here to keep this module
// header-free).
constexpr int OFF_NAME = 0x1E0;
using CastSpellByName_t = int(__fastcall *)(void *L);
using NameToSlot_t = int(__fastcall *)(const char *name, int *outBookType);
@@ -75,7 +71,7 @@ const char *LocaleName(int spellID) {
return nullptr;
const int locale = *reinterpret_cast<const int *>(
static_cast<uintptr_t>(Offsets::VAR_LOCALE_INDEX));
return *reinterpret_cast<const char *const *>(record + OFF_NAME + locale * 4);
return *reinterpret_cast<const char *const *>(record + Offsets::OFF_SPELL_NAMES + locale * 4);
}
// Case-insensitive name match for the auto-repeat-name gate. Walks
+12 -24
View File
@@ -22,15 +22,6 @@
namespace Spell::Info {
// Spell.dbc record offsets (from BuildSpellTooltip / Script_GetSpellName / Script_GetSpellTexture).
static constexpr int OFF_CASTING_TIME_INDEX = 0x48;
static constexpr int OFF_POWER_TYPE = 0x7C;
static constexpr int OFF_MANA_COST = 0x80;
static constexpr int OFF_RANGE_INDEX = 0x90;
static constexpr int OFF_ICON_ID = 0x1D4;
static constexpr int OFF_NAME = 0x1E0;
static constexpr int OFF_RANK = 0x204;
// Attributes (+0x18) bit 6 = SPELL_ATTR_PASSIVE — passive spell (no cast
// bar, applies its effect as soon as learned/equipped).
static constexpr uint32_t SPELL_ATTR_PASSIVE = 0x40;
@@ -50,9 +41,6 @@ static constexpr uint32_t SPELL_ATTR_EX2_HEALTH_FUNNEL = 0x800;
// have it), so we classify by walking effect targets and checking
// whether any falls into a known hostile-target or friendly-target
// set. Same algorithm CMaNGOS uses in `SpellMgr::IsPositiveSpell`.
static constexpr int OFF_EFFECT_IMPLICIT_TARGET_A = 0x148; // uint32[3]
static constexpr int OFF_EFFECT_IMPLICIT_TARGET_B = 0x154; // uint32[3]
// Target IDs from vanilla 1.12's `SpellTarget` enum that mark a
// spell as hostile-targeted (covers single-target damage,
// debuffs, AoE damage, etc.). List is conservative — anything not
@@ -144,26 +132,26 @@ static bool ReadSpellInfo(int spellID, SpellInfoData &out) {
const int locale = ReadGlobal<int>(Offsets::VAR_LOCALE_INDEX);
out.spellID = spellID;
out.name = *reinterpret_cast<const char *const *>(record + OFF_NAME + locale * 4);
out.rank = *reinterpret_cast<const char *const *>(record + OFF_RANK + locale * 4);
out.name = *reinterpret_cast<const char *const *>(record + Offsets::OFF_SPELL_NAMES + locale * 4);
out.rank = *reinterpret_cast<const char *const *>(record + Offsets::OFF_SPELL_RECORD_RANK + locale * 4);
out.iconPath = nullptr;
const int iconID = *reinterpret_cast<const int *>(record + OFF_ICON_ID);
const int iconID = *reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_ICON_ID);
if (auto *iconRec = LookupSubRecord(Offsets::VAR_SPELL_ICON_RECORDS,
Offsets::VAR_SPELL_ICON_COUNT, iconID)) {
out.iconPath = *reinterpret_cast<const char *const *>(iconRec + 4);
}
out.cost = *reinterpret_cast<const int *>(record + OFF_MANA_COST);
out.cost = *reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_MANA_COST);
const uint32_t attrEx2 = *reinterpret_cast<const uint32_t *>(
record + Offsets::OFF_SPELL_RECORD_ATTRIBUTES_EX2);
out.isFunnel = (attrEx2 & SPELL_ATTR_EX2_HEALTH_FUNNEL) != 0;
out.powerType = *reinterpret_cast<const int *>(record + OFF_POWER_TYPE);
out.powerType = *reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_POWER_TYPE);
out.castTimeMs = 0;
const int castIndex = *reinterpret_cast<const int *>(record + OFF_CASTING_TIME_INDEX);
const int castIndex = *reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_CASTING_TIME_INDEX);
if (auto *castRec = LookupSubRecord(Offsets::VAR_SPELL_CAST_TIMES_RECORDS,
Offsets::VAR_SPELL_CAST_TIMES_COUNT, castIndex)) {
out.castTimeMs = *reinterpret_cast<const int *>(castRec + 4);
@@ -171,7 +159,7 @@ static bool ReadSpellInfo(int spellID, SpellInfoData &out) {
out.minRange = 0.0f;
out.maxRange = 0.0f;
const int rangeIndex = *reinterpret_cast<const int *>(record + OFF_RANGE_INDEX);
const int rangeIndex = *reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_RANGE_INDEX);
if (auto *rangeRec = LookupSubRecord(Offsets::VAR_SPELL_RANGE_RECORDS,
Offsets::VAR_SPELL_RANGE_COUNT, rangeIndex)) {
out.minRange = *reinterpret_cast<const float *>(rangeRec + 4);
@@ -291,7 +279,7 @@ static int __fastcall Script_C_GetSpellName(void *L) {
return 0; // nil for unknown spellID
const int locale = ReadGlobal<int>(Offsets::VAR_LOCALE_INDEX);
const char *name = *reinterpret_cast<const char *const *>(record + OFF_NAME + locale * 4);
const char *name = *reinterpret_cast<const char *const *>(record + Offsets::OFF_SPELL_NAMES + locale * 4);
if (name == nullptr || *name == '\0')
return 0; // empty / no name in current locale → nil
Game::Lua::PushString(L, name);
@@ -304,7 +292,7 @@ static int __fastcall Script_C_GetSpellTexture(void *L) {
if (record == nullptr)
return 0;
const int iconID = *reinterpret_cast<const int *>(record + OFF_ICON_ID);
const int iconID = *reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_ICON_ID);
auto *iconRec = LookupSubRecord(Offsets::VAR_SPELL_ICON_RECORDS,
Offsets::VAR_SPELL_ICON_COUNT, iconID);
if (iconRec == nullptr)
@@ -330,7 +318,7 @@ static bool BuildSpellLink(int spellID, char *out, size_t outLen) {
if (record == nullptr)
return false;
const int locale = ReadGlobal<int>(Offsets::VAR_LOCALE_INDEX);
const char *name = *reinterpret_cast<const char *const *>(record + OFF_NAME + locale * 4);
const char *name = *reinterpret_cast<const char *const *>(record + Offsets::OFF_SPELL_NAMES + locale * 4);
if (name == nullptr || *name == '\0')
return false;
const int n = std::snprintf(out, outLen, "|cff71d5ff|Hspell:%d:0|h[%s]|h|r",
@@ -538,9 +526,9 @@ static bool AnyEffectTarget(const uint8_t *record, Pred pred) {
if (record == nullptr)
return false;
auto *targetsA = reinterpret_cast<const uint32_t *>(
record + OFF_EFFECT_IMPLICIT_TARGET_A);
record + Offsets::OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_A);
auto *targetsB = reinterpret_cast<const uint32_t *>(
record + OFF_EFFECT_IMPLICIT_TARGET_B);
record + Offsets::OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_B);
for (int i = 0; i < 3; ++i) {
if (pred(targetsA[i]) || pred(targetsB[i]))
return true;
+3 -6
View File
@@ -35,9 +35,6 @@ namespace {
// Spell.dbc per-effect arrays. Each is an int32[3] in the record.
// Field-index derivation against the known `EffectApplyAuraName` at
// field 91 / +0x16C — the implicit-target pair sits at field 82/85.
constexpr int OFF_SPELL_EFFECT = 0xF4; // SPELL_EFFECT_* code
constexpr int OFF_SPELL_EFFECT_TARGET_A = 0x148;
constexpr int OFF_SPELL_EFFECT_TARGET_B = 0x154;
constexpr int EFFECT_COUNT = 3;
// Vanilla 1.12 implicit-target codes (CMaNGOS `Targets` enum).
@@ -61,14 +58,14 @@ bool IsSelfBuff(uint32_t spellID) {
bool sawEffect = false;
for (int i = 0; i < EFFECT_COUNT; ++i) {
const int effect = *reinterpret_cast<const int *>(
rec + OFF_SPELL_EFFECT + i * 4);
rec + Offsets::OFF_SPELL_RECORD_EFFECT + i * 4);
if (effect == 0)
continue;
sawEffect = true;
const int targetA = *reinterpret_cast<const int *>(
rec + OFF_SPELL_EFFECT_TARGET_A + i * 4);
rec + Offsets::OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_A + i * 4);
const int targetB = *reinterpret_cast<const int *>(
rec + OFF_SPELL_EFFECT_TARGET_B + i * 4);
rec + Offsets::OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_B + i * 4);
if (!IsSelfOnlyTarget(targetA) || !IsSelfOnlyTarget(targetB))
return false;
}
+6 -11
View File
@@ -130,11 +130,6 @@ bool SpellHiddenFromSpellbook(int spellID) {
// checks are NOT in the 1.12 client's Spell.dbc — server-only columns — so
// the spellLevel rule is the only client-readable target-level mechanism.)
constexpr int OFF_SPELL_MAX_LEVEL = 0x6C; // uint32 (scaling cap level)
constexpr int OFF_SPELL_SPELL_LEVEL = 0x74; // uint32 (rank's effective level)
constexpr int OFF_SPELL_EFFECT = 0xF4; // uint32[3] effect type
constexpr int OFF_SPELL_EFFECT_TARGET_A = 0x148; // uint32[3] implicit target A
constexpr int OFF_SPELL_RANK = 0x204; // char*[9] localized rank text
constexpr uint32_t SPELL_ATTR_PASSIVE = 0x40; // Attributes bit
constexpr uint32_t SPELL_EFFECT_APPLY_AURA = 6;
constexpr uint32_t SPELL_EFFECT_APPLY_AREA_AURA_PARTY = 35;
@@ -176,7 +171,7 @@ bool IsPositiveRankTarget(uint32_t t) {
// empty Rank and un-gated) vs ranked ones (Divine Spirit / Fortitude).
bool HasRankString(const uint8_t *record) {
const char *rank = *reinterpret_cast<const char *const *>(
record + OFF_SPELL_RANK + LocaleIndex() * 4);
record + Offsets::OFF_SPELL_RECORD_RANK + LocaleIndex() * 4);
return rank != nullptr && *rank != '\0';
}
@@ -184,7 +179,7 @@ bool HasRankString(const uint8_t *record) {
// the spell isn't subject to the ranked-positive-aura target-level rule.
int RequiredTargetLevel(const uint8_t *record) {
const int spellLevel =
*reinterpret_cast<const int *>(record + OFF_SPELL_SPELL_LEVEL);
*reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_SPELL_LEVEL);
if (spellLevel <= 10) // targetLevel + 10 >= spellLevel holds for any level
return 0;
const uint32_t attr =
@@ -194,9 +189,9 @@ int RequiredTargetLevel(const uint8_t *record) {
if (!HasRankString(record)) // single-rank spell → not gated
return 0;
auto *effect = reinterpret_cast<const uint32_t *>(record + OFF_SPELL_EFFECT);
auto *effect = reinterpret_cast<const uint32_t *>(record + Offsets::OFF_SPELL_RECORD_EFFECT);
auto *targetA =
reinterpret_cast<const uint32_t *>(record + OFF_SPELL_EFFECT_TARGET_A);
reinterpret_cast<const uint32_t *>(record + Offsets::OFF_SPELL_RECORD_EFFECT_IMPLICIT_TARGET_A);
bool positiveAura = false;
for (int i = 0; i < 3; ++i) {
if ((effect[i] == SPELL_EFFECT_APPLY_AURA &&
@@ -227,13 +222,13 @@ int __fastcall Script_GetSpellLevelInfo(void *L) {
return 0;
Game::Lua::PushNumber(
L, static_cast<double>(
*reinterpret_cast<const int *>(record + OFF_SPELL_SPELL_LEVEL)));
*reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_SPELL_LEVEL)));
Game::Lua::PushNumber(
L, static_cast<double>(
*reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_BASE_LEVEL)));
Game::Lua::PushNumber(
L, static_cast<double>(
*reinterpret_cast<const int *>(record + OFF_SPELL_MAX_LEVEL)));
*reinterpret_cast<const int *>(record + Offsets::OFF_SPELL_RECORD_MAX_LEVEL)));
return 3;
}
+2 -4
View File
@@ -49,8 +49,6 @@ namespace {
using GetSpellCost_t = uint32_t(__fastcall *)(int spellID, int unit);
constexpr int OFF_POWER_TYPE = 0x7C; // int PowerType
constexpr int OFF_MANA_COST_PERCENT = 0x270; // int, % of base resource (0 = flat)
uint32_t EffectiveCost(int spellID) {
return reinterpret_cast<GetSpellCost_t>(Offsets::FUN_GET_SPELL_COST)(spellID, 0);
@@ -66,8 +64,8 @@ int __fastcall Script_GetSpellPowerCost(void *L) {
if (cost == 0xFFFFFFFF)
return 0; // engine error (no player context, etc.)
const int powerType = *reinterpret_cast<const int *>(rec + OFF_POWER_TYPE);
const int costPercent = *reinterpret_cast<const int *>(rec + OFF_MANA_COST_PERCENT);
const int powerType = *reinterpret_cast<const int *>(rec + Offsets::OFF_SPELL_RECORD_POWER_TYPE);
const int costPercent = *reinterpret_cast<const int *>(rec + Offsets::OFF_SPELL_RECORD_MANA_COST_PERCENT);
if (cost == 0 && costPercent == 0)
return 0; // nil — no resource cost
+1 -2
View File
@@ -23,7 +23,6 @@ namespace {
// Spell.dbc RangeIndex + SpellRange.dbc min/max offsets (verified,
// documented in CLAUDE.md under "Sub-DBC record layouts").
constexpr int OFF_SPELL_RANGE_INDEX = 0x90;
constexpr int OFF_SPELLRANGE_MIN = 0x04;
constexpr int OFF_SPELLRANGE_MAX = 0x08;
@@ -42,7 +41,7 @@ bool SpellIDHasRange(int spellID) {
if (rec == nullptr)
return false;
const uint32_t rangeIdx =
*reinterpret_cast<const uint32_t *>(rec + OFF_SPELL_RANGE_INDEX);
*reinterpret_cast<const uint32_t *>(rec + Offsets::OFF_SPELL_RECORD_RANGE_INDEX);
if (rangeIdx == 0)
return false;
const uint8_t *rangeRec = DBC::Record(Offsets::VAR_SPELL_RANGE_RECORDS,
+1 -6
View File
@@ -29,11 +29,6 @@ namespace Spell::Subtext {
namespace {
// `Spell.dbc.Rank[9]` — same 9-slot locale-string array shape as the
// adjacent `Name[9]` field. Defined locally; sibling modules
// (`Info.cpp`, `Tooltip.cpp`, `macro/Spell.cpp`) carry the same
// constant — promoting to `Offsets.h` is a future refactor.
constexpr int OFF_SPELL_RANK = 0x204;
} // namespace
@@ -46,7 +41,7 @@ static int __fastcall Script_GetSpellSubtext(void *L) {
const char *subtext = DBC::LocalizedField(Offsets::VAR_SPELL_RECORDS,
Offsets::VAR_SPELL_RECORD_COUNT,
static_cast<uint32_t>(spellID),
OFF_SPELL_RANK);
Offsets::OFF_SPELL_RECORD_RANK);
if (subtext == nullptr) {
Game::Lua::PushNil(L);
return 1;
+3 -5
View File
@@ -24,8 +24,6 @@ namespace Spell::Tooltip {
// pulled from Spell::Info — that module keeps these as `static
// constexpr` privates and exposing them just for two readers here
// would force a header change.
static constexpr int OFF_SPELL_NAME = 0x1E0; // localized char *[9]
static constexpr int OFF_SPELL_RANK = 0x204; // localized char *[9]
using BuildSpellTooltip_t = void(__thiscall *)(void *thisObj, int spellID, int arg2, int arg3,
int isPet, int showRank, int arg6, int arg7);
@@ -94,7 +92,7 @@ void AppendByID(void *L, int spellID) {
return;
const int locale = *reinterpret_cast<const int *>(Offsets::VAR_LOCALE_INDEX);
const char *name = *reinterpret_cast<const char *const *>(
record + OFF_SPELL_NAME + locale * 4);
record + Offsets::OFF_SPELL_NAMES + locale * 4);
if (name == nullptr || name[0] == '\0')
return;
@@ -154,9 +152,9 @@ static int __fastcall Script_GameTooltipGetSpell(void *L) {
const int locale = *reinterpret_cast<const int *>(Offsets::VAR_LOCALE_INDEX);
const char *name = *reinterpret_cast<const char *const *>(
record + OFF_SPELL_NAME + locale * 4);
record + Offsets::OFF_SPELL_NAMES + locale * 4);
const char *rank = *reinterpret_cast<const char *const *>(
record + OFF_SPELL_RANK + locale * 4);
record + Offsets::OFF_SPELL_RECORD_RANK + locale * 4);
if (name == nullptr)
return 0;
+2 -4
View File
@@ -29,8 +29,6 @@ using GetSpellCost_t = uint32_t(__fastcall *)(int spellID, int unit);
// Spell.dbc record field offsets we read for usability. Fully documented
// in CLAUDE.md.
constexpr int OFF_SPELL_POWER_TYPE = 0x7C; // int8: 0=mana, 1=rage, 2=focus, 3=energy, 4=happiness
constexpr int OFF_SPELL_MANA_COST = 0x80; // u32 base cost (fallback only)
// Returns true if the player knows `spellID` per the engine's spell-
// knowledge bitmap at `[VAR_PLAYER_SPELL_BITMAP]`. Same check
@@ -179,12 +177,12 @@ Usability ComputeUsability(void *L, int spellID) {
// resolve a cost (shouldn't happen here: the player descriptor
// resolved above, so it has a player context).
const int powerType = static_cast<int>(*reinterpret_cast<const int8_t *>(
record + OFF_SPELL_POWER_TYPE));
record + Offsets::OFF_SPELL_RECORD_POWER_TYPE));
if (powerType >= 0 && powerType <= 4) {
auto getCost = reinterpret_cast<GetSpellCost_t>(Offsets::FUN_GET_SPELL_COST);
uint32_t cost = getCost(spellID, 0 /* local player */);
if (cost == 0xFFFFFFFF)
cost = *reinterpret_cast<const uint32_t *>(record + OFF_SPELL_MANA_COST);
cost = *reinterpret_cast<const uint32_t *>(record + Offsets::OFF_SPELL_RECORD_MANA_COST);
if (cost > 0) {
const int currentPower = *reinterpret_cast<const int *>(
desc + Offsets::OFF_UNIT_FIELD_POWER1 + powerType * 4);
+5 -8
View File
@@ -57,11 +57,8 @@ namespace Totem::Tracker {
namespace {
// Spell.dbc record field offsets (see spell/Info.cpp for the shared set).
constexpr int OFF_EFFECT = 0xF4; // int32[3] — SPELL_EFFECT_*
constexpr int OFF_TOTEM_TOOL = 0xA0; // int32[2] — Totem (required tool item IDs)
constexpr int OFF_MISC_VALUE = 0x1A8; // int32[3] — EffectMiscValue
constexpr int OFF_ICON_ID = 0x1D4; // int32 — SpellIconID
constexpr int OFF_NAME = 0x1E0; // char*[9] locale array
// SUMMON_TOTEM_SLOT1..4 spell effects (verified against Spell.dbc: Searing
// 87/Fire, Stoneskin 88/Earth, Healing Stream 89/Water, Windfury 90/Air).
@@ -131,7 +128,7 @@ void ScanTools() {
const uint8_t *rec = Spell::Lookup::RecordForID(spellID);
if (rec == nullptr)
continue;
const auto *eff = reinterpret_cast<const int32_t *>(rec + OFF_EFFECT);
const auto *eff = reinterpret_cast<const int32_t *>(rec + Offsets::OFF_SPELL_RECORD_EFFECT);
for (int i = 0; i < Offsets::SPELL_RECORD_EFFECT_COUNT; ++i) {
const int e = eff[i];
if (e < kEffectSummonTotemSlot1 || e > kEffectSummonTotemSlot4)
@@ -413,10 +410,10 @@ int __fastcall Script_GetTotemInfo(void *L) {
*reinterpret_cast<const int *>(static_cast<uintptr_t>(
Offsets::VAR_LOCALE_INDEX));
const char *n = *reinterpret_cast<const char *const *>(
rec + OFF_NAME + locale * 4);
rec + Offsets::OFF_SPELL_NAMES + locale * 4);
if (n != nullptr)
name = n;
icon = IconPath(*reinterpret_cast<const int *>(rec + OFF_ICON_ID));
icon = IconPath(*reinterpret_cast<const int *>(rec + Offsets::OFF_SPELL_RECORD_ICON_ID));
}
Game::Lua::PushBool(L, haveTotem);
@@ -563,7 +560,7 @@ int __fastcall Script_GameTooltipSetTotem(void *L) {
const int locale =
*reinterpret_cast<const int *>(static_cast<uintptr_t>(Offsets::VAR_LOCALE_INDEX));
const char *name =
*reinterpret_cast<const char *const *>(rec + OFF_NAME + locale * 4);
*reinterpret_cast<const char *const *>(rec + Offsets::OFF_SPELL_NAMES + locale * 4);
if (name == nullptr || name[0] == '\0')
return 0;
@@ -630,7 +627,7 @@ void OnPlayerSpellGo(uint32_t spellID) {
if (rec == nullptr)
return;
const auto *effects = reinterpret_cast<const int32_t *>(rec + OFF_EFFECT);
const auto *effects = reinterpret_cast<const int32_t *>(rec + Offsets::OFF_SPELL_RECORD_EFFECT);
const auto *misc = reinterpret_cast<const int32_t *>(rec + OFF_MISC_VALUE);
for (int i = 0; i < Offsets::SPELL_RECORD_EFFECT_COUNT; ++i) {
const int eff = effects[i];