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.1.1.1 by root, Fri Feb 3 07:12:49 2006 UTC vs.
Revision 1.7 by root, Wed Dec 13 18:08:01 2006 UTC

1/*
2 * static char *rcsid_newclient_h =
3 * "$Id: newclient.h,v 1.1.1.1 2006/02/03 07:12:49 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
47 42
48#ifndef NEWCLIENT_H 43#ifndef NEWCLIENT_H
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 teh 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 data8
238{
239 void *data;
240 int len;
241
242 data8 (int len, void *data) : len (len), data (data) { }
243 data8 (const char *str) : len (strlen (str ? str : 0)), data ((void *)str) { }
244 data8 (const shstr &sh) : len (sh.length ()), data ((void *)&sh) { }
245};
246
247struct data16
248{
249 void *data;
250 int len;
251
252 data16 (int len, void *data) : len (len), data (data) { }
253 data16 (const char *str) : len (strlen (str ? str : 0)), data ((void *)str) { }
254 data16 (const shstr &sh) : len (sh.length ()), data ((void *)&sh) { }
255};
256
239/* Contains the base information we use to make up a packet we want to send. */ 257/* Contains the base information we use to make up a packet we want to send. */
240typedef struct SockList { 258struct SockList
259{
260 uint8 *buf;
241 int len; 261 int len;
242 unsigned char *buf;
243} SockList;
244 262
263// SockList () buf (0), len (0) { }
264// SockList (int size) buf (malloc (size)), len (0) { }
265
266 SockList &operator <<(uint8 v) { buf [len++] = v; return *this; }
267
268 SockList &operator <<(uint16 v) { return *this << uint8 (v >> 8) << uint8 (v); }
269 SockList &operator <<(uint32 v) { return *this << uint16 (v >> 16) << uint16 (v); }
270 SockList &operator <<(uint64 v) { return *this << uint32 (v >> 32) << uint32 (v); }
271
272 SockList &operator <<(sint8 v) { return *this << (uint8 )v; }
273 SockList &operator <<(sint16 v) { return *this << (uint16)v; }
274 SockList &operator <<(sint32 v) { return *this << (uint32)v; }
275 SockList &operator <<(sint64 v) { return *this << (uint64)v; }
276
277 SockList &operator <<(const data8 &v);
278 SockList &operator <<(const data16 &v);
279};
280
281inline void SockList_AddChar (SockList *sl, uint8 data) { *sl << data; }
282inline void SockList_AddShort(SockList *sl, uint16 data) { *sl << data; }
283inline void SockList_AddInt (SockList *sl, uint32 data) { *sl << data; }
284inline void SockList_AddInt64(SockList *sl, uint64 data) { *sl << data; }
285
245typedef struct CS_Stats { 286struct CS_Stats
287{
246 int ibytes; /* ibytes, obytes are bytes in, out */ 288 int ibytes; /* ibytes, obytes are bytes in, out */
247 int obytes; 289 int obytes;
248 short max_conn; /* Maximum connections received */ 290 short max_conn; /* Maximum connections received */
249 time_t time_start; /* When we started logging this */ 291 time_t time_start; /* When we started logging this */
250} CS_Stats; 292};
251
252 293
253extern CS_Stats cst_tot, cst_lst; 294extern CS_Stats cst_tot, cst_lst;
254 295
255#endif 296#endif
297

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines