ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/client.h
(Generate patch)

Comparing deliantra/server/include/client.h (file contents):
Revision 1.91 by root, Mon Nov 9 18:47:56 2009 UTC vs.
Revision 1.96 by root, Thu Apr 8 19:31:22 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * 5 *
6 * Deliantra is free software: you can redistribute it and/or modify it under 6 * Deliantra is free software: you can redistribute it and/or modify it under
7 * the terms of the Affero GNU General Public License as published by the 7 * the terms of the Affero GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your 8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version. 9 * option) any later version.
20 * The authors can be reached via e-mail to <support@deliantra.net> 20 * The authors can be reached via e-mail to <support@deliantra.net>
21 */ 21 */
22 22
23#ifndef CLIENT_H 23#ifndef CLIENT_H
24#define CLIENT_H 24#define CLIENT_H
25
26#include <deque>
27#include <bitset>
28#include <tr1/unordered_set>
29 25
30#if HAVE_TCP_INFO 26#if HAVE_TCP_INFO
31# include <netinet/tcp.h> 27# include <netinet/tcp.h>
32#else 28#else
33 struct tcp_info { 29 struct tcp_info {
193 bool ACC (RW, monitor_spells); /* Client wishes to be informed when their spell list changes */ 189 bool ACC (RW, monitor_spells); /* Client wishes to be informed when their spell list changes */
194 bool ACC (RW, smoothing); // deliantra-style smoothing 190 bool ACC (RW, smoothing); // deliantra-style smoothing
195 191
196 bool ACC (RW, force_newmap); // force a newmap before next map update 192 bool ACC (RW, force_newmap); // force a newmap before next map update
197 uint32 ACC (RW, supported_readables); /* each bit is a readable supported by client */ 193 uint32 ACC (RW, supported_readables); /* each bit is a readable supported by client */
198 uint32 ACC (RW, cs_version), ACC (RW, sc_version); /* versions of the client */
199 uint16 ACC (RW, look_position); /* start of drawing of look window */ 194 uint16 ACC (RW, look_position); /* start of drawing of look window */
200 uint16 ACC (RW, mss); // likely tcp maximum segment size 195 uint16 ACC (RW, mss); // likely tcp maximum segment size
201 uint8 ACC (RW, mapmode); /* Type of map commands the client wants. */ 196 uint8 ACC (RW, mapmode); /* Type of map commands the client wants. */
202 uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */ 197 uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */
203 uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */ 198 uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */
204 199
205 maptile_ptr ACC (RW, current_map); // CF+ last/current player map 200 maptile_ptr ACC (RW, current_map); // CF+ last/current player map
206 region_ptr ACC (RW, current_region); // CF+ last/current player region 201 region_ptr ACC (RW, current_region); // CF+ last/current player region
207 int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position 202 int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position
208 shstr ACC (RW, version); // CF+ client name/version
209 uint8 ACC (RW, faceset); // CF+ selected faceset 203 uint8 ACC (RW, faceset); // CF+ selected faceset
210 204
211 tstamp ACC (RW, last_send); // last data send on socket. 205 tstamp ACC (RW, last_send); // last data send on socket.
212 206
213 float ACC (RW, socket_timeout); /* after how many seconds of no ack do we declare dead */ 207 float ACC (RW, socket_timeout); /* after how many seconds of no ack do we declare dead */
258 int len; 252 int len;
259 int count; 253 int count;
260 char msg[MSG_BUF_SIZE]; 254 char msg[MSG_BUF_SIZE];
261 } msgbuf[MSG_BUF_COUNT]; 255 } msgbuf[MSG_BUF_COUNT];
262 256
263 MTH bool msg_suppressed (const char *msg); 257 MTH bool msg_suppressed (const_utf8_string msg);
264 258
265 /* The following is the setup for a ring buffer for storing output 259 /* The following is the setup for a ring buffer for storing output
266 * data that the OS can't handle right away. 260 * data that the OS can't handle right away.
267 * TODO: this member is enourmously large - optimise? 261 * TODO: this member is enourmously large - optimise?
268 */ 262 */
290 MTH void flush (); 284 MTH void flush ();
291 MTH void write_outputbuffer (); 285 MTH void write_outputbuffer ();
292 MTH int outputbuffer_len () const { return outputbuffer.len; } 286 MTH int outputbuffer_len () const { return outputbuffer.len; }
293 void send (void *buf_, int len); 287 void send (void *buf_, int len);
294 288
295 void send_packet (const char *buf); 289 void send_packet (const_octet_string buf);
296 void send_packet (const char *buf, int len); 290 void send_packet (const_octet_string buf, int len);
297 void send_packet_printf (const char *format, ...) attribute ((format (printf, 2, 3))); 291 void send_packet_printf (const_utf8_string format, ...) attribute ((format (printf, 2, 3)));
298 void send_packet (packet &sl); 292 void send_packet (packet &sl);
299 293
300 void send_drawinfo (const char *msg, int flags = NDI_BLACK); 294 void send_drawinfo (const_utf8_string msg, int flags = NDI_BLACK);
301 295
302 MTH void send_face (faceidx facenum, int pri = 0); 296 MTH void send_face (faceidx facenum, int pri = 0);
303 MTH void send_faces (object *ob); 297 MTH void send_faces (object *ob);
304 MTH void send_animation (short anim_num); 298 MTH void send_animation (short anim_num);
305 void send_msg (int color, const char *type, const char *msg); 299 void send_msg (int color, const_utf8_string type, const_utf8_string msg);
306 300
307 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0); 301 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0);
308 // called when something under the player changes 302 // called when something under the player changes
309 MTH void floorbox_update () { update_look = 1; } 303 MTH void floorbox_update () { update_look = 1; }
310 // called when the player has been moved 304 // called when the player has been moved
361 ((__sockPtr)->supported_readables & (1<<(__type))) ) 355 ((__sockPtr)->supported_readables & (1<<(__type))) )
362 356
363#define FACE_TYPES 1 357#define FACE_TYPES 1
364#define PNG_FACE_INDEX 0 358#define PNG_FACE_INDEX 0
365 359
366#define VERSION_CS 1023 /* version >= 1023 understand setup cmd */
367#define VERSION_SC 1026
368//#define VERSION_SC 1027 // requestinfo image_info and image_sums, makes extending faces on the fly impossible
369#define VERSION_INFO "Deliantra Server"
370
371//-GPL 360//-GPL
372 361
373typedef object_vector<client, &client::active> sockvec; 362typedef object_vector<client, &client::active> sockvec;
374 363
375extern sockvec clients; 364extern sockvec clients;
378 for (int _i = 0; _i < clients.size (); ++_i) \ 367 for (int _i = 0; _i < clients.size (); ++_i) \
379 statementvar (client *, var, clients [_i]) 368 statementvar (client *, var, clients [_i])
380 369
381// returns true when the message needs special (read: perl) treatment 370// returns true when the message needs special (read: perl) treatment
382static inline bool 371static inline bool
383msg_is_special (const char *msg, bool nl_special = true) 372msg_is_special (const_any_string msg, bool nl_special = true)
384{ 373{
385 return msg [strcspn (msg, nl_special ? "<&\n" : "<&")]; 374 return msg [strcspn (msg, nl_special ? "<&\n" : "<&")];
386} 375}
387 376
388#endif 377#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines