From 5df5f4d423ccadc26899ff0cc02a7dbb1fc921f0 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Tue, 17 Mar 2026 20:59:29 -0700 Subject: [PATCH] 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. --- include/game/game_handler.hpp | 3 +++ src/game/game_handler.cpp | 6 +++++- src/ui/game_screen.cpp | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 027b5de8..f67477d4 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -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 petSpellList_; // known pet spells std::unordered_set petAutocastSpells_; // spells with autocast on diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 8f83e052..4b052724 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -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."); diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 6430e1df..40fab36e 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -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);