ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/lowlevel.C
(Generate patch)

Comparing deliantra/server/socket/lowlevel.C (file contents):
Revision 1.46 by root, Sun Jun 10 04:44:21 2007 UTC vs.
Revision 1.48 by root, Sun Jun 24 04:09:29 2007 UTC

47 if (destroyed ()) 47 if (destroyed ())
48 return; 48 return;
49 49
50#if HAVE_TCP_INFO 50#if HAVE_TCP_INFO
51 // check about once per second, spread evenly over all clients 51 // check about once per second, spread evenly over all clients
52 if (!((pticks + fd) & 7)) 52 // do this only when player is active
53 if (!((pticks + fd) & 7) && pl && pl->active)
53 { 54 {
54 // check time of last ack, and, if too old, kill connection 55 // check time of last ack, and, if too old, kill connection
55 struct tcp_info tcpi; 56 struct tcp_info tcpi;
56 socklen_t len = sizeof (tcpi); 57 socklen_t len = sizeof (tcpi);
57 58
84 */ 85 */
85 86
86 // write a nop to the socket at least every IDLE_NOP seconds. 87 // write a nop to the socket at least every IDLE_NOP seconds.
87 if (!outputbuffer.len) 88 if (!outputbuffer.len)
88 { 89 {
89 if (last_send + IDLE_PING <= NOW) 90 if (last_send + IDLE_PING <= NOW && pl && pl->active)
90 { 91 {
91 // this is a bit ugly, but map1/map1a seem to be the only 92 // this is a bit ugly, but map1/map1a seem to be the only
92 // nop'able commands and they are quite small. 93 // nop'able commands and they are quite small.
93 packet sl (mapmode == Map1Cmd ? "map1" : "map1a"); 94 packet sl (mapmode == Map1Cmd ? "map1" : "map1a");
94 send_packet (sl); 95 send_packet (sl);
510 va_end (ap); 511 va_end (ap);
511 512
512 send_packet (sl); 513 send_packet (sl);
513} 514}
514 515
515void 516// returns true when the message needs special (read: perl) treatment
516client::send_drawinfo (const char *msg, int flags) 517static bool
517{ 518msg_is_special (const char *msg)
518 send_packet_printf ("drawinfo %d %s", flags, msg); 519{
520 return msg [strcspn (msg, "<[&\n")];
519} 521}
520 522
521void 523void
522client::send_msg (int color, const char *type, const char *msg) 524client::send_msg (int color, const char *type, const char *msg)
523{ 525{
526 if (msg_is_special (msg))
527 cfperl_send_msg (this, color, type, msg);
524 if (can_msg) 528 else if (can_msg)
525 send_packet_printf ("msg %d %s %s", color, type, msg); 529 send_packet_printf ("msg %d %s %s", color, type, msg);
526 else if (color < 0) 530 else if (color < 0)
527 return; // client cannot handle this 531 return; // client cannot handle this
528 else if (strchr (msg, '<') || strchr (msg, '&'))
529 {
530 //TODO: should escape/modify to old syntax
531 send_packet_printf ("drawinfo %d %s", color, msg);
532 }
533 else 532 else
534 send_packet_printf ("drawinfo %d %s", color, msg); 533 send_packet_printf ("drawinfo %d %s", color, msg);
534}
535
536void
537client::send_drawinfo (const char *msg, int flags)
538{
539 send_msg (flags, "log", msg);
535} 540}
536 541
537/*********************************************************************** 542/***********************************************************************
538 * 543 *
539 * packet functions/utilities 544 * packet functions/utilities

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines