summaryrefslogtreecommitdiff
path: root/src/net/network.h
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-09-13 22:56:29 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-09-13 22:56:29 +0000
commit3dc311a652d1fda1252903a974920395e56e5668 (patch)
tree7098d55015d28a4d973c5073d7c9e45ae03ec400 /src/net/network.h
parent78771718bf7af14273d7bb0090dccff97b00b397 (diff)
downloadmana-client-3dc311a652d1fda1252903a974920395e56e5668.tar.gz
mana-client-3dc311a652d1fda1252903a974920395e56e5668.tar.bz2
mana-client-3dc311a652d1fda1252903a974920395e56e5668.tar.xz
mana-client-3dc311a652d1fda1252903a974920395e56e5668.zip
Merged with SDL_NET_TEST branch.
Diffstat (limited to 'src/net/network.h')
-rw-r--r--src/net/network.h79
1 files changed, 23 insertions, 56 deletions
diff --git a/src/net/network.h b/src/net/network.h
index cc5e542f..a037c6fa 100644
--- a/src/net/network.h
+++ b/src/net/network.h
@@ -21,67 +21,20 @@
* $Id$
*/
-#ifndef _TMW_NETWORK_H
-#define _TMW_NETWORK_H
-
-#ifndef WIN32
-#include "win2linux.h"
-#else
-#include <winsock.h>
-#endif
-
-#include <stdio.h>
-
-#ifdef MACOSX
-#include "win2mac.h"
-#endif
-
-/** Macros to write in output buffer, pos is the location where to write data
- After you wrote len bytes, you have to use WFIFOSET */
-#define WFIFOSPACE (buffer_size-out_size) // Number of bytes currently written in uotput buffer
-#define WFIFOP(pos) (out+(pos+out_size)) // Return a pointer to a specific location in output buffer
-#define WFIFOB(pos) (*(unsigned char *)(out+pos+out_size)) // Write a byte (1 byte)
-#define WFIFOW(pos) (*(unsigned short *)(out+pos+out_size)) // Write a word (2 byte)
-#define WFIFOL(pos) (*(unsigned int *)(out+pos+out_size)) // Write a long (4 byte)
-//#define WFIFOSET(len) out_size+=len // Increase size of written data
-
-#ifdef MACOSX
- #define net_b_value(id) (id)
- #define net_w_value(id) DR_SwapTwoBytes(id)
- #define net_l_value(id) DR_SwapFourBytes(id)
-#else
- #define net_b_value(id) (id)
- #define net_w_value(id) (id)
- #define net_l_value(id) (id)
-#endif
+#ifndef _TMW_NETWORK_
+#define _TMW_NETWORK_
+#include <string>
-/** Macros to read from input buffer, pos is the location of data to be read
- After you read len bytes, you should use RFIFOSKIP */
-#define RFIFOP(pos) (in+(pos)) // Get a pointer from a specific location in input buffer
-
-#ifdef MACOSX
- #define RFIFOB(pos) ((*(unsigned char*)(in+(pos)))) // Read a byte
- #define RFIFOW(pos) DR_SwapTwoBytes((*(unsigned short*)(in+(pos)))) // Read a word
- #define RFIFOL(pos) DR_SwapFourBytes((*(unsigned int*)(in+(pos)))) // Read a long
-#else
- #define RFIFOB(pos) (*(unsigned char*)(in+(pos))) // Read a byte
- #define RFIFOW(pos) (*(unsigned short*)(in+(pos))) // Read a word
- #define RFIFOL(pos) (*(unsigned int*)(in+(pos))) // Read a long
-#endif
-
-#define RFIFOSKIP(len) (memcpy(in,in+len,in_size-len));in_size-=len; // Empty len bytes from input buffer
-#define RFIFOSPACE (buffer_size-in_size) // Return input buffer size
-#define RFIFOSET(len) in_size+=len;
-
-/** Increase size of written data */
-void WFIFOSET(int len);
+#include "SDL_net.h"
+#include "messagein.h"
+#include "messageout.h"
/** Convert an address from int format to string */
char *iptostring(int address);
/** Open a session with a server */
-SOCKET open_session(const char* address, short port);
+int open_session(const char* address, short port);
/** Close a session */
void close_session();
@@ -89,7 +42,21 @@ void close_session();
/** Send and receive data waiting in the buffers */
void flush();
-extern char *in, *out; // Input, output buffer
-extern int in_size, out_size; // Input, output buffer size
+/**
+ * Returns the next arriving message, waiting for it if necessary.
+ */
+MessageIn get_next_message();
+extern char *out;
+
+
+void writeByte(int pos, unsigned char value);//writeByte(char value);
+void writeWord(int pos, unsigned short value);//writeWord(short value);
+void writeLong(int pos, unsigned int value);//writeLong(int value);
+char *writePointer(int pos); //writeString(const std::string &string, int length);
+void writeSet(unsigned int value);
+void skip(int len);
+
+extern unsigned int in_size; /**< Amount of data in input buffer. */
+extern unsigned int out_size; /**< Amount of data in output buffer. */
#endif