1 // ============================================================================
2 // Rocks'n'Diamonds - McDuffin Strikes Back!
3 // ----------------------------------------------------------------------------
4 // (c) 1995-2014 by Artsoft Entertainment
7 // https://www.artsoft.org/
8 // ----------------------------------------------------------------------------
10 // ============================================================================
17 #define DEFAULT_SERVER_PORT 19504
19 #define PROTOCOL_VERSION_MAJOR 2
20 #define PROTOCOL_VERSION_MINOR 0
21 #define PROTOCOL_VERSION_PATCH 0
23 #define OP_PROTOCOL_VERSION 1
24 #define OP_BAD_PROTOCOL_VERSION 2
25 #define OP_YOUR_NUMBER 3
26 #define OP_NUMBER_WANTED 4
27 #define OP_PLAYER_NAME 5
28 #define OP_PLAYER_CONNECTED 6
29 #define OP_PLAYER_DISCONNECTED 7
30 #define OP_START_PLAYING 8
31 #define OP_PAUSE_PLAYING 9
32 #define OP_CONTINUE_PLAYING 10
33 #define OP_STOP_PLAYING 11
34 #define OP_MOVE_PLAYER 12
35 #define OP_BROADCAST_MESSAGE 13
36 #define OP_LEVEL_FILE 14
38 #define MAX_BUFFER_SIZE 4096
39 #define MAX_PACKET_SIZE 1048576
44 unsigned int max_size;
52 int getNetwork8BitInteger(byte *);
53 int putNetwork8BitInteger(byte *, int);
54 int getNetwork16BitInteger(byte *);
55 int putNetwork16BitInteger(byte *, int);
56 int getNetwork32BitInteger(byte *);
57 int putNetwork32BitInteger(byte *, int);
58 char *getNetworkString(byte *);
59 int putNetworkString(byte *, char *);
61 struct NetworkBuffer *newNetworkBuffer(void);
62 void initNetworkBufferForReceiving(struct NetworkBuffer *);
63 void initNetworkBufferForReading(struct NetworkBuffer *);
64 void initNetworkBufferForWriting(struct NetworkBuffer *, int, int);
66 int receiveNetworkBufferBytes(struct NetworkBuffer *, TCPsocket, int);
67 int receiveNetworkBufferPacket(struct NetworkBuffer *, TCPsocket);
69 int getNetworkBuffer8BitInteger(struct NetworkBuffer *);
70 void putNetworkBuffer8BitInteger(struct NetworkBuffer *, int);
71 int getNetworkBuffer16BitInteger(struct NetworkBuffer *);
72 void putNetworkBuffer16BitInteger(struct NetworkBuffer *, int);
73 int getNetworkBuffer32BitInteger(struct NetworkBuffer *);
74 void putNetworkBuffer32BitInteger(struct NetworkBuffer *, int);
75 char *getNetworkBufferString(struct NetworkBuffer *);
76 void putNetworkBufferString(struct NetworkBuffer *, char *);
77 int getNetworkBufferFile(struct NetworkBuffer *, char *);
78 int putNetworkBufferFile(struct NetworkBuffer *, char *);
80 void dumpNetworkBuffer(struct NetworkBuffer *);
82 int NetworkServerThread(void *);
83 void NetworkServer(int, int);