summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-14 12:10:41 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-14 12:10:41 +0000
commitf048a4dd4add4a710bb15f77eaedad93f625b0c4 (patch)
tree46849986ed36a23f9a386b0475eb8e7c4a4f3f68 /src
parentb9772c8575708a9f28d89b3b973af73e382e9329 (diff)
downloadmana-client-f048a4dd4add4a710bb15f77eaedad93f625b0c4.tar.gz
mana-client-f048a4dd4add4a710bb15f77eaedad93f625b0c4.tar.bz2
mana-client-f048a4dd4add4a710bb15f77eaedad93f625b0c4.tar.xz
mana-client-f048a4dd4add4a710bb15f77eaedad93f625b0c4.zip
Enabled buying and selling from NPCs.
Diffstat (limited to 'src')
-rw-r--r--src/gui/buy.cpp12
-rw-r--r--src/gui/sell.cpp15
-rw-r--r--src/net/gameserver/player.cpp8
-rw-r--r--src/net/gameserver/player.h1
4 files changed, 16 insertions, 20 deletions
diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp
index 9ac37e96..6cfe5e18 100644
--- a/src/gui/buy.cpp
+++ b/src/gui/buy.cpp
@@ -31,9 +31,8 @@
#include "slider.h"
#include "../npc.h"
-
+#include "../net/gameserver/player.h"
#include "../resources/itemdb.h"
-
#include "../utils/tostring.h"
@@ -176,13 +175,8 @@ void BuyDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "buy" && mAmountItems > 0 &&
mAmountItems <= mMaxItems)
{
- // XXX Convert for new server
- /*
- MessageOut outMsg(CMSG_NPC_BUY_REQUEST);
- outMsg.writeShort(8);
- outMsg.writeShort(mAmountItems);
- outMsg.writeShort(mShopItems->at(selectedItem).id);
- */
+ Net::GameServer::Player::tradeWithNPC
+ (mShopItems->at(selectedItem).id, mAmountItems);
// Update money and adjust the max number of items that can be bought
mMoney -= mAmountItems * mShopItems->at(selectedItem).price;
diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp
index 53746248..b601d70c 100644
--- a/src/gui/sell.cpp
+++ b/src/gui/sell.cpp
@@ -35,10 +35,9 @@
#include "../item.h"
#include "../npc.h"
-
-#include "../resources/iteminfo.h"
+#include "../net/gameserver/player.h"
#include "../resources/itemdb.h"
-
+#include "../resources/iteminfo.h"
#include "../utils/tostring.h"
SellDialog::SellDialog():
@@ -177,14 +176,8 @@ void SellDialog::action(const gcn::ActionEvent &event)
else if (event.getId() == "sell" && mAmountItems > 0
&& mAmountItems <= mMaxItems)
{
- // Attempt sell
- // XXX Convert for new server
- /*
- MessageOut outMsg(CMSG_NPC_SELL_REQUEST);
- outMsg.writeShort(8);
- outMsg.writeShort(mShopItems->at(selectedItem).index);
- outMsg.writeShort(mAmountItems);
- */
+ Net::GameServer::Player::tradeWithNPC
+ (mShopItems->at(selectedItem).id, mAmountItems);
mMaxItems -= mAmountItems;
mShopItems->getShop()->at(selectedItem).quantity = mMaxItems;
diff --git a/src/net/gameserver/player.cpp b/src/net/gameserver/player.cpp
index 29d711d7..feba5565 100644
--- a/src/net/gameserver/player.cpp
+++ b/src/net/gameserver/player.cpp
@@ -139,3 +139,11 @@ void Net::GameServer::Player::tradeItem(int slot, int amount)
msg.writeByte(amount);
Net::GameServer::connection->send(msg);
}
+
+void Net::GameServer::Player::tradeWithNPC(int item, int amount)
+{
+ MessageOut msg(PGMSG_NPC_BUYSELL);
+ msg.writeShort(item);
+ msg.writeShort(amount);
+ Net::GameServer::connection->send(msg);
+}
diff --git a/src/net/gameserver/player.h b/src/net/gameserver/player.h
index d21e656e..dcf3f267 100644
--- a/src/net/gameserver/player.h
+++ b/src/net/gameserver/player.h
@@ -49,6 +49,7 @@ namespace Net
void requestTrade(int id);
void acceptTrade(bool accept);
void tradeItem(int slot, int amount);
+ void tradeWithNPC(int item, int amount);
}
}
}