summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorRonny Pfannschmidt <r0nny@users.sourceforge.net>2006-01-03 21:43:54 +0000
committerRonny Pfannschmidt <r0nny@users.sourceforge.net>2006-01-03 21:43:54 +0000
commit5bcc5490c6dd2cf5535ab283292217302e402ee7 (patch)
treed9ebdec29d65709f2aa354e450ec363f45c6af59 /src/net
parent2d58eee5901e866fe994c19d38d9dca3383fab37 (diff)
downloadmana-5bcc5490c6dd2cf5535ab283292217302e402ee7.tar.gz
mana-5bcc5490c6dd2cf5535ab283292217302e402ee7.tar.bz2
mana-5bcc5490c6dd2cf5535ab283292217302e402ee7.tar.xz
mana-5bcc5490c6dd2cf5535ab283292217302e402ee7.zip
moved network logic out of gui/trade.cpp to net/protocol_trade.{h,cpp}
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