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 |
… | |
… | |
184 | {"requestinfo", SC(RequestInfo) 0 }, |
184 | {"requestinfo", SC(RequestInfo) 0 }, |
185 | {"setfacemode", SC(SetFaceMode) 0 }, |
185 | {"setfacemode", SC(SetFaceMode) 0 }, |
186 | {"setsound", SC(SetSound) 0 }, |
186 | {"setsound", SC(SetSound) 0 }, |
187 | {"setup", SC(SetUp) 0 }, |
187 | {"setup", SC(SetUp) 0 }, |
188 | {"version", SC(VersionCmd) 0 }, |
188 | {"version", SC(VersionCmd) 0 }, |
189 | {"toggleextendedinfos", SC(ToggleExtendedInfos) 0 }, /*Added: tchize */ |
|
|
190 | {"toggleextendedtext", SC(ToggleExtendedText) 0 }, /*Added: tchize */ |
189 | {"toggleextendedtext", SC(ToggleExtendedText) 0 }, /*Added: tchize */ |
191 | {"asksmooth", SC(AskSmooth) 0 }, /*Added: tchize (smoothing technologies) */ |
190 | {"asksmooth", SC(AskSmooth) 0 }, /*Added: tchize (smoothing technologies) */ |
192 | }; |
191 | }; |
193 | |
192 | |
194 | bool |
193 | bool |
… | |
… | |
474 | va_end (ap); |
473 | va_end (ap); |
475 | |
474 | |
476 | send_packet (sl); |
475 | send_packet (sl); |
477 | } |
476 | } |
478 | |
477 | |
479 | // returns true when the message needs special (read: perl) treatment |
|
|
480 | static bool |
|
|
481 | msg_is_special (const char *msg) |
|
|
482 | { |
|
|
483 | return msg [strcspn (msg, "<[&\n")]; |
|
|
484 | } |
|
|
485 | |
|
|
486 | void |
478 | void |
487 | client::send_msg (int color, const char *type, const char *msg) |
479 | client::send_msg (int color, const char *type, const char *msg) |
488 | { |
480 | { |
489 | if (!msg || !type) // it can happen (for example, missing attack messages cause this) |
481 | if (!msg || !type) // it can happen (for example, missing attack messages cause this) |
490 | { |
482 | { |
… | |
… | |
492 | return; |
484 | return; |
493 | } |
485 | } |
494 | |
486 | |
495 | int len = strlen (msg); |
487 | int len = strlen (msg); |
496 | |
488 | |
|
|
489 | if (!(color & NDI_VERBATIM) |
|
|
490 | && (msg_is_special (msg) |
497 | if (msg_is_special (msg) || (type [0] == 'c' && type [1] == '/') || len > (MAXSOCKBUF - 128)) |
491 | || (type [0] == 'c' && type [1] == '/') || len > (MAXSOCKBUF - 128))) |
498 | cfperl_send_msg (this, color, type, msg); |
492 | cfperl_send_msg (this, color, type, msg); |
499 | else if (can_msg) |
493 | else if (can_msg) |
500 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
494 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
501 | else if (color < 0) |
495 | else if (color < 0) |
502 | return; // client cannot handle this |
496 | return; // client cannot handle this |