diff options
author | Bertram <bertram@cegetel.net> | 2009-10-09 16:31:16 +0200 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-10-09 16:31:16 +0200 |
commit | 1102bdc2e5a9e52b621cf58d68d0065faba2b84c (patch) | |
tree | 4a9b849cd1a795baca0a496ff14f397f0d418f66 /src/game-server/trade.cpp | |
parent | b555dd7bcc5046e9809ef37d2173955d042594da (diff) | |
download | manaserv-1102bdc2e5a9e52b621cf58d68d0065faba2b84c.tar.gz manaserv-1102bdc2e5a9e52b621cf58d68d0065faba2b84c.tar.bz2 manaserv-1102bdc2e5a9e52b621cf58d68d0065faba2b84c.tar.xz manaserv-1102bdc2e5a9e52b621cf58d68d0065faba2b84c.zip |
Synced the protocol file with client in protocol.h, letting other defines in defines.h, and removing some overheading along the way.
Diffstat (limited to 'src/game-server/trade.cpp')
-rw-r--r-- | src/game-server/trade.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/game-server/trade.cpp b/src/game-server/trade.cpp index e61fc8fc..47ce4d8a 100644 --- a/src/game-server/trade.cpp +++ b/src/game-server/trade.cpp @@ -24,7 +24,6 @@ #include "game-server/trade.hpp" -#include "defines.h" #include "game-server/character.hpp" #include "game-server/gamehandler.hpp" #include "game-server/inventory.hpp" @@ -73,12 +72,12 @@ bool Trade::request(Character *c, int id) cancel(); return false; } - + //Second player confirmed. - + //Starts trading. mState = TRADE_RUN; - + //Telling both player that the trade has started MessageOut msg(GPMSG_TRADE_START); mChar1->getClient()->send(msg); @@ -115,21 +114,21 @@ void Trade::agree(Character *c) } // First player agrees. mState = TRADE_CONFIRM_WAIT; - + // Send the other player that the first player has confirmed - MessageOut msg(GPMSG_TRADE_AGREED); + MessageOut msg(GPMSG_TRADE_AGREED); mChar2->getClient()->send(msg); return; } - + if (mState == TRADE_AGREE_WAIT && c == mChar1) { // We don't care about the first player, he already agreed return; } - + // The second player has agreed - + // Check if both player has the objects in their inventories // and enouth money, then swap them. Inventory v1(mChar1, true), v2(mChar2, true); @@ -143,7 +142,7 @@ void Trade::agree(Character *c) cancel(); return; } - + MessageOut msg(GPMSG_TRADE_COMPLETE); mChar1->getClient()->send(msg); mChar2->getClient()->send(msg); @@ -154,7 +153,7 @@ void Trade::confirm(Character *c) { if (mState == TRADE_CONFIRMED || mState == TRADE_AGREE_WAIT) return; - + if (mState == TRADE_RUN) //No player has confirmed { //One player confirms, if it's the player 2, make it player 1 @@ -167,7 +166,7 @@ void Trade::confirm(Character *c) assert(c == mChar1); // First player agrees. mState = TRADE_CONFIRM_WAIT; - + //Send the other player that the first player has confirmed MessageOut msg(GPMSG_TRADE_CONFIRM); mChar2->getClient()->send(msg); @@ -179,7 +178,7 @@ void Trade::confirm(Character *c) // First player has already agreed. We only care about the second one. return; } - + mState = TRADE_CONFIRMED; MessageOut msg(GPMSG_TRADE_BOTH_CONFIRM); mChar1->getClient()->send(msg); @@ -189,7 +188,7 @@ void Trade::confirm(Character *c) void Trade::setMoney(Character *c, int amount) { //If the player has already confirmed, exit. - if ((mState != TRADE_RUN && (mState != TRADE_CONFIRM_WAIT || c != mChar1)) + if ((mState != TRADE_RUN && (mState != TRADE_CONFIRM_WAIT || c != mChar1)) || amount < 0) return; /* Checking now if there is enough money is useless as it can change @@ -218,7 +217,7 @@ void Trade::setMoney(Character *c, int amount) void Trade::addItem(Character *c, int slot, int amount) { //If the player has already confirmed, exit. - if ((mState != TRADE_RUN && (mState != TRADE_CONFIRM_WAIT || c != mChar1)) + if ((mState != TRADE_RUN && (mState != TRADE_CONFIRM_WAIT || c != mChar1)) || amount < 0) return; Character *other; |