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.66 by root, Mon Jul 30 02:03:02 2007 UTC vs.
Revision 1.67 by root, Fri Aug 24 00:26:10 2007 UTC

242 faceidx ACC (RW, scrub_idx); // which face to send next 242 faceidx ACC (RW, scrub_idx); // which face to send next
243 int ACC (RW, bg_scrub); // how many ticks till the next background face send 243 int ACC (RW, bg_scrub); // how many ticks till the next background face send
244 244
245 struct tcp_info tcpi; 245 struct tcp_info tcpi;
246 tstamp next_rate_adjust; 246 tstamp next_rate_adjust;
247
248 unordered_vector<char *> mapinfo_queue;
249 void mapinfo_queue_clear ();
250 void mapinfo_queue_run ();
251 bool mapinfo_try (char *buf);
252
253 struct ixsend {
254 int16_t pri; // unused
255 faceidx idx;
256 uint32_t ofs; // if != 0, need to send remaining bytes of partial_face
257 };
258 std::vector<ixsend, slice_allocator<ixsend> > ixface; // which faces to send to the client using ix
259
260 std::vector<faceidx, slice_allocator<faceidx> > fxface; // which faces to send using fx
261 MTH void flush_fx (); // send fx if required
262
263 void do_destroy ();
264 void gather_callbacks (AV *&callbacks, event_type event) const;
265
266 iow socket_ev; void socket_cb (iow &w, int got);
267 iw cmd_ev; void cmd_cb (iw &w);
268
269 std::deque< command, slice_allocator<command> > cmd_queue;
270
271 // large structures at the end please
272 struct Map lastmap;
273 std::bitset<MAXANIMNUM> anims_sent;
274 std::bitset<MAX_FACES> faces_sent;
275 std::bitset<FT_NUM> fx_want;
276
277 // if we get an incomplete packet, this is used to hold the data.
278 // we add 2 byte for the header, one for the trailing 0 byte
279 uint8 inbuf[MAXSOCKBUF + 2 + 1];
280
281 enum { MSG_BUF_SIZE = 80, MSG_BUF_COUNT = 10 };
282 struct msg_buf
283 {
284 tick_t expire;
285 int len;
286 int count;
287 char msg[MSG_BUF_SIZE];
288 } msgbuf[MSG_BUF_COUNT];
289
290 MTH bool msg_suppressed (const char *msg);
291
292 bool may_execute (const packet_type *pkt) const;
293 void execute (const packet_type *pkt, char *data, int datalen);
294
295 void queue_command (packet_type *handler, char *data, int datalen);
296 MTH bool handle_command ();
297 // resets movement state
298 MTH void reset_state ();
299 // resets variable data used to send stat diffs
300 MTH void reset_stats ();
301
302 MTH bool handle_packet ();
303 int next_packet (); // returns length of packet or 0
304 void skip_packet (int len); // we have processed the packet, skip it
305
306 MTH void flush ();
307 MTH void write_outputbuffer ();
308 MTH int outputbuffer_len () const { return outputbuffer.len; }
309 void send (void *buf_, int len);
310
311 void send_packet (const char *buf);
312 void send_packet (const char *buf, int len);
313 void send_packet_printf (const char *format, ...);
314 void send_packet (packet &sl);
315
316 void send_drawinfo (const char *msg, int flags = NDI_BLACK);
317
318 MTH void send_face (faceidx facenum, int pri = 0);
319 MTH void send_image (faceidx facenum);
320 MTH void send_faces (object *ob);
321 MTH void send_animation (short anim_num);
322 void send_msg (int color, const char *type, const char *msg);
323
324 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0);
325 // called when something under the player changes
326 MTH void floorbox_update () { update_look = 1; }
327 // called when the player has been moved
328 MTH void floorbox_reset () { look_position = 0; floorbox_update (); }
329
330 MTH void tick (); // called every server tick to do housekeeping etc.
331
332 MTH static client *create (int fd, const char *peername);
333 MTH static void clock ();
334 MTH static void flush_sockets ();
335
336protected:
337 client (int fd, const char *from_ip);
338 ~client ();
339};
340
247#if FOR_PERL 341#if FOR_PERL
248 // unfortunately, this emans that we *require* tcp_info now...
249 ACC (RW, tcpi.tcpi_state); 342 ACC (RW, tcpi.tcpi_state);
250 ACC (RW, tcpi.tcpi_ca_state); 343 ACC (RW, tcpi.tcpi_ca_state);
251 ACC (RW, tcpi.tcpi_retransmits); 344 ACC (RW, tcpi.tcpi_retransmits);
252 ACC (RW, tcpi.tcpi_probes); 345 ACC (RW, tcpi.tcpi_probes);
253 ACC (RW, tcpi.tcpi_backoff); 346 ACC (RW, tcpi.tcpi_backoff);
275 ACC (RW, tcpi.tcpi_snd_cwnd); 368 ACC (RW, tcpi.tcpi_snd_cwnd);
276 ACC (RW, tcpi.tcpi_advmss); 369 ACC (RW, tcpi.tcpi_advmss);
277 ACC (RW, tcpi.tcpi_reordering); 370 ACC (RW, tcpi.tcpi_reordering);
278#endif 371#endif
279 372
280 struct ixsend {
281 int16_t pri; // unused
282 faceidx idx;
283 uint32_t ofs; // if != 0, need to send remaining bytes of partial_face
284 };
285 std::vector<ixsend, slice_allocator<ixsend> > ixface; // which faces to send to the client using ix
286
287 std::vector<faceidx, slice_allocator<faceidx> > fxface; // which faces to send using fx
288 MTH void flush_fx (); // send fx if required
289
290 void do_destroy ();
291 void gather_callbacks (AV *&callbacks, event_type event) const;
292
293 iow socket_ev; void socket_cb (iow &w, int got);
294 iw cmd_ev; void cmd_cb (iw &w);
295
296 std::deque< command, slice_allocator<command> > cmd_queue;
297
298 // large structures at the end please
299 struct Map lastmap;
300 std::bitset<MAXANIMNUM> anims_sent;
301 std::bitset<MAX_FACES> faces_sent;
302 std::bitset<FT_NUM> fx_want;
303
304 // if we get an incomplete packet, this is used to hold the data.
305 // we add 2 byte for the header, one for the trailing 0 byte
306 uint8 inbuf[MAXSOCKBUF + 2 + 1];
307
308 enum { MSG_BUF_SIZE = 80, MSG_BUF_COUNT = 10 };
309 struct msg_buf
310 {
311 tick_t expire;
312 int len;
313 int count;
314 char msg[MSG_BUF_SIZE];
315 } msgbuf[MSG_BUF_COUNT];
316
317 MTH bool msg_suppressed (const char *msg);
318
319 bool may_execute (const packet_type *pkt) const;
320 void execute (const packet_type *pkt, char *data, int datalen);
321
322 void queue_command (packet_type *handler, char *data, int datalen);
323 MTH bool handle_command ();
324 // resets movement state
325 MTH void reset_state ();
326 // resets variable data used to send stat diffs
327 MTH void reset_stats ();
328
329 MTH bool handle_packet ();
330 int next_packet (); // returns length of packet or 0
331 void skip_packet (int len); // we have processed the packet, skip it
332
333 MTH void flush ();
334 MTH void write_outputbuffer ();
335 MTH int outputbuffer_len () const { return outputbuffer.len; }
336 void send (void *buf_, int len);
337
338 void send_packet (const char *buf);
339 void send_packet (const char *buf, int len);
340 void send_packet_printf (const char *format, ...);
341 void send_packet (packet &sl);
342
343 void send_drawinfo (const char *msg, int flags = NDI_BLACK);
344
345 MTH void send_face (faceidx facenum, int pri = 0);
346 MTH void send_image (faceidx facenum);
347 MTH void send_faces (object *ob);
348 MTH void send_animation (short anim_num);
349 void send_msg (int color, const char *type, const char *msg);
350
351 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0);
352 // called when something under the player changes
353 MTH void floorbox_update () { update_look = 1; }
354 // called when the player has been moved
355 MTH void floorbox_reset () { look_position = 0; floorbox_update (); }
356
357 MTH void tick (); // called every server tick to do housekeeping etc.
358
359 MTH static client *create (int fd, const char *peername);
360 MTH static void clock ();
361 MTH static void flush_sockets ();
362
363protected:
364 client (int fd, const char *from_ip);
365 ~client ();
366};
367
368#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\ 373#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\
369 ( ((__type)>0) &&\ 374 ( ((__type)>0) &&\
370 ((__sockPtr)->has_readable_type) && \ 375 ((__sockPtr)->has_readable_type) && \
371 ((__sockPtr)->supported_readables & (1<<(__type))) ) 376 ((__sockPtr)->supported_readables & (1<<(__type))) )
372 377

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines