diff options
Diffstat (limited to 'src/net/tmwa')
-rw-r--r-- | src/net/tmwa/buysellrecv.cpp | 35 | ||||
-rw-r--r-- | src/net/tmwa/buysellrecv.h | 1 | ||||
-rw-r--r-- | src/net/tmwa/packetsin.inc | 2 |
3 files changed, 37 insertions, 1 deletions
diff --git a/src/net/tmwa/buysellrecv.cpp b/src/net/tmwa/buysellrecv.cpp index 230327899..6a30f7bc6 100644 --- a/src/net/tmwa/buysellrecv.cpp +++ b/src/net/tmwa/buysellrecv.cpp @@ -82,4 +82,39 @@ void BuySellRecv::processNpcSellResponse(Net::MessageIn &msg) } } +void BuySellRecv::processNpcBuyResponse(Net::MessageIn &msg) +{ + const uint8_t response = msg.readUInt8("response"); + if (response == 0U) + { + NotifyManager::notify(NotifyTypes::BUY_DONE); + return; + } + // Reset player money since buy dialog already assumed purchase + // would go fine + if (Ea::BuySellRecv::mBuyDialog) + { + Ea::BuySellRecv::mBuyDialog->setMoney( + PlayerInfo::getAttribute(Attributes::MONEY)); + } + switch (response) + { + case 1: + NotifyManager::notify(NotifyTypes::BUY_FAILED_NO_MONEY); + break; + + case 2: + NotifyManager::notify(NotifyTypes::BUY_FAILED_OVERWEIGHT); + break; + + case 3: + NotifyManager::notify(NotifyTypes::BUY_FAILED_TOO_MANY_ITEMS); + break; + + default: + NotifyManager::notify(NotifyTypes::BUY_FAILED); + break; + }; +} + } // namespace TmwAthena diff --git a/src/net/tmwa/buysellrecv.h b/src/net/tmwa/buysellrecv.h index b5bd82ace..36607df84 100644 --- a/src/net/tmwa/buysellrecv.h +++ b/src/net/tmwa/buysellrecv.h @@ -34,6 +34,7 @@ namespace TmwAthena { void processNpcBuy(Net::MessageIn &msg); void processNpcSellResponse(Net::MessageIn &msg); + void processNpcBuyResponse(Net::MessageIn &msg); } // namespace BuySellRecv } // namespace TmwAthena diff --git a/src/net/tmwa/packetsin.inc b/src/net/tmwa/packetsin.inc index 2ee65afd9..150028a41 100644 --- a/src/net/tmwa/packetsin.inc +++ b/src/net/tmwa/packetsin.inc @@ -62,7 +62,7 @@ packet(SMSG_MAP_MUSIC, 0x0227, -1, &Ea::PlayerRecv::process packet(SMSG_MAP_QUIT_RESPONSE, 0x018b, 4, &Ea::GameRecv::processMapQuitResponse, 0); packet(SMSG_MVP_EFFECT, 0x010c, 6, &Ea::ChatRecv::processMVPEffect, 0); packet(SMSG_NPC_BUY, 0x00c6, -1, &BuySellRecv::processNpcBuy, 0); -packet(SMSG_NPC_BUY_RESPONSE, 0x00ca, 3, &Ea::BuySellRecv::processNpcBuyResponse, 0); +packet(SMSG_NPC_BUY_RESPONSE, 0x00ca, 3, &BuySellRecv::processNpcBuyResponse, 0); packet(SMSG_NPC_BUY_SELL_CHOICE, 0x00c4, 6, &Ea::BuySellRecv::processNpcBuySellChoice, 0); packet(SMSG_NPC_CHANGETITLE, 0x0228, -1, &Ea::NpcRecv::processChangeTitle, 0); packet(SMSG_NPC_CHOICE, 0x00b7, -1, &Ea::NpcRecv::processNpcChoice, 0); |