diff options
author | Jared Adams <jaxad0127@gmail.com> | 2009-02-25 13:38:55 -0700 |
---|---|---|
committer | Jared Adams <jaxad0127@gmail.com> | 2009-02-25 13:38:55 -0700 |
commit | f04a8713ffc83db8b3dc4a472b28aad25a2b2bd1 (patch) | |
tree | 1822aa7cecfbe4ef38b55216ab82b686e3b636c7 /src/gui/buysell.cpp | |
parent | 9673149ea3c28f42f38fc9989faf76d68e72bd20 (diff) | |
download | mana-f04a8713ffc83db8b3dc4a472b28aad25a2b2bd1.tar.gz mana-f04a8713ffc83db8b3dc4a472b28aad25a2b2bd1.tar.bz2 mana-f04a8713ffc83db8b3dc4a472b28aad25a2b2bd1.tar.xz mana-f04a8713ffc83db8b3dc4a472b28aad25a2b2bd1.zip |
Fix NPC handling to not need a handle on the NPC
The Being ID is used instead, as that is all that was ever really
needed.
Diffstat (limited to 'src/gui/buysell.cpp')
-rw-r--r-- | src/gui/buysell.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/buysell.cpp b/src/gui/buysell.cpp index 8bf5f1f4..c1c934d1 100644 --- a/src/gui/buysell.cpp +++ b/src/gui/buysell.cpp @@ -24,10 +24,13 @@ #include "../npc.h" +#include "../net/messageout.h" +#include "../net/protocol.h" + #include "../utils/gettext.h" -BuySellDialog::BuySellDialog(): - Window(_("Shop")) +BuySellDialog::BuySellDialog(Network *network): + Window(_("Shop")), mNetwork(network) { Button *buyButton = 0; static const char *buttonNames[] = { @@ -60,12 +63,19 @@ void BuySellDialog::logic() void BuySellDialog::action(const gcn::ActionEvent &event) { + setVisible(false); + int action; if (event.getId() == "Buy") { - current_npc->buy(); + action = 0; } else if (event.getId() == "Sell") { - current_npc->sell(); + action = 1; } else if (event.getId() == "Cancel") { - if (current_npc) current_npc->handleDeath(); + current_npc = 0; + return; } - setVisible(false); + + MessageOut outMsg(mNetwork); + outMsg.writeInt16(CMSG_NPC_BUY_SELL_REQUEST); + outMsg.writeInt32(current_npc); + outMsg.writeInt8(action); } |