From ce54b196e73383a6ca28667ebe826cea94bfa59e Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 28 Mar 2026 15:18:33 -0700 Subject: [PATCH] fix: trade COMPLETE resets state before EXTENDED can populate items/gold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SMSG_TRADE_STATUS(COMPLETE) and SMSG_TRADE_STATUS_EXTENDED arrive in the same packet batch. COMPLETE was calling resetTradeState() which cleared all trade slots and gold BEFORE EXTENDED could write the final data. The trade window showed "7c" (garbage gold) because the gold field read from the wrong offset (slot size was also wrong: 60→52 bytes). Now COMPLETE just sets status to None without full reset, preserving trade state for EXTENDED to populate. The TRADE_CLOSED addon event still fires correctly. --- src/game/inventory_handler.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/game/inventory_handler.cpp b/src/game/inventory_handler.cpp index 2f661899..f952a2ab 100644 --- a/src/game/inventory_handler.cpp +++ b/src/game/inventory_handler.cpp @@ -2102,7 +2102,9 @@ void InventoryHandler::handleTradeStatus(network::Packet& packet) { owner_.addSystemChatMessage("You are already trading."); break; case 7: // TRADE_STATUS_COMPLETE - resetTradeState(); + // Don't reset immediately — TRADE_STATUS_EXTENDED may arrive in the same + // packet batch and needs the trade state to store final item/gold data. + tradeStatus_ = TradeStatus::None; owner_.addSystemChatMessage("Trade complete."); if (owner_.addonEventCallback_) { owner_.addonEventCallback_("TRADE_CLOSED", {});