diff --git a/include/game/game_handler.hpp b/include/game/game_handler.hpp index 31a60fb7..0d2883f6 100644 --- a/include/game/game_handler.hpp +++ b/include/game/game_handler.hpp @@ -1981,6 +1981,7 @@ public: void openMailCompose(); void closeMailCompose(); bool hasNewMail() const; + void openMailbox(uint64_t guid); void closeMailbox(); void sendMail(const std::string& recipient, const std::string& subject, const std::string& body, uint64_t money, uint64_t cod = 0); diff --git a/include/game/inventory_handler.hpp b/include/game/inventory_handler.hpp index d5e0239a..ea64df0d 100644 --- a/include/game/inventory_handler.hpp +++ b/include/game/inventory_handler.hpp @@ -149,6 +149,7 @@ public: void openMailCompose() { showMailCompose_ = true; clearMailAttachments(); } void closeMailCompose() { showMailCompose_ = false; clearMailAttachments(); } bool hasNewMail() const { return hasNewMail_; } + void openMailbox(uint64_t guid); void closeMailbox(); void sendMail(const std::string& recipient, const std::string& subject, const std::string& body, uint64_t money, uint64_t cod = 0); diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 8e344be7..c1ffd725 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -5762,8 +5762,7 @@ void GameHandler::performGameObjectInteractionNow(uint64_t guid) { // (using lastInteractedGoGuid_ set above). For instant-open chests // (no cast), the server sends SMSG_LOOT_RESPONSE directly after USE. } else if (isMailbox) { - // Server responds with SMSG_SHOW_MAILBOX → InventoryHandler::handleShowMailbox - // opens the UI and requests the mail list. + openMailbox(guid); } // CMSG_GAMEOBJ_REPORT_USE triggers GO AI scripts (SmartAI, ScriptAI) which @@ -6532,6 +6531,10 @@ void GameHandler::updateAttachedTransportChildren(float deltaTime) { // Mail System // ============================================================ +void GameHandler::openMailbox(uint64_t guid) { + if (inventoryHandler_) inventoryHandler_->openMailbox(guid); +} + void GameHandler::closeMailbox() { if (inventoryHandler_) inventoryHandler_->closeMailbox(); } diff --git a/src/game/inventory_handler.cpp b/src/game/inventory_handler.cpp index 6d90d6d5..4abb9f96 100644 --- a/src/game/inventory_handler.cpp +++ b/src/game/inventory_handler.cpp @@ -1536,6 +1536,17 @@ void InventoryHandler::categorizeTrainerSpells() { // Mail // ============================================================ +void InventoryHandler::openMailbox(uint64_t guid) { + mailboxGuid_ = guid; + mailboxOpen_ = true; + hasNewMail_ = false; + selectedMailIndex_ = -1; + showMailCompose_ = false; + clearMailAttachments(); + if (owner_.addonEventCallback_) owner_.addonEventCallback_("MAIL_SHOW", {}); + refreshMailList(); +} + void InventoryHandler::closeMailbox() { mailboxOpen_ = false; mailboxGuid_ = 0;