summaryrefslogtreecommitdiff
path: root/src/net/manaserv/buysellhandler.cpp
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-02-13 15:04:58 -0700
committerJared Adams <jaxad0127@gmail.com>2010-02-13 15:08:54 -0700
commit8bc425ff48b7a874ca0fb9d2285044c75f3010ab (patch)
tree5904c7f53cde9ffbe7df2a63f088561141e06b66 /src/net/manaserv/buysellhandler.cpp
parent28c9cec5d39c9a1b98694eba9a28281cf111e34a (diff)
downloadmana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.gz
mana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.bz2
mana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.tar.xz
mana-8bc425ff48b7a874ca0fb9d2285044c75f3010ab.zip
Make NPC dialogs instance instead of global
This change allows players to talk to multiple NPCs at a time (if the server agrees). Manaserv's netcode allows multiple commerce instances too. eAthena's is limited to one commerce instance, due to protocol limitations.
Diffstat (limited to 'src/net/manaserv/buysellhandler.cpp')
-rw-r--r--src/net/manaserv/buysellhandler.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/net/manaserv/buysellhandler.cpp b/src/net/manaserv/buysellhandler.cpp
index e98dce98..9b7c0863 100644
--- a/src/net/manaserv/buysellhandler.cpp
+++ b/src/net/manaserv/buysellhandler.cpp
@@ -26,17 +26,14 @@
#include "localplayer.h"
#include "npc.h"
-#include "net/messagein.h"
-
-#include "net/manaserv/protocol.h"
-
#include "gui/buy.h"
#include "gui/chat.h"
#include "gui/sell.h"
-extern BuyDialog *buyDialog;
-extern SellDialog *sellDialog;
-extern Window *buySellDialog;
+#include "net/messagein.h"
+
+#include "net/manaserv/protocol.h"
+
namespace ManaServ {
@@ -58,37 +55,43 @@ void BuySellHandler::handleMessage(Net::MessageIn &msg)
return;
}
- current_npc = being->getId();
+ int npcId = being->getId();
switch (msg.getId())
{
case GPMSG_NPC_BUY:
- buyDialog->reset();
- buyDialog->setMoney(player_node->getMoney());
- buyDialog->setVisible(true);
+ {
+ BuyDialog* dialog = new BuyDialog(npcId);
+
+ dialog->reset();
+ dialog->setMoney(player_node->getMoney());
while (msg.getUnreadLength())
{
int itemId = msg.readInt16();
int amount = msg.readInt16();
int value = msg.readInt16();
- buyDialog->addItem(itemId, amount, value);
+ dialog->addItem(itemId, amount, value);
}
break;
+ }
case GPMSG_NPC_SELL:
- sellDialog->setMoney(player_node->getMoney());
- sellDialog->reset();
- sellDialog->setVisible(true);
+ {
+ SellDialog* dialog = new SellDialog(npcId);
+
+ dialog->reset();
+ dialog->setMoney(player_node->getMoney());
while (msg.getUnreadLength())
{
int itemId = msg.readInt16();
int amount = msg.readInt16();
int value = msg.readInt16();
- sellDialog->addItem(new Item(itemId, amount, false), value);
+ dialog->addItem(new Item(itemId, amount, false), value);
}
break;
+ }
}
}