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.90 by root, Sat Nov 7 18:30:05 2009 UTC vs.
Revision 1.101 by root, Sat Oct 16 22:51:51 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 {
99 * current state. we set up our on buffers for sending/receiving, so we can 95 * current state. we set up our on buffers for sending/receiving, so we can
100 * handle some higher level functions. fd is the actual file descriptor we 96 * handle some higher level functions. fd is the actual file descriptor we
101 * are using. 97 * are using.
102 */ 98 */
103 99
104/* Only one map mode can actually be used, so lets make it a switch
105 * instead of having a bunch of different fields that needed to
106 * get toggled.
107 */
108enum { Map0Cmd = 0, Map1Cmd = 1, Map1aCmd = 2 };
109
110// states the socket can be in 100// states the socket can be in
111enum { 101enum {
112 ST_DEAD, // socket is dead 102 ST_DEAD, // socket is dead
113 ST_SETUP, // initial handshake / setup / login 103 ST_SETUP, // initial handshake / setup / login
114 ST_PLAYING, // logged in an playing 104 ST_PLAYING, // logged in an playing
175 uint32 ACC (RW, last_path_repelled); /* Last spell repelled sent to client */ 165 uint32 ACC (RW, last_path_repelled); /* Last spell repelled sent to client */
176 uint32 ACC (RW, last_path_denied); /* Last spell denied sent to client */ 166 uint32 ACC (RW, last_path_denied); /* Last spell denied sent to client */
177 living ACC (RO, last_stats); /* Last stats as sent to client */ 167 living ACC (RO, last_stats); /* Last stats as sent to client */
178 float ACC (RW, last_speed); /* Last speed as sent to client */ 168 float ACC (RW, last_speed); /* Last speed as sent to client */
179 sint16 ACC (RW, last_resist[NROFATTACKS]);/* last resist values sent to client */ 169 sint16 ACC (RW, last_resist[NROFATTACKS]);/* last resist values sent to client */
180 sint64 ACC (RW, last_skill_exp[NUM_SKILLS]);/* shadow register. if != exp. obj update client */ 170 sint64 ACC (RW, last_skill_exp[CS_NUM_SKILLS]);/* shadow register. if != exp. obj update client */
181 171
182 bool ACC (RW, afk); /* player is afk */ 172 bool ACC (RW, afk); /* player is afk */
183 bool ACC (RW, sent_scroll); 173 bool ACC (RW, sent_scroll);
184 bool ACC (RW, sound); /* does the client want sound */ 174 bool ACC (RW, sound); /* does the client want sound */
185 bool ACC (RW, newmapcmd); /* Send newmap command when entering new map SMACFIGGEN */ 175 bool ACC (RW, bumpmsg); /* give message when bumping into walls */
176
186 bool ACC (RW, plugincmd); // extend the protocol through a plug-in */ 177 bool ACC (RW, plugincmd); // extend the protocol through a plug-in */
187 bool ACC (RW, mapinfocmd); // return map info and send map change info 178 bool ACC (RW, mapinfocmd); // return map info and send map change info
188 uint8_t ACC (RW, extcmd); // call into extensions/plugins 179 uint8_t ACC (RW, extcmd); // call into extensions/plugins
180 bool ACC (RW, need_delinv0); /* If true, we need to delinv 0 before sending new floorbox */
181
189 bool ACC (RW, update_look); /* If true, we need to send the look window */ 182 bool ACC (RW, update_look); /* If true, we need to send the look window */
183 bool ACC (RW, update_spells); // If true, we need to esrv_update_spells
190 bool ACC (RW, has_readable_type); /* If true client accept additional text information */ 184 bool ACC (RW, has_readable_type); /* If true client accept additional text information */
191 /* used to arrange text in books, scrolls, or scripted dialogs */
192 bool ACC (RW, monitor_spells); /* Client wishes to be informed when their spell list changes */ 185 bool ACC (RW, monitor_spells); /* Client wishes to be informed when their spell list changes */
186
193 bool ACC (RW, smoothing); // deliantra-style smoothing 187 bool ACC (RW, smoothing); // deliantra-style smoothing
194
195 bool ACC (RW, force_newmap); // force a newmap before next map update 188 bool ACC (RW, force_newmap); // force a newmap before next map update
196 uint32 ACC (RW, supported_readables); /* each bit is a readable supported by client */
197 uint32 ACC (RW, cs_version), ACC (RW, sc_version); /* versions of the client */
198 uint16 ACC (RW, look_position); /* start of drawing of look window */ 189 uint16 ACC (RW, look_position); /* start of drawing of look window */
199 uint16 ACC (RW, mss); // likely tcp maximum segment size 190 uint16 ACC (RW, mss); // likely tcp maximum segment size
200 uint8 ACC (RW, mapmode); /* Type of map commands the client wants. */
201 uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */ 191 uint8 ACC (RW, mapx), ACC (RW, mapy); /* How large a map the client wants */
202 uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */ 192 uint8 ACC (RW, itemcmd); /* What version of the 'item' protocol command to use */
193 uint8 ACC (RW, faceset); // CF+ selected faceset
203 194
204 maptile_ptr ACC (RW, current_map); // CF+ last/current player map 195 maptile_ptr ACC (RW, current_map); // CF+ last/current player map
205 region_ptr ACC (RW, current_region); // CF+ last/current player region 196 region_ptr ACC (RW, current_region); // CF+ last/current player region
206 int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position 197 int ACC (RW, current_x), ACC (RW, current_y); // CF+ last/current map position
207 shstr ACC (RW, version); // CF+ client name/version
208 uint8 ACC (RW, faceset); // CF+ selected faceset
209 198
210 tstamp ACC (RW, last_send); // last data send on socket. 199 tstamp ACC (RW, last_send); // last data send on socket.
211 200
212 float ACC (RW, socket_timeout); /* after how many seconds of no ack do we declare dead */ 201 float ACC (RW, socket_timeout); /* after how many seconds of no ack do we declare dead */
213 int ACC (RW, rate_avail); // current rate balance 202 int ACC (RW, rate_avail); // current rate balance
257 int len; 246 int len;
258 int count; 247 int count;
259 char msg[MSG_BUF_SIZE]; 248 char msg[MSG_BUF_SIZE];
260 } msgbuf[MSG_BUF_COUNT]; 249 } msgbuf[MSG_BUF_COUNT];
261 250
262 MTH bool msg_suppressed (const char *msg); 251 MTH bool msg_suppressed (const_utf8_string msg);
263 252
264 /* The following is the setup for a ring buffer for storing output 253 /* The following is the setup for a ring buffer for storing output
265 * data that the OS can't handle right away. 254 * data that the OS can't handle right away.
266 * TODO: this member is enourmously large - optimise? 255 * TODO: this member is enourmously large - optimise?
267 */ 256 */
289 MTH void flush (); 278 MTH void flush ();
290 MTH void write_outputbuffer (); 279 MTH void write_outputbuffer ();
291 MTH int outputbuffer_len () const { return outputbuffer.len; } 280 MTH int outputbuffer_len () const { return outputbuffer.len; }
292 void send (void *buf_, int len); 281 void send (void *buf_, int len);
293 282
294 void send_packet (const char *buf); 283 void send_packet (const_octet_string buf);
295 void send_packet (const char *buf, int len); 284 void send_packet (const_octet_string buf, int len);
296 void send_packet_printf (const char *format, ...) attribute ((format (printf, 2, 3))); 285 void send_packet_printf (const_utf8_string format, ...) attribute ((format (printf, 2, 3)));
297 void send_packet (packet &sl); 286 void send_packet (packet &sl);
298 287
299 void send_drawinfo (const char *msg, int flags = NDI_BLACK); 288 void send_drawinfo (const_utf8_string msg, int flags = NDI_BLACK);
300 289
301 MTH void send_face (faceidx facenum, int pri = 0); 290 MTH void send_face (faceidx facenum, int pri = 0);
302 MTH void send_faces (object *ob); 291 MTH void send_faces (object *ob);
303 MTH void send_animation (short anim_num); 292 MTH void send_animation (short anim_num);
304 void send_msg (int color, const char *type, const char *msg); 293 void send_msg (int color, const_utf8_string type, const_utf8_string msg);
305 294
306 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0); 295 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0);
307 // called when something under the player changes 296 // called when something under the player changes
308 MTH void floorbox_update () { update_look = 1; } 297 MTH void floorbox_update () { update_look = 1; }
309 // called when the player has been moved 298 // called when the player has been moved
360 ((__sockPtr)->supported_readables & (1<<(__type))) ) 349 ((__sockPtr)->supported_readables & (1<<(__type))) )
361 350
362#define FACE_TYPES 1 351#define FACE_TYPES 1
363#define PNG_FACE_INDEX 0 352#define PNG_FACE_INDEX 0
364 353
365#define VERSION_CS 1023 /* version >= 1023 understand setup cmd */
366#define VERSION_SC 1026
367//#define VERSION_SC 1027 // requestinfo image_info and image_sums, makes extending faces on the fly impossible
368#define VERSION_INFO "Deliantra Server"
369
370//-GPL 354//-GPL
371 355
372typedef object_vector<client, &client::active> sockvec; 356typedef object_vector<client, &client::active> sockvec;
373 357
374extern sockvec clients; 358extern sockvec clients;
377 for (int _i = 0; _i < clients.size (); ++_i) \ 361 for (int _i = 0; _i < clients.size (); ++_i) \
378 statementvar (client *, var, clients [_i]) 362 statementvar (client *, var, clients [_i])
379 363
380// returns true when the message needs special (read: perl) treatment 364// returns true when the message needs special (read: perl) treatment
381static inline bool 365static inline bool
382msg_is_special (const char *msg, bool nl_special = true) 366msg_is_special (const_any_string msg, bool nl_special = true)
383{ 367{
384 return msg [strcspn (msg, nl_special ? "<&\n" : "<&")]; 368 return msg [strcspn (msg, nl_special ? "<&\n" : "<&")];
385} 369}
386 370
387#endif 371#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines