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.19 by root, Sat Dec 23 09:41:55 2006 UTC vs.
Revision 1.23 by pippijn, Sat Jan 6 14:42:30 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for the X Window System 2 CrossFire, A Multiplayer game for the X Window System
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 9 it under the terms of the GNU General Public License as published by
162}; 163};
163 164
164/* how many times we are allowed to give the wrong password before being kicked. */ 165/* how many times we are allowed to give the wrong password before being kicked. */
165#define MAX_PASSWORD_FAILURES 5 166#define MAX_PASSWORD_FAILURES 5
166 167
167ACC_CLASS (client) // should become player when newsocket is a baseclass of player 168INTERFACE_CLASS (client) // should become player when newsocket is a baseclass of player
168struct client : zero_initialised, attachable<client> 169struct client : zero_initialised, attachable
169{ 170{
170 int ACC (RW, fd); 171 int ACC (RW, fd);
171 unsigned int inbuf_len; // number of bytes valid in inbuf 172 unsigned int inbuf_len; // number of bytes valid in inbuf
172 uint8 *faces_sent; // This is a bitmap on sent face status 173 uint8 *faces_sent; // This is a bitmap on sent face status
173 statsinfo stats; 174 statsinfo stats;
174 175
175 client_container cc_inv, cc_other; 176 client_container cc_inv, cc_other;
176 Buffer outputbuffer; 177 Buffer outputbuffer;
177 178
178 char *ACC (RW, host); /* Which host it is connected from (ip address) */ 179 char *ACC (RW, host); /* Which host it is connected from (ip address) */
179 uint8 ACC (RW, state); /* Input state of the player (name, password, etc */ 180 uint8 ACC (RW, state); /* Input state of the player (name, password, etc */
180 uint8 ACC (RW, password_fails); /* how many times the player has failed to give the right password */ 181 uint8 ACC (RW, password_fails); /* how many times the player has failed to give the right password */
181 182
183 bool ACC (RW, afk); /* player is afk */
182 bool ACC (RW, facecache); /* If true, client is caching images */ 184 bool ACC (RW, facecache); /* If true, client is caching images */
183 bool ACC (RW, sent_scroll); 185 bool ACC (RW, sent_scroll);
184 bool ACC (RW, sound); /* does the client want sound */ 186 bool ACC (RW, sound); /* does the client want sound */
185 bool ACC (RW, newmapcmd); /* Send newmap command when entering new map SMACFIGGEN */ 187 bool ACC (RW, newmapcmd); /* Send newmap command when entering new map SMACFIGGEN */
186 bool ACC (RW, plugincmd); /* CF+ extend the protocol through a plug-in */ 188 bool ACC (RW, plugincmd); /* CF+ extend the protocol through a plug-in */
213 215
214 player_ptr ACC (RO, pl); 216 player_ptr ACC (RO, pl);
215 217
216 int ACC (RW, rtt), ACC (RW, rttvar); /* round-trip time and -variance, if known */ 218 int ACC (RW, rtt), ACC (RW, rttvar); /* round-trip time and -variance, if known */
217 219
218 client (int fd, const char *from_ip);
219 ~client ();
220 void destroy (); 220 void do_destroy ();
221 bool destroyed () const { return state == ST_DEAD; } 221 void gather_callbacks (AV *&callbacks, event_type event) const;
222 222
223 iw cmd_ev; void cmd_cb (iw &w); 223 iw cmd_ev; void cmd_cb (iw &w);
224 iow socket_ev; void socket_cb (iow &w, int got); 224 iow socket_ev; void socket_cb (iow &w, int got);
225 225
226 std::deque< command, slice_allocator<command> > cmd_queue; 226 std::deque< command, slice_allocator<command> > cmd_queue;
234 234
235 bool may_execute (const packet_type *pkt) const; 235 bool may_execute (const packet_type *pkt) const;
236 void execute (const packet_type *pkt, char *data, int datalen); 236 void execute (const packet_type *pkt, char *data, int datalen);
237 237
238 void queue_command (packet_type *handler, char *data, int datalen); 238 void queue_command (packet_type *handler, char *data, int datalen);
239 bool handle_command (); 239 MTH bool handle_command ();
240 // resets movement state 240 // resets movement state
241 void reset_state (); 241 MTH void reset_state ();
242 242
243 bool handle_packet (); 243 MTH bool handle_packet ();
244 int next_packet (); // returns length of packet or 0 244 int next_packet (); // returns length of packet or 0
245 void skip_packet (int len); // we have processed the packet, skip it 245 void skip_packet (int len); // we have processed the packet, skip it
246 246
247 void flush (); 247 MTH void flush ();
248 void write_outputbuffer (); 248 MTH void write_outputbuffer ();
249 void send (void *buf_, int len); 249 void send (void *buf_, int len);
250 250
251 void send_packet (const char *buf); 251 void send_packet (const char *buf);
252 void send_packet (const char *buf, int len); 252 void send_packet (const char *buf, int len);
253 void send_packet_printf (const char *format, ...); 253 void send_packet_printf (const char *format, ...);
254 void send_packet (packet &sl); 254 void send_packet (packet &sl);
255 255
256 // called when something under the player changes 256 // called when something under the player changes
257 void floorbox_update () { update_look = 1; } 257 MTH void floorbox_update () { update_look = 1; }
258 // called when the player has been moved 258 // called when the player has been moved
259 void floorbox_reset () { look_position = 0; floorbox_update (); } 259 MTH void floorbox_reset () { look_position = 0; floorbox_update (); }
260 260
261 static client *create (int fd, const char *peername); 261 MTH static client *create (int fd, const char *peername);
262
263protected:
264 client (int fd, const char *from_ip);
265 ~client ();
262}; 266};
263 267
264#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\ 268#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\
265 ( ((__type)>0) &&\ 269 ( ((__type)>0) &&\
266 ((__sockPtr)->has_readable_type) && \ 270 ((__sockPtr)->has_readable_type) && \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines