feat: handle SMSG_PET_RENAMEABLE to auto-open pet rename dialog on first tame

When the server sends SMSG_PET_RENAMEABLE (after taming a pet for the first
time), the pet rename modal now automatically opens so the player can name
their new pet without needing to right-click the pet frame.
This commit is contained in:
Kelsi 2026-03-17 20:59:29 -07:00
parent 113be66314
commit 5df5f4d423
3 changed files with 14 additions and 1 deletions

View file

@ -718,6 +718,8 @@ public:
void dismissPet();
void renamePet(const std::string& newName);
bool hasPet() const { return petGuid_ != 0; }
// Returns true once after SMSG_PET_RENAMEABLE; consuming the flag clears it.
bool consumePetRenameablePending() { bool v = petRenameablePending_; petRenameablePending_ = false; return v; }
uint64_t getPetGuid() const { return petGuid_; }
// ---- Pet state (populated by SMSG_PET_SPELLS / SMSG_PET_MODE) ----
@ -2747,6 +2749,7 @@ private:
uint32_t petActionSlots_[10] = {}; // SMSG_PET_SPELLS action bar (10 slots)
uint8_t petCommand_ = 1; // 0=stay,1=follow,2=attack,3=dismiss
uint8_t petReact_ = 1; // 0=passive,1=defensive,2=aggressive
bool petRenameablePending_ = false; // set by SMSG_PET_RENAMEABLE, consumed by UI
std::vector<uint32_t> petSpellList_; // known pet spells
std::unordered_set<uint32_t> petAutocastSpells_; // spells with autocast on

View file

@ -7661,10 +7661,14 @@ void GameHandler::handlePacket(network::Packet& packet) {
case Opcode::SMSG_PET_DISMISS_SOUND:
case Opcode::SMSG_PET_ACTION_SOUND:
case Opcode::SMSG_PET_UNLEARN_CONFIRM:
case Opcode::SMSG_PET_RENAMEABLE:
case Opcode::SMSG_PET_UPDATE_COMBO_POINTS:
packet.setReadPos(packet.getSize());
break;
case Opcode::SMSG_PET_RENAMEABLE:
// Server signals that the pet can now be named (first tame)
petRenameablePending_ = true;
packet.setReadPos(packet.getSize());
break;
case Opcode::SMSG_PET_NAME_INVALID:
addUIError("That pet name is invalid. Please choose a different name.");
addSystemChatMessage("That pet name is invalid. Please choose a different name.");

View file

@ -629,6 +629,12 @@ void GameScreen::render(game::GameHandler& gameHandler) {
renderPetFrame(gameHandler);
}
// Auto-open pet rename modal when server signals the pet is renameable (first tame)
if (gameHandler.consumePetRenameablePending()) {
petRenameOpen_ = true;
petRenameBuf_[0] = '\0';
}
// Totem frame (Shaman only, when any totem is active)
if (gameHandler.getPlayerClass() == 7) {
renderTotemFrame(gameHandler);