--- deliantra/server/include/network.h 2007/07/28 12:02:58 1.15 +++ deliantra/server/include/network.h 2007/09/30 20:22:18 1.19 @@ -47,10 +47,10 @@ /* Maximum size of any packet we expect. * - * The size must be the same in the server and the client (stupid), and its also NOT - * the maximum buffer size as one would expect, but the maximum buffer size + 1. + * The size must be the same in the server and the client (stupid). + * TODO: make the actual network configurable per client and use 2**16. */ -#define MAXSOCKBUF 10240 +#define MAXSOCKBUF 10239 #define CS_QUERY_YESNO 0x1 /* Yes/no question */ #define CS_QUERY_SINGLECHAR 0x2 /* Single character response expected */ @@ -149,45 +149,6 @@ #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 @@ -269,6 +230,15 @@ uint32 val; ber32 (uint32 val) : val (val) { } + + static int encoded_size (uint32 val) + { + if (val >= (1 << 7*4)) return 5; + if (val >= (1 << 7*3)) return 4; + if (val >= (1 << 7*2)) return 3; + if (val >= (1 << 7*1)) return 2; + return 1; + } }; /* Contains the base information we use to make up a packet we want to send. */