fix: operator precedence broke stabled pet parsing — only first pet shown

!packet.hasRemaining(4) + 4 + 4 evaluated as (!hasRemaining(4))+8
due to ! binding tighter than +, making the check always truthy and
breaking out of the loop after the first pet. Hunters with multiple
stabled pets would see only one in the stable master UI.
This commit is contained in:
Kelsi 2026-03-29 18:46:15 -07:00
parent f681de0a08
commit 3712e6c5c1

View file

@ -1546,13 +1546,15 @@ void SpellHandler::handleListStabledPets(network::Packet& packet) {
owner_.stabledPets_.reserve(petCount);
for (uint8_t i = 0; i < petCount; ++i) {
if (!packet.hasRemaining(4) + 4 + 4) break;
// petNumber(4) + entry(4) + level(4) = 12 bytes before the name string
if (!packet.hasRemaining(12)) break;
GameHandler::StabledPet pet;
pet.petNumber = packet.readUInt32();
pet.entry = packet.readUInt32();
pet.level = packet.readUInt32();
pet.name = packet.readString();
if (!packet.hasRemaining(4) + 1) break;
// displayId(4) + isActive(1) = 5 bytes after the name string
if (!packet.hasRemaining(5)) break;
pet.displayId = packet.readUInt32();
pet.isActive = (packet.readUInt8() != 0);
owner_.stabledPets_.push_back(std::move(pet));
@ -1616,6 +1618,17 @@ void SpellHandler::resetCastState() {
owner_.lastInteractedGoGuid_ = 0;
}
void SpellHandler::resetAllState() {
knownSpells_.clear();
spellCooldowns_.clear();
playerAuras_.clear();
targetAuras_.clear();
unitAurasCache_.clear();
unitCastStates_.clear();
resetCastState();
resetTalentState();
}
void SpellHandler::resetTalentState() {
talentsInitialized_ = false;
learnedTalents_[0].clear();