diff options
author | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-14 10:43:58 +0000 |
---|---|---|
committer | Guillaume Melquiond <guillaume.melquiond@gmail.com> | 2007-08-14 10:43:58 +0000 |
commit | 4b48bc6fefd4f580d3b8db8893f78706e64bf880 (patch) | |
tree | c6a36b566f9837bf1faf260f673f11b0ac2df783 /src/game-server/buysell.cpp | |
parent | 01e3326de8fc03cf9f61fd1b288cd4f16915484c (diff) | |
download | manaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.tar.gz manaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.tar.bz2 manaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.tar.xz manaserv-4b48bc6fefd4f580d3b8db8893f78706e64bf880.zip |
Handled money as part of the inventory.
Diffstat (limited to 'src/game-server/buysell.cpp')
-rw-r--r-- | src/game-server/buysell.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/game-server/buysell.cpp b/src/game-server/buysell.cpp index e73141df..f249d9c1 100644 --- a/src/game-server/buysell.cpp +++ b/src/game-server/buysell.cpp @@ -83,7 +83,6 @@ void BuySell::start(MovingObject *obj) void BuySell::perform(int id, int amount) { Inventory inv(mChar); - int money = mChar->getMoney(); for (TradedItems::iterator i = mItems.begin(), i_end = mItems.end(); i != i_end; ++i) { @@ -92,13 +91,13 @@ void BuySell::perform(int id, int amount) if (mSell) { amount -= inv.remove(id, amount); - money += amount * i->cost; + inv.changeMoney(amount * i->cost); } else { - amount = std::min(amount, money / i->cost); + amount = std::min(amount, mChar->getPossessions().money / i->cost); amount -= inv.insert(id, amount); - money -= amount * i->cost; + inv.changeMoney(-amount * i->cost); } if (i->amount) { @@ -108,7 +107,6 @@ void BuySell::perform(int id, int amount) mItems.erase(i); } } - mChar->setMoney(money); return; } } |