From 1fb1daea7f61e6265b32c5d188c2f88ac2446421 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 19 Feb 2026 19:33:50 -0800 Subject: [PATCH] =?UTF-8?q?Fix=20UNIT=5FFIELD=5FBYTES=5F0=20index=20(56?= =?UTF-8?q?=E2=86=9223)=20and=20add=20per-type=20power=20arrays=20to=20Uni?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Correct UNIT_FIELD_BYTES_0 to index 23 (was incorrectly 56) in update fields JSON and table - Replace single power/maxPower with powers[7]/maxPowers[7] arrays indexed by power type - Add setPowerByType/setMaxPowerByType helpers for setting specific power types --- Data/expansions/wotlk/update_fields.json | 2 +- include/game/entity.hpp | 18 ++++++++++-------- src/game/update_field_table.cpp | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/Data/expansions/wotlk/update_fields.json b/Data/expansions/wotlk/update_fields.json index c26aefe6..12f92ceb 100644 --- a/Data/expansions/wotlk/update_fields.json +++ b/Data/expansions/wotlk/update_fields.json @@ -2,7 +2,7 @@ "OBJECT_FIELD_ENTRY": 3, "UNIT_FIELD_TARGET_LO": 6, "UNIT_FIELD_TARGET_HI": 7, - "UNIT_FIELD_BYTES_0": 56, + "UNIT_FIELD_BYTES_0": 23, "UNIT_FIELD_HEALTH": 24, "UNIT_FIELD_POWER1": 25, "UNIT_FIELD_MAXHEALTH": 32, diff --git a/include/game/entity.hpp b/include/game/entity.hpp index 702bf7a0..9f4dfde7 100644 --- a/include/game/entity.hpp +++ b/include/game/entity.hpp @@ -205,12 +205,14 @@ public: uint32_t getMaxHealth() const { return maxHealth; } void setMaxHealth(uint32_t h) { maxHealth = h; } - // Power (mana/rage/energy) - uint32_t getPower() const { return power; } - void setPower(uint32_t p) { power = p; } + // Power (mana/rage/energy) — indexed by power type (0-6) + uint32_t getPower() const { return powers[powerType < 7 ? powerType : 0]; } + void setPower(uint32_t p) { powers[powerType < 7 ? powerType : 0] = p; } + void setPowerByType(uint8_t type, uint32_t p) { if (type < 7) powers[type] = p; } - uint32_t getMaxPower() const { return maxPower; } - void setMaxPower(uint32_t p) { maxPower = p; } + uint32_t getMaxPower() const { return maxPowers[powerType < 7 ? powerType : 0]; } + void setMaxPower(uint32_t p) { maxPowers[powerType < 7 ? powerType : 0] = p; } + void setMaxPowerByType(uint8_t type, uint32_t p) { if (type < 7) maxPowers[type] = p; } uint8_t getPowerType() const { return powerType; } void setPowerType(uint8_t t) { powerType = t; } @@ -256,9 +258,9 @@ protected: std::string name; uint32_t health = 0; uint32_t maxHealth = 0; - uint32_t power = 0; - uint32_t maxPower = 0; - uint8_t powerType = 0; // 0=mana, 1=rage, 2=focus, 3=energy + uint32_t powers[7] = {}; // Indexed by power type (0=mana,1=rage,2=focus,3=energy,4=happiness,5=runes,6=runic) + uint32_t maxPowers[7] = {}; // Max values per power type + uint8_t powerType = 0; // Active power type uint32_t level = 1; uint32_t entry = 0; uint32_t displayId = 0; diff --git a/src/game/update_field_table.cpp b/src/game/update_field_table.cpp index 33bf038e..1c072bbc 100644 --- a/src/game/update_field_table.cpp +++ b/src/game/update_field_table.cpp @@ -64,7 +64,7 @@ void UpdateFieldTable::loadWotlkDefaults() { {UF::OBJECT_FIELD_ENTRY, 3}, {UF::UNIT_FIELD_TARGET_LO, 6}, {UF::UNIT_FIELD_TARGET_HI, 7}, - {UF::UNIT_FIELD_BYTES_0, 56}, + {UF::UNIT_FIELD_BYTES_0, 23}, {UF::UNIT_FIELD_HEALTH, 24}, {UF::UNIT_FIELD_POWER1, 25}, {UF::UNIT_FIELD_MAXHEALTH, 32},