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.9 by root, Wed Dec 13 21:27:09 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 SockList
269{
270 SockList () : buf (0), len (0) { }
271 SockList (int size) : buf ((uint8 *)malloc (size)), len (0) { }
272
273 int length () const { return len; }
274
275 SockList &operator <<(uint8 v) { buf [len++] = v; return *this; }
276
277 SockList &operator <<(uint16 v) { return *this << uint8 (v >> 8) << uint8 (v); }
278 SockList &operator <<(uint32 v) { return *this << uint16 (v >> 16) << uint16 (v); }
279 SockList &operator <<(uint64 v) { return *this << uint32 (v >> 32) << uint32 (v); }
280
281 SockList &operator <<(sint8 v) { return *this << (uint8 )v; }
282 SockList &operator <<(sint16 v) { return *this << (uint16)v; }
283 SockList &operator <<(sint32 v) { return *this << (uint32)v; }
284 SockList &operator <<(sint64 v) { return *this << (uint64)v; }
285
286 SockList &operator <<(const data &v);
287 SockList &operator <<(const data8 &v);
288 SockList &operator <<(const data16 &v);
289
290 SockList &operator <<(const char *v);
291 SockList &operator <<(const shstr &sh) { return *this << data (&sh, sh.length ()); }
292
293 void printf (const char *format, ...);
294
295 void free () { ::free (buf); }
296
297public:
298 uint8 *buf;
241 int len; 299 int len;
242 unsigned char *buf; 300};
243} SockList;
244 301
302inline void SockList_AddChar (SockList *sl, uint8 data) { *sl << data; }
303inline void SockList_AddShort (SockList *sl, uint16 data) { *sl << data; }
304inline void SockList_AddInt (SockList *sl, uint32 data) { *sl << data; }
305inline void SockList_AddInt64 (SockList *sl, uint64 data) { *sl << data; }
306
245typedef struct CS_Stats { 307struct CS_Stats
308{
246 int ibytes; /* ibytes, obytes are bytes in, out */ 309 int ibytes; /* ibytes, obytes are bytes in, out */
247 int obytes; 310 int obytes;
248 short max_conn; /* Maximum connections received */ 311 short max_conn; /* Maximum connections received */
249 time_t time_start; /* When we started logging this */ 312 time_t time_start; /* When we started logging this */
250} CS_Stats; 313};
251
252 314
253extern CS_Stats cst_tot, cst_lst; 315extern CS_Stats cst_tot, cst_lst;
254 316
255#endif 317#endif
318

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines