summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/net')
-rw-r--r--src/net/protocol_trade.cpp50
-rw-r--r--src/net/protocol_trade.h36
2 files changed, 86 insertions, 0 deletions
diff --git a/src/net/protocol_trade.cpp b/src/net/protocol_trade.cpp
new file mode 100644
index 00000000..0271567e
--- /dev/null
+++ b/src/net/protocol_trade.cpp
@@ -0,0 +1,50 @@
+
+#include "protocol_trade.h"
+
+#include "../item.h"
+#include "../gui/trade.h"
+
+#include "messageout.h"
+
+cancel_t cancel;
+complete_t complete;
+
+/** Start trading with someone */
+void trade(Being&);
+
+void trade(int id,int amount)
+{
+ MessageOut outMsg;
+ outMsg.writeInt16(CMSG_TRADE_ITEM_ADD_REQUEST);
+ outMsg.writeInt16(id);
+ outMsg.writeInt32(amount);
+};
+
+/** add trading item*/
+
+void trade(Item& item,int amount)
+{
+trade(item.getInvIndex(),amount);
+}
+
+/** add money to trade */
+void trade(int i){trade(0,i);};
+
+/** cancel courent trade */
+void trade(cancel_t&)
+{
+ MessageOut outMsg;
+ outMsg.writeInt16(CMSG_TRADE_CANCEL_REQUEST);
+};
+
+void trade()
+{
+ MessageOut outMsg;
+ outMsg.writeInt16(CMSG_TRADE_OK);
+};
+
+void trade(complete_t&)
+{
+ MessageOut outMsg;
+ outMsg.writeInt16(CMSG_TRADE_ADD_COMPLETE);
+};
diff --git a/src/net/protocol_trade.h b/src/net/protocol_trade.h
new file mode 100644
index 00000000..42908ab2
--- /dev/null
+++ b/src/net/protocol_trade.h
@@ -0,0 +1,36 @@
+#ifndef _TMW_PROTOCOL_HELPER_
+#define _TMW_PROTOCOL_HELPER_
+
+#include "protocol.h"
+
+
+/**
+ * Helper class for using <actionfunc>(cancel), to cancel stuff
+ */
+class cancel_t {};
+extern cancel_t cancel;
+
+class complete_t {};
+extern complete_t complete;
+
+
+class Item;
+
+/** Start trading with someone */
+void trade(Being&);
+
+/** add trading item*/
+void trade(Item&,int amount);
+
+/** add money to trade */
+void trade(int);
+
+/** verify the trade */
+void trade();
+
+void trade(complete_t&);
+
+/** cancel courent trade */
+void trade(cancel_t&);
+
+#endif