Fix buff bar: opcode merge, isBuff flag, and duration countdown

Root cause: OpcodeTable::loadFromJson() cleared all mappings before
loading the expansion JSON, so any WotLK opcode absent from Turtle WoW's
opcodes.json (including SMSG_AURA_UPDATE and SMSG_AURA_UPDATE_ALL) was
permanently lost. Changed loadFromJson to patch/merge on top of existing
defaults so only explicitly listed opcodes are overridden.

Also fix isBuff border color: was testing flag 0x02 (effect 2 active)
instead of 0x80 (negative/debuff flag).

Add client-side duration countdown: AuraSlot.receivedAtMs is stamped
when the packet arrives; getRemainingMs(nowMs) subtracts elapsed time so
buff tooltips show accurate remaining duration instead of stale snapshot.
This commit is contained in:
Kelsi 2026-02-17 15:49:12 -08:00
parent df0bfaea4f
commit 55fd692c1a
4 changed files with 32 additions and 9 deletions

View file

@ -698,13 +698,12 @@ bool OpcodeTable::loadFromJson(const std::string& path) {
std::string json((std::istreambuf_iterator<char>(f)), std::istreambuf_iterator<char>());
// Save old tables so we can restore on failure
// Merge/patch on top of existing table (WotLK defaults must be loaded first).
// Opcodes NOT in the JSON keep their current mapping, so expansion-specific
// JSONs only need to list entries that differ from the WotLK baseline.
auto savedLogicalToWire = logicalToWire_;
auto savedWireToLogical = wireToLogical_;
logicalToWire_.clear();
wireToLogical_.clear();
// Parse simple JSON: { "NAME": "0xHEX", ... } or { "NAME": 123, ... }
size_t pos = 0;
size_t loaded = 0;
@ -746,6 +745,11 @@ bool OpcodeTable::loadFromJson(const std::string& path) {
auto logOp = nameToLogical(key);
if (logOp) {
uint16_t logIdx = static_cast<uint16_t>(*logOp);
// Remove stale reverse-mapping for this logical opcode's old wire value
auto oldIt = logicalToWire_.find(logIdx);
if (oldIt != logicalToWire_.end()) {
wireToLogical_.erase(oldIt->second);
}
logicalToWire_[logIdx] = wire;
wireToLogical_[wire] = logIdx;
++loaded;