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.65 by root, Sat Jul 28 00:15:03 2007 UTC vs.
Revision 1.68 by root, Mon Oct 1 01:09: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
268 std::deque< command, slice_allocator<command> > cmd_queue;
269
270 // large structures at the end please
271 struct Map lastmap;
272 std::bitset<MAXANIMNUM> anims_sent;
273 std::bitset<MAX_FACES> faces_sent;
274 std::bitset<FT_NUM> fx_want;
275
276 // if we get an incomplete packet, this is used to hold the data.
277 // we add 2 byte for the header, one for the trailing 0 byte
278 uint8 inbuf[MAXSOCKBUF + 2 + 1];
279
280 enum { MSG_BUF_SIZE = 80, MSG_BUF_COUNT = 10 };
281 struct msg_buf
282 {
283 tick_t expire;
284 int len;
285 int count;
286 char msg[MSG_BUF_SIZE];
287 } msgbuf[MSG_BUF_COUNT];
288
289 MTH bool msg_suppressed (const char *msg);
290
291 bool may_execute (const packet_type *pkt) const;
292 void execute (const packet_type *pkt, char *data, int datalen);
293
294 void queue_command (packet_type *handler, char *data, int datalen);
295 MTH bool handle_command ();
296 // resets movement state
297 MTH void reset_state ();
298 // resets variable data used to send stat diffs
299 MTH void reset_stats ();
300
301 MTH bool handle_packet ();
302 int next_packet (); // returns length of packet or 0
303 void skip_packet (int len); // we have processed the packet, skip it
304
305 MTH void flush ();
306 MTH void write_outputbuffer ();
307 MTH int outputbuffer_len () const { return outputbuffer.len; }
308 void send (void *buf_, int len);
309
310 void send_packet (const char *buf);
311 void send_packet (const char *buf, int len);
312 void send_packet_printf (const char *format, ...);
313 void send_packet (packet &sl);
314
315 void send_drawinfo (const char *msg, int flags = NDI_BLACK);
316
317 MTH void send_face (faceidx facenum, int pri = 0);
318 MTH void send_image (faceidx facenum);
319 MTH void send_faces (object *ob);
320 MTH void send_animation (short anim_num);
321 void send_msg (int color, const char *type, const char *msg);
322
323 MTH void play_sound (faceidx sound, int dx = 0, int dy = 0);
324 // called when something under the player changes
325 MTH void floorbox_update () { update_look = 1; }
326 // called when the player has been moved
327 MTH void floorbox_reset () { look_position = 0; floorbox_update (); }
328
329 MTH void tick (); // called every server tick to do housekeeping etc.
330
331 MTH static client *create (int fd, const char *peername);
332 MTH static void clock ();
333 MTH static void flush_sockets ();
334
335protected:
336 client (int fd, const char *from_ip);
337 ~client ();
338};
339
247#if FOR_PERL 340#if FOR_PERL
248 // unfortunately, this emans that we *require* tcp_info now...
249 ACC (RW, tcpi.tcpi_state); 341 ACC (RW, tcpi.tcpi_state);
250 ACC (RW, tcpi.tcpi_ca_state); 342 ACC (RW, tcpi.tcpi_ca_state);
251 ACC (RW, tcpi.tcpi_retransmits); 343 ACC (RW, tcpi.tcpi_retransmits);
252 ACC (RW, tcpi.tcpi_probes); 344 ACC (RW, tcpi.tcpi_probes);
253 ACC (RW, tcpi.tcpi_backoff); 345 ACC (RW, tcpi.tcpi_backoff);
275 ACC (RW, tcpi.tcpi_snd_cwnd); 367 ACC (RW, tcpi.tcpi_snd_cwnd);
276 ACC (RW, tcpi.tcpi_advmss); 368 ACC (RW, tcpi.tcpi_advmss);
277 ACC (RW, tcpi.tcpi_reordering); 369 ACC (RW, tcpi.tcpi_reordering);
278#endif 370#endif
279 371
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
361protected:
362 client (int fd, const char *from_ip);
363 ~client ();
364};
365
366#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\ 372#define CLIENT_SUPPORT_READABLES(__sockPtr,__type)\
367 ( ((__type)>0) &&\ 373 ( ((__type)>0) &&\
368 ((__sockPtr)->has_readable_type) && \ 374 ((__sockPtr)->has_readable_type) && \
369 ((__sockPtr)->supported_readables & (1<<(__type))) ) 375 ((__sockPtr)->supported_readables & (1<<(__type))) )
370 376

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines