fix(mail): route GO mailbox open through InventoryHandler

The decomposition PRs moved mail state to InventoryHandler but the GO
interaction code still set stale GameHandler fields. Add openMailbox()
on InventoryHandler and forward from GameHandler so the correct
mailboxGuid_/mailboxOpen_ are set and refreshMailList() works.
This commit is contained in:
Kelsi 2026-04-05 04:22:48 -07:00
parent 62f3f515e2
commit 35be19e74c
4 changed files with 18 additions and 2 deletions

View file

@ -1981,6 +1981,7 @@ public:
void openMailCompose(); void openMailCompose();
void closeMailCompose(); void closeMailCompose();
bool hasNewMail() const; bool hasNewMail() const;
void openMailbox(uint64_t guid);
void closeMailbox(); void closeMailbox();
void sendMail(const std::string& recipient, const std::string& subject, void sendMail(const std::string& recipient, const std::string& subject,
const std::string& body, uint64_t money, uint64_t cod = 0); const std::string& body, uint64_t money, uint64_t cod = 0);

View file

@ -149,6 +149,7 @@ public:
void openMailCompose() { showMailCompose_ = true; clearMailAttachments(); } void openMailCompose() { showMailCompose_ = true; clearMailAttachments(); }
void closeMailCompose() { showMailCompose_ = false; clearMailAttachments(); } void closeMailCompose() { showMailCompose_ = false; clearMailAttachments(); }
bool hasNewMail() const { return hasNewMail_; } bool hasNewMail() const { return hasNewMail_; }
void openMailbox(uint64_t guid);
void closeMailbox(); void closeMailbox();
void sendMail(const std::string& recipient, const std::string& subject, void sendMail(const std::string& recipient, const std::string& subject,
const std::string& body, uint64_t money, uint64_t cod = 0); const std::string& body, uint64_t money, uint64_t cod = 0);

View file

@ -5762,8 +5762,7 @@ void GameHandler::performGameObjectInteractionNow(uint64_t guid) {
// (using lastInteractedGoGuid_ set above). For instant-open chests // (using lastInteractedGoGuid_ set above). For instant-open chests
// (no cast), the server sends SMSG_LOOT_RESPONSE directly after USE. // (no cast), the server sends SMSG_LOOT_RESPONSE directly after USE.
} else if (isMailbox) { } else if (isMailbox) {
// Server responds with SMSG_SHOW_MAILBOX → InventoryHandler::handleShowMailbox openMailbox(guid);
// opens the UI and requests the mail list.
} }
// CMSG_GAMEOBJ_REPORT_USE triggers GO AI scripts (SmartAI, ScriptAI) which // CMSG_GAMEOBJ_REPORT_USE triggers GO AI scripts (SmartAI, ScriptAI) which
@ -6532,6 +6531,10 @@ void GameHandler::updateAttachedTransportChildren(float deltaTime) {
// Mail System // Mail System
// ============================================================ // ============================================================
void GameHandler::openMailbox(uint64_t guid) {
if (inventoryHandler_) inventoryHandler_->openMailbox(guid);
}
void GameHandler::closeMailbox() { void GameHandler::closeMailbox() {
if (inventoryHandler_) inventoryHandler_->closeMailbox(); if (inventoryHandler_) inventoryHandler_->closeMailbox();
} }

View file

@ -1536,6 +1536,17 @@ void InventoryHandler::categorizeTrainerSpells() {
// Mail // 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() { void InventoryHandler::closeMailbox() {
mailboxOpen_ = false; mailboxOpen_ = false;
mailboxGuid_ = 0; mailboxGuid_ = 0;