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.63 by root, Wed Nov 14 08:09:46 2007 UTC vs.
Revision 1.66 by root, Fri Sep 19 01:39:45 2008 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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 1992,2007 Frank Tore Johansen 5 * Copyright (©) 1992,2007 Frank Tore Johansen
6 * 6 *
7 * Deliantra is free software: you can redistribute it and/or modify 7 * Deliantra is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by 8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or 9 * the Free Software Foundation, either version 3 of the License, or
474 va_end (ap); 474 va_end (ap);
475 475
476 send_packet (sl); 476 send_packet (sl);
477} 477}
478 478
479// returns true when the message needs special (read: perl) treatment
480static bool
481msg_is_special (const char *msg)
482{
483 return msg [strcspn (msg, "<[&\n")];
484}
485
486void 479void
487client::send_msg (int color, const char *type, const char *msg) 480client::send_msg (int color, const char *type, const char *msg)
488{ 481{
489 if (!msg || !type) // it can happen (for example, missing attack messages cause this) 482 if (!msg || !type) // it can happen (for example, missing attack messages cause this)
490 { 483 {
492 return; 485 return;
493 } 486 }
494 487
495 int len = strlen (msg); 488 int len = strlen (msg);
496 489
490 if (!(color & NDI_VERBATIM)
491 && (msg_is_special (msg)
497 if (msg_is_special (msg) || (type [0] == 'c' && type [1] == '/') || len > (MAXSOCKBUF - 128)) 492 || (type [0] == 'c' && type [1] == '/') || len > (MAXSOCKBUF - 128)))
498 cfperl_send_msg (this, color, type, msg); 493 cfperl_send_msg (this, color, type, msg);
499 else if (can_msg) 494 else if (can_msg)
500 send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); 495 send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg);
501 else if (color < 0) 496 else if (color < 0)
502 return; // client cannot handle this 497 return; // client cannot handle this

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines