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.5 by root, Tue Aug 29 08:01:36 2006 UTC vs.
Revision 1.11 by root, Thu Dec 14 00:23:59 2006 UTC

1/*
2 * static char *rcsid_newclient_h =
3 * "$Id: newclient.h,v 1.5 2006/08/29 08:01:36 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
237#define UPD_SP_DAMAGE 0x04 232#define UPD_SP_DAMAGE 0x04
238 233
239#define SOUND_NORMAL 0 234#define SOUND_NORMAL 0
240#define SOUND_SPELL 1 235#define SOUND_SPELL 1
241 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
242/* 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. */
243struct SockList { 268struct SockList
269{
270 SockList () : buf (0), len (0) { }
271 SockList (int size) : buf ((uint8 *)malloc (size)), len (0) { }
272
273 void reset () { len = 0; }
274 int length () const { return len; }
275
276 SockList &operator <<(uint8 v) { buf [len++] = v; return *this; }
277
278 SockList &operator <<(uint16 v) { return *this << uint8 (v >> 8) << uint8 (v); }
279 SockList &operator <<(uint32 v) { return *this << uint16 (v >> 16) << uint16 (v); }
280 SockList &operator <<(uint64 v) { return *this << uint32 (v >> 32) << uint32 (v); }
281
282 SockList &operator <<(sint8 v) { return *this << (uint8 )v; }
283 SockList &operator <<(sint16 v) { return *this << (uint16)v; }
284 SockList &operator <<(sint32 v) { return *this << (uint32)v; }
285 SockList &operator <<(sint64 v) { return *this << (uint64)v; }
286
287 SockList &operator <<(const data &v);
288 SockList &operator <<(const data8 &v);
289 SockList &operator <<(const data16 &v);
290
291 SockList &operator <<(const char *v);
292 SockList &operator <<(const shstr &sh) { return *this << data (&sh, sh.length ()); }
293
294 void printf (const char *format, ...);
295
296 void free () { ::free (buf); }
297
298public:
299 uint8 *buf;
244 int len; 300 int len;
245 unsigned char *buf;
246}; 301};
247 302
248inline void SockList_AddChar (SockList *sl, char c) 303inline void SockList_AddChar (SockList *sl, uint8 data) { *sl << data; }
249{
250 sl->buf[sl->len++]=c;
251}
252
253inline void SockList_AddShort (SockList *sl, unsigned short data) 304inline void SockList_AddShort (SockList *sl, uint16 data) { *sl << data; }
254{ 305inline void SockList_AddInt (SockList *sl, uint32 data) { *sl << data; }
255 sl->buf[sl->len++] = data >> 8; 306inline void SockList_AddInt64 (SockList *sl, uint64 data) { *sl << data; }
256 sl->buf[sl->len++] = data;
257}
258 307
308inline uint16 net_uint16 (uint8 *data) { return (data [0] << 8) | data [1]; }
309inline uint32 net_uint32 (uint8 *data) { return (net_uint16 (data) << 16) | net_uint16 (data + 2); }
310inline sint16 net_sint16 (uint8 *data) { return sint16 (net_uint16 (data)); }
311inline sint16 net_sint32 (uint8 *data) { return sint32 (net_uint32 (data)); }
312
259struct CS_Stats { 313struct CS_Stats
314{
260 int ibytes; /* ibytes, obytes are bytes in, out */ 315 int ibytes; /* ibytes, obytes are bytes in, out */
261 int obytes; 316 int obytes;
262 short max_conn; /* Maximum connections received */ 317 short max_conn; /* Maximum connections received */
263 time_t time_start; /* When we started logging this */ 318 time_t time_start; /* When we started logging this */
264}; 319};
265 320
266extern CS_Stats cst_tot, cst_lst; 321extern CS_Stats cst_tot, cst_lst;
267 322
268#endif 323#endif
324

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines