mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-05-03 08:03:50 +00:00
fix: restore Classic aura flag normalization and clean up EntityController
- Restore 0x02→0x80 Classic harmful-to-WotLK debuff bit mapping in syncClassicAurasFromFields so downstream checks work across expansions - Extract handleDisplayIdChange helper to deduplicate identical logic in onValuesUpdateUnit and onValuesUpdatePlayer - Remove unused newItemCreated parameter from handleValuesUpdate - Fix indentation on PLAYER_DEAD/PLAYER_ALIVE/PLAYER_UNGHOST emit calls
This commit is contained in:
parent
1988b53619
commit
d32b35c583
2 changed files with 42 additions and 45 deletions
|
|
@ -152,7 +152,7 @@ private:
|
||||||
|
|
||||||
// --- Phase 2: Update type handlers ---
|
// --- Phase 2: Update type handlers ---
|
||||||
void handleCreateObject(const UpdateBlock& block, bool& newItemCreated);
|
void handleCreateObject(const UpdateBlock& block, bool& newItemCreated);
|
||||||
void handleValuesUpdate(const UpdateBlock& block, bool& newItemCreated);
|
void handleValuesUpdate(const UpdateBlock& block);
|
||||||
void handleMovementUpdate(const UpdateBlock& block);
|
void handleMovementUpdate(const UpdateBlock& block);
|
||||||
|
|
||||||
// --- Phase 3: Concern-specific helpers ---
|
// --- Phase 3: Concern-specific helpers ---
|
||||||
|
|
@ -253,6 +253,10 @@ private:
|
||||||
void onCreateGameObject(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
void onCreateGameObject(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
||||||
void onCreateItem(const UpdateBlock& block, bool& newItemCreated);
|
void onCreateItem(const UpdateBlock& block, bool& newItemCreated);
|
||||||
void onCreateCorpse(const UpdateBlock& block);
|
void onCreateCorpse(const UpdateBlock& block);
|
||||||
|
void handleDisplayIdChange(const UpdateBlock& block,
|
||||||
|
const std::shared_ptr<Entity>& entity,
|
||||||
|
const std::shared_ptr<Unit>& unit,
|
||||||
|
const UnitFieldUpdateResult& result);
|
||||||
void onValuesUpdateUnit(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
void onValuesUpdateUnit(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
||||||
void onValuesUpdatePlayer(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
void onValuesUpdatePlayer(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
||||||
void onValuesUpdateItem(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
void onValuesUpdateItem(const UpdateBlock& block, std::shared_ptr<Entity>& entity);
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,7 @@ void EntityController::applyUpdateObjectBlock(const UpdateBlock& block, bool& ne
|
||||||
handleCreateObject(block, newItemCreated);
|
handleCreateObject(block, newItemCreated);
|
||||||
break;
|
break;
|
||||||
case UpdateType::VALUES:
|
case UpdateType::VALUES:
|
||||||
handleValuesUpdate(block, newItemCreated);
|
handleValuesUpdate(block);
|
||||||
break;
|
break;
|
||||||
case UpdateType::MOVEMENT:
|
case UpdateType::MOVEMENT:
|
||||||
handleMovementUpdate(block);
|
handleMovementUpdate(block);
|
||||||
|
|
@ -433,9 +433,8 @@ void EntityController::updateNonPlayerTransportAttachment(const UpdateBlock& blo
|
||||||
// 3f: Rebuild playerAuras from UNIT_FIELD_AURAS (Classic/vanilla only).
|
// 3f: Rebuild playerAuras from UNIT_FIELD_AURAS (Classic/vanilla only).
|
||||||
// blockFields is used to check if any aura field was updated in this packet.
|
// blockFields is used to check if any aura field was updated in this packet.
|
||||||
// entity->getFields() is used for reading the full accumulated state.
|
// entity->getFields() is used for reading the full accumulated state.
|
||||||
// Note: CREATE originally normalised Classic flags (0x02→0x80) while VALUES
|
// Normalises Classic harmful bit (0x02) to WotLK debuff bit (0x80) so
|
||||||
// used raw bytes; VALUES runs more frequently and overwrites CREATE's mapping
|
// downstream code checking for 0x80 works consistently across expansions.
|
||||||
// immediately, so the helper uses raw bytes (matching VALUES behaviour).
|
|
||||||
void EntityController::syncClassicAurasFromFields(const std::shared_ptr<Entity>& entity) {
|
void EntityController::syncClassicAurasFromFields(const std::shared_ptr<Entity>& entity) {
|
||||||
if (!isClassicLikeExpansion() || !owner_.spellHandler_) return;
|
if (!isClassicLikeExpansion() || !owner_.spellHandler_) return;
|
||||||
|
|
||||||
|
|
@ -467,6 +466,10 @@ void EntityController::syncClassicAurasFromFields(const std::shared_ptr<Entity>&
|
||||||
if (fit != allFields.end())
|
if (fit != allFields.end())
|
||||||
aFlag = static_cast<uint8_t>((fit->second >> ((slot % 4) * 8)) & 0xFF);
|
aFlag = static_cast<uint8_t>((fit->second >> ((slot % 4) * 8)) & 0xFF);
|
||||||
}
|
}
|
||||||
|
// Normalize Classic harmful bit (0x02) to WotLK debuff bit (0x80)
|
||||||
|
// so downstream code checking for 0x80 works consistently.
|
||||||
|
if (aFlag & 0x02)
|
||||||
|
aFlag = (aFlag & ~0x02) | 0x80;
|
||||||
a.flags = aFlag;
|
a.flags = aFlag;
|
||||||
a.durationMs = -1;
|
a.durationMs = -1;
|
||||||
a.maxDurationMs = -1;
|
a.maxDurationMs = -1;
|
||||||
|
|
@ -1507,14 +1510,14 @@ void EntityController::onCreateCorpse(const UpdateBlock& block) {
|
||||||
// Phase 5: Type-specific VALUES UPDATE handlers
|
// Phase 5: Type-specific VALUES UPDATE handlers
|
||||||
// ============================================================
|
// ============================================================
|
||||||
|
|
||||||
void EntityController::onValuesUpdateUnit(const UpdateBlock& block, std::shared_ptr<Entity>& entity) {
|
void EntityController::handleDisplayIdChange(const UpdateBlock& block,
|
||||||
auto unit = std::static_pointer_cast<Unit>(entity);
|
const std::shared_ptr<Entity>& entity,
|
||||||
UnitFieldIndices ufi = UnitFieldIndices::resolve();
|
const std::shared_ptr<Unit>& unit,
|
||||||
UnitFieldUpdateResult result = applyUnitFieldsOnUpdate(block, entity, unit, ufi);
|
const UnitFieldUpdateResult& result) {
|
||||||
|
if (!result.displayIdChanged || unit->getDisplayId() == 0 ||
|
||||||
|
unit->getDisplayId() == result.oldDisplayId)
|
||||||
|
return;
|
||||||
|
|
||||||
// Display ID changed — re-spawn/model-change notification
|
|
||||||
if (result.displayIdChanged && unit->getDisplayId() != 0 &&
|
|
||||||
unit->getDisplayId() != result.oldDisplayId) {
|
|
||||||
constexpr uint32_t UNIT_DYNFLAG_DEAD = 0x0008;
|
constexpr uint32_t UNIT_DYNFLAG_DEAD = 0x0008;
|
||||||
constexpr uint32_t UNIT_DYNFLAG_LOOTABLE = 0x0001;
|
constexpr uint32_t UNIT_DYNFLAG_LOOTABLE = 0x0001;
|
||||||
bool isDeadNow = (unit->getHealth() == 0) ||
|
bool isDeadNow = (unit->getHealth() == 0) ||
|
||||||
|
|
@ -1529,7 +1532,13 @@ void EntityController::onValuesUpdateUnit(const UpdateBlock& block, std::shared_
|
||||||
if (!uid.empty())
|
if (!uid.empty())
|
||||||
pendingEvents_.emit("UNIT_MODEL_CHANGED", {uid});
|
pendingEvents_.emit("UNIT_MODEL_CHANGED", {uid});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EntityController::onValuesUpdateUnit(const UpdateBlock& block, std::shared_ptr<Entity>& entity) {
|
||||||
|
auto unit = std::static_pointer_cast<Unit>(entity);
|
||||||
|
UnitFieldIndices ufi = UnitFieldIndices::resolve();
|
||||||
|
UnitFieldUpdateResult result = applyUnitFieldsOnUpdate(block, entity, unit, ufi);
|
||||||
|
handleDisplayIdChange(block, entity, unit, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityController::onValuesUpdatePlayer(const UpdateBlock& block, std::shared_ptr<Entity>& entity) {
|
void EntityController::onValuesUpdatePlayer(const UpdateBlock& block, std::shared_ptr<Entity>& entity) {
|
||||||
|
|
@ -1549,23 +1558,7 @@ void EntityController::onValuesUpdatePlayer(const UpdateBlock& block, std::share
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3e: Display ID changed — re-spawn/model-change
|
// 3e: Display ID changed — re-spawn/model-change
|
||||||
if (result.displayIdChanged && unit->getDisplayId() != 0 &&
|
handleDisplayIdChange(block, entity, unit, result);
|
||||||
unit->getDisplayId() != result.oldDisplayId) {
|
|
||||||
constexpr uint32_t UNIT_DYNFLAG_DEAD = 0x0008;
|
|
||||||
constexpr uint32_t UNIT_DYNFLAG_LOOTABLE = 0x0001;
|
|
||||||
bool isDeadNow = (unit->getHealth() == 0) ||
|
|
||||||
((unit->getDynamicFlags() & (UNIT_DYNFLAG_DEAD | UNIT_DYNFLAG_LOOTABLE)) != 0);
|
|
||||||
dispatchEntitySpawn(block.guid, entity->getType(), entity, unit,
|
|
||||||
isDeadNow && !result.npcDeathNotified);
|
|
||||||
if (owner_.addonEventCallback_) {
|
|
||||||
std::string uid;
|
|
||||||
if (block.guid == owner_.targetGuid) uid = "target";
|
|
||||||
else if (block.guid == owner_.focusGuid) uid = "focus";
|
|
||||||
else if (block.guid == owner_.petGuid_) uid = "pet";
|
|
||||||
if (!uid.empty())
|
|
||||||
pendingEvents_.emit("UNIT_MODEL_CHANGED", {uid});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3d: Self-player stat/inventory/quest field updates
|
// 3d: Self-player stat/inventory/quest field updates
|
||||||
if (block.guid == owner_.playerGuid) {
|
if (block.guid == owner_.playerGuid) {
|
||||||
|
|
@ -1669,7 +1662,7 @@ void EntityController::handleCreateObject(const UpdateBlock& block, bool& newIte
|
||||||
flushPendingEvents();
|
flushPendingEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityController::handleValuesUpdate(const UpdateBlock& block, bool& /*newItemCreated*/) {
|
void EntityController::handleValuesUpdate(const UpdateBlock& block) {
|
||||||
auto entity = entityManager.getEntity(block.guid);
|
auto entity = entityManager.getEntity(block.guid);
|
||||||
if (!entity) return;
|
if (!entity) return;
|
||||||
pendingEvents_.clear();
|
pendingEvents_.clear();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue