feat: add right-click pet spell autocast toggle via CMSG_PET_SPELL_AUTOCAST

Right-clicking a castable pet ability (actionId > 6) in the pet action
bar now sends CMSG_PET_SPELL_AUTOCAST to toggle the spell's autocast
state. The local petAutocastSpells_ set is updated optimistically and
the tooltip shows the current state with a right-click hint.
This commit is contained in:
Kelsi 2026-03-18 05:08:10 -07:00
parent 586408516b
commit e7fe35c1f9
3 changed files with 28 additions and 2 deletions

View file

@ -18291,6 +18291,24 @@ void GameHandler::dismissPet() {
socket->send(packet);
}
void GameHandler::togglePetSpellAutocast(uint32_t spellId) {
if (petGuid_ == 0 || spellId == 0 || state != WorldState::IN_WORLD || !socket) return;
bool currentlyOn = petAutocastSpells_.count(spellId) != 0;
uint8_t newState = currentlyOn ? 0 : 1;
// CMSG_PET_SPELL_AUTOCAST: petGuid(8) + spellId(4) + state(1)
network::Packet pkt(wireOpcode(Opcode::CMSG_PET_SPELL_AUTOCAST));
pkt.writeUInt64(petGuid_);
pkt.writeUInt32(spellId);
pkt.writeUInt8(newState);
socket->send(pkt);
// Optimistically update local state; server will confirm via SMSG_PET_SPELLS
if (newState)
petAutocastSpells_.insert(spellId);
else
petAutocastSpells_.erase(spellId);
LOG_DEBUG("togglePetSpellAutocast: spellId=", spellId, " autocast=", (int)newState);
}
void GameHandler::renamePet(const std::string& newName) {
if (petGuid_ == 0 || state != WorldState::IN_WORLD || !socket) return;
if (newName.empty() || newName.size() > 12) return; // Server enforces max 12 chars