--- deliantra/server/include/network.h 2007/07/29 19:11:47 1.17 +++ deliantra/server/include/network.h 2010/03/26 01:04:44 1.29 @@ -1,24 +1,25 @@ /* - * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. + * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team - * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team - * Copyright (©) 1992,2007 Frank Tore Johansen + * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2002 Mark Wedel & Crossfire Development Team + * Copyright (©) 1992 Frank Tore Johansen * - * Crossfire TRT is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. + * Deliantra is free software: you can redistribute it and/or modify it under + * the terms of the Affero GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * You should have received a copy of the Affero GNU General Public License + * and the GNU General Public License along with this program. If not, see + * . * - * The authors can be reached via e-mail to + * The authors can be reached via e-mail to */ /* This file defines various flags that both the new client and @@ -39,16 +40,19 @@ * talking about the same values. */ - #ifndef NETWORK_H #define NETWORK_H +//+GPL + #include +#include "compiler.h" + /* Maximum size of any packet we expect. * * The size must be the same in the server and the client (stupid). - * TODO: make the actual network configurable per clietn and use 2**16. + * TODO: make the actual network configurable per client and use 2**16. */ #define MAXSOCKBUF 10239 @@ -149,47 +153,9 @@ #define SF_FIREON 0x01 #define SF_RUNON 0x02 -/* The following are the color flags passed to new_draw_info. - * - * We also set up some control flags - * - * NDI = New Draw Info - */ - -/* Color specifications - note these match the order in xutil.c */ -/* Note 2: Black, the default color, is 0. Thus, it does not need to - * be implicitly specified. - */ -#define NDI_BLACK 0 -#define NDI_WHITE 1 -#define NDI_NAVY 2 -#define NDI_RED 3 -#define NDI_ORANGE 4 -#define NDI_BLUE 5 /* Actually, it is Dodger Blue */ -#define NDI_DK_ORANGE 6 /* DarkOrange2 */ -#define NDI_GREEN 7 /* SeaGreen */ -#define NDI_LT_GREEN 8 /* DarkSeaGreen, which is actually paler */ - /* Than seagreen - also background color */ -#define NDI_GREY 9 -#define NDI_BROWN 10 /* Sienna */ -#define NDI_GOLD 11 -#define NDI_TAN 12 /* Khaki */ - -#define NDI_MAX_COLOR 12 /* Last value in */ -#define NDI_COLOR_MASK 0x1f /* Gives lots of room for expansion - we are */ - /* using an int anyways, so we have the space */ - /* to still do all the flags */ - -#define NDI_REPLY 0x20 // is a direct reply to a user command -#define NDI_NOCREATE 0x40 // do not create a tba if one doesn't exist -#define NDI_CLIENT_MASK 0x7f // what the client is allowed to see - -#define NDI_UNIQUE 0x1000 /* Print this out immediately, don't buffer */ -#define NDI_ALL 0x2000 /* Inform all players of this message */ -#define NDI_DEF 0x4000 // ignore colour for channel protocol - /* Flags for the item command */ enum {a_none, a_readied, a_wielded, a_worn, a_active, a_applied}; + #define F_APPLIED 0x000F #define F_LOCATION 0x00F0 #define F_UNPAID 0x0200 @@ -228,11 +194,13 @@ /* The flag values sent by the updspell command */ #define UPD_SP_MANA 0x01 #define UPD_SP_GRACE 0x02 -#define UPD_SP_DAMAGE 0x04 +#define UPD_SP_LEVEL 0x04 // was UPD_SP_DAMAGE in <= server 2.93, client 2.10 #define SOUND_NORMAL 0 #define SOUND_SPELL 1 +//-GPL + struct data { unsigned int len; @@ -240,7 +208,8 @@ data (const void *ptr, int len) : len (len), ptr (ptr) { } data (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { } - data (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { } + data (shstr_tmp sh) : len (sh.length ()), ptr ((void *)&sh) { } + data (dynbuf &buf) : len (buf.size ()), ptr (buf.linearise ()) { } }; struct data8 @@ -250,7 +219,8 @@ data8 (const void *ptr, int len) : len (len), ptr (ptr) { } data8 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { } - data8 (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { } + data8 (shstr_tmp sh) : len (sh.length ()), ptr ((void *)&sh) { } + data8 (dynbuf &buf) : len (buf.size ()), ptr (buf.linearise ()) { } }; struct data16 @@ -260,7 +230,8 @@ data16 (const void *ptr, int len) : len (len), ptr (ptr) { } data16 (const char *str) : len (strlen (str ? str : 0)), ptr ((void *)str) { } - data16 (const shstr &sh) : len (sh.length ()), ptr ((void *)&sh) { } + data16 (shstr_tmp sh) : len (sh.length ()), ptr ((void *)&sh) { } + data16 (dynbuf &buf) : len (buf.size ()), ptr (buf.linearise ()) { } }; struct ber32 @@ -328,12 +299,12 @@ packet &operator <<(const data16 &v); packet &operator <<(const char *v); - packet &operator <<(const shstr &sh) { return *this << data (&sh, sh.length ()); } + packet &operator <<(shstr_tmp sh) { return *this << data (sh); } packet &operator <<(const std::string &s) { return *this << data (s.data (), s.size ()); } void vprintf (const char *format, va_list ap); - void printf (const char *format, ...) + void printf (const char *format, ...) attribute ((format (printf, 2, 3))) { va_list ap; va_start (ap, format);