ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/newclient.h
(Generate patch)

Comparing deliantra/server/include/newclient.h (file contents):
Revision 1.2 by root, Mon Mar 13 20:45:39 2006 UTC vs.
Revision 1.14 by root, Thu Dec 14 01:30:52 2006 UTC

1/*
2 * static char *rcsid_newclient_h =
3 * "$Id: newclient.h,v 1.2 2006/03/13 20:45:39 root Exp $";
4 */
5
6/* 1/*
7 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
8 3
9 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
49#define NEWCLIENT_H 44#define NEWCLIENT_H
50 45
51/* Maximum size of any packet we expect. Using this makes it so we don't need to 46/* Maximum size of any packet we expect. Using this makes it so we don't need to
52 * allocated and deallocated the same buffer over and over again and the price 47 * allocated and deallocated the same buffer over and over again and the price
53 * of using a bit of extra memory. It also makes the code simpler. 48 * of using a bit of extra memory. It also makes the code simpler.
49 *
50 * The size must be the same in the server and the client (stupid), and its also NOT
51 * the maximum buffer size as one would expect, but the maximum buffer size + 1.
54 */ 52 */
55#define MAXSOCKBUF 10240 53#define MAXSOCKBUF 10240
56 54
57 55
58#define CS_QUERY_YESNO 0x1 /* Yes/no question */ 56#define CS_QUERY_YESNO 0x1 /* Yes/no question */
174#define NDI_ORANGE 4 172#define NDI_ORANGE 4
175#define NDI_BLUE 5 /* Actually, it is Dodger Blue */ 173#define NDI_BLUE 5 /* Actually, it is Dodger Blue */
176#define NDI_DK_ORANGE 6 /* DarkOrange2 */ 174#define NDI_DK_ORANGE 6 /* DarkOrange2 */
177#define NDI_GREEN 7 /* SeaGreen */ 175#define NDI_GREEN 7 /* SeaGreen */
178#define NDI_LT_GREEN 8 /* DarkSeaGreen, which is actually paler */ 176#define NDI_LT_GREEN 8 /* DarkSeaGreen, which is actually paler */
179 /* Than seagreen - also background color */ 177 /* Than seagreen - also background color */
180#define NDI_GREY 9 178#define NDI_GREY 9
181#define NDI_BROWN 10 /* Sienna */ 179#define NDI_BROWN 10 /* Sienna */
182#define NDI_GOLD 11 180#define NDI_GOLD 11
183#define NDI_TAN 12 /* Khaki */ 181#define NDI_TAN 12 /* Khaki */
184 182
185#define NDI_MAX_COLOR 12 /* Last value in */ 183#define NDI_MAX_COLOR 12 /* Last value in */
186#define NDI_COLOR_MASK 0xff /* Gives lots of room for expansion - we are */ 184#define NDI_COLOR_MASK 0xff /* Gives lots of room for expansion - we are */
187 /* using an int anyways, so we have the space */ 185 /* using an int anyways, so we have the space */
188 /* to still do all the flags */ 186 /* to still do all the flags */
189 187
190 188
191#define NDI_UNIQUE 0x100 /* Print this out immediately, don't buffer */ 189#define NDI_UNIQUE 0x100 /* Print this out immediately, don't buffer */
192#define NDI_ALL 0x200 /* Inform all players of this message */ 190#define NDI_ALL 0x200 /* Inform all players of this message */
193 191
213 * are color informatin. For now, only high bit information we need 211 * are color informatin. For now, only high bit information we need
214 * is floor information. 212 * is floor information.
215 */ 213 */
216#define FACE_FLOOR 0x80 214#define FACE_FLOOR 0x80
217#define FACE_WALL 0x40 /* Or'd into the color value by the server 215#define FACE_WALL 0x40 /* Or'd into the color value by the server
218 * right before sending. 216 * right before sending.
219 */ 217 */
220#define FACE_COLOR_MASK 0xf 218#define FACE_COLOR_MASK 0xf
221 219
222#define UPD_LOCATION 0x01 220#define UPD_LOCATION 0x01
223#define UPD_FLAGS 0x02 221#define UPD_FLAGS 0x02
224#define UPD_WEIGHT 0x04 222#define UPD_WEIGHT 0x04
234#define UPD_SP_DAMAGE 0x04 232#define UPD_SP_DAMAGE 0x04
235 233
236#define SOUND_NORMAL 0 234#define SOUND_NORMAL 0
237#define SOUND_SPELL 1 235#define SOUND_SPELL 1
238 236
237struct data
238{
239 const void *ptr;
240 unsigned int len;
241
242 data (const void *ptr, int len) : len (len), ptr (ptr) { }
243 data (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { }
244 data (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { }
245};
246
247struct data8
248{
249 const void *ptr;
250 unsigned int len;
251
252 data8 (const void *ptr, int len) : len (len), ptr (ptr) { }
253 data8 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { }
254 data8 (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { }
255};
256
257struct data16
258{
259 const void *ptr;
260 unsigned int len;
261
262 data16 (const void *ptr, int len) : len (len), ptr (ptr) { }
263 data16 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { }
264 data16 (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { }
265};
266
239/* Contains the base information we use to make up a packet we want to send. */ 267/* Contains the base information we use to make up a packet we want to send. */
240typedef struct SockList { 268struct packet
269{
270 packet () : len (0) { }
271
272 void reset () { len = 0; }
273 int length () const { return len; }
274
275 packet &operator <<(uint8 v) { buf [len++] = v; return *this; }
276
277 packet &operator <<(uint16 v) { return *this << uint8 (v >> 8) << uint8 (v); }
278 packet &operator <<(uint32 v) { return *this << uint16 (v >> 16) << uint16 (v); }
279 packet &operator <<(uint64 v) { return *this << uint32 (v >> 32) << uint32 (v); }
280
281 packet &operator <<(sint8 v) { return *this << (uint8 )v; }
282 packet &operator <<(sint16 v) { return *this << (uint16)v; }
283 packet &operator <<(sint32 v) { return *this << (uint32)v; }
284 packet &operator <<(sint64 v) { return *this << (uint64)v; }
285
286 packet &operator <<(const data &v);
287 packet &operator <<(const data8 &v);
288 packet &operator <<(const data16 &v);
289
290 packet &operator <<(const char *v);
291 packet &operator <<(const shstr &sh) { return *this << data (&sh, sh.length ()); }
292
293 void printf (const char *format, ...);
294
295public:
296 uint8 buf [MAXSOCKBUF];
241 int len; 297 int len;
242 unsigned char *buf; 298};
243} SockList;
244 299
300inline uint16 net_uint16 (uint8 *data) { return (data [0] << 8) | data [1]; }
301inline uint32 net_uint32 (uint8 *data) { return (net_uint16 (data) << 16) | net_uint16 (data + 2); }
302inline sint16 net_sint16 (uint8 *data) { return sint16 (net_uint16 (data)); }
303inline sint16 net_sint32 (uint8 *data) { return sint32 (net_uint32 (data)); }
304
245typedef struct CS_Stats { 305struct CS_Stats
306{
246 int ibytes; /* ibytes, obytes are bytes in, out */ 307 int ibytes; /* ibytes, obytes are bytes in, out */
247 int obytes; 308 int obytes;
248 short max_conn; /* Maximum connections received */ 309 short max_conn; /* Maximum connections received */
249 time_t time_start; /* When we started logging this */ 310 time_t time_start; /* When we started logging this */
250} CS_Stats; 311};
251
252 312
253extern CS_Stats cst_tot, cst_lst; 313extern CS_Stats cst_tot, cst_lst;
254 314
255#endif 315#endif
316

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines