summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorblue112 <bluesansdouze@gmail.com>2009-04-21 15:31:21 +0200
committerJared Adams <jaxad0127@gmail.com>2009-04-21 08:35:52 -0600
commitfa96d81b86914adb3d8608f8ab4f734d3286fcd4 (patch)
tree422d35e88df76f05f40b5308fa842ce8a0ceeb3b /src/net
parent18bb2946b4acfe8d3ac9184a453898718488e556 (diff)
downloadmana-client-fa96d81b86914adb3d8608f8ab4f734d3286fcd4.tar.gz
mana-client-fa96d81b86914adb3d8608f8ab4f734d3286fcd4.tar.bz2
mana-client-fa96d81b86914adb3d8608f8ab4f734d3286fcd4.tar.xz
mana-client-fa96d81b86914adb3d8608f8ab4f734d3286fcd4.zip
Trade system
Handler & GUI modification, to make the three steps systems working. Protocol changes for the same reason Player.cpp changes because it uses the cancel method which signature has changed
Diffstat (limited to 'src/net')
-rw-r--r--src/net/tmwserv/gameserver/player.cpp2
-rw-r--r--src/net/tmwserv/protocol.h15
-rw-r--r--src/net/tmwserv/tradehandler.cpp16
3 files changed, 22 insertions, 11 deletions
diff --git a/src/net/tmwserv/gameserver/player.cpp b/src/net/tmwserv/gameserver/player.cpp
index a3e1458c..3f05c954 100644
--- a/src/net/tmwserv/gameserver/player.cpp
+++ b/src/net/tmwserv/gameserver/player.cpp
@@ -81,7 +81,7 @@ void Net::GameServer::Player::requestTrade(int id)
void Net::GameServer::Player::acceptTrade(bool accept)
{
- MessageOut msg(accept ? PGMSG_TRADE_ACCEPT : PGMSG_TRADE_CANCEL);
+ MessageOut msg(accept ? PGMSG_TRADE_REQUEST : PGMSG_TRADE_CANCEL);
Net::GameServer::connection->send(msg);
}
diff --git a/src/net/tmwserv/protocol.h b/src/net/tmwserv/protocol.h
index 7eb0b931..57926611 100644
--- a/src/net/tmwserv/protocol.h
+++ b/src/net/tmwserv/protocol.h
@@ -129,12 +129,15 @@ enum {
GPMSG_TRADE_COMPLETE = 0x02C3, // -
PGMSG_TRADE_CANCEL = 0x02C4, // -
GPMSG_TRADE_CANCEL = 0x02C5, // -
- PGMSG_TRADE_ACCEPT = 0x02C6, // -
- GPMSG_TRADE_ACCEPT = 0x02C7, // -
- PGMSG_TRADE_ADD_ITEM = 0x02C8, // B slot, B amount
- GPMSG_TRADE_ADD_ITEM = 0x02C9, // W item id, B amount
- PGMSG_TRADE_SET_MONEY = 0x02CA, // L amount
- GPMSG_TRADE_SET_MONEY = 0x02CB, // L amount
+ PGMSG_TRADE_AGREED = 0x02C6, // -
+ GPMSG_TRADE_AGREED = 0x02C7, // -
+ PGMSG_TRADE_CONFIRM = 0x02C8, // -
+ GPMSG_TRADE_CONFIRM = 0x02C9, // -
+ PGMSG_TRADE_ADD_ITEM = 0x02CA, // B slot, B amount
+ GPMSG_TRADE_ADD_ITEM = 0x02CB, // W item id, B amount
+ PGMSG_TRADE_SET_MONEY = 0x02CC, // L amount
+ GPMSG_TRADE_SET_MONEY = 0x02CD, // L amount
+ GPMSG_TRADE_BOTH_CONFIRM = 0x02CE, // -
PGMSG_USE_ITEM = 0x0300, // B slot
GPMSG_USE_RESPONSE = 0x0301, // B error
GPMSG_BEINGS_DAMAGE = 0x0310, // { W being id, W amount }*
diff --git a/src/net/tmwserv/tradehandler.cpp b/src/net/tmwserv/tradehandler.cpp
index 2b10bac1..ae190c96 100644
--- a/src/net/tmwserv/tradehandler.cpp
+++ b/src/net/tmwserv/tradehandler.cpp
@@ -71,13 +71,16 @@ TradeHandler::TradeHandler():
GPMSG_TRADE_CANCEL,
GPMSG_TRADE_START,
GPMSG_TRADE_COMPLETE,
- GPMSG_TRADE_ACCEPT,
+ GPMSG_TRADE_AGREED,
+ GPMSG_TRADE_BOTH_CONFIRM,
+ GPMSG_TRADE_CONFIRM,
GPMSG_TRADE_ADD_ITEM,
GPMSG_TRADE_SET_MONEY,
0
};
handledMessages = _messages;
tradeHandler = this;
+
}
void TradeHandler::setAcceptTradeRequests(bool acceptTradeRequests)
@@ -127,10 +130,14 @@ void TradeHandler::handleMessage(MessageIn &msg)
tradeWindow->setVisible(true);
break;
- case GPMSG_TRADE_ACCEPT:
+ case GPMSG_TRADE_BOTH_CONFIRM:
tradeWindow->receivedOk(false);
break;
+ case GPMSG_TRADE_AGREED:
+ tradeWindow->receivedOk(false);
+ break;
+
case GPMSG_TRADE_CANCEL:
localChatTab->chatLog("Trade canceled.", BY_SERVER);
tradeWindow->setVisible(false);
@@ -187,12 +194,13 @@ void TradeHandler::setMoney(int amount)
void TradeHandler::confirm()
{
- // TODO
+ MessageOut msg(PGMSG_TRADE_CONFIRM);
+ Net::GameServer::connection->send(msg);
}
void TradeHandler::finish()
{
- MessageOut msg(PGMSG_TRADE_ACCEPT);
+ MessageOut msg(PGMSG_TRADE_AGREED);
Net::GameServer::connection->send(msg);
}