… | |
… | |
216 | { |
216 | { |
217 | data += 6; |
217 | data += 6; |
218 | len -= 6; |
218 | len -= 6; |
219 | } |
219 | } |
220 | |
220 | |
221 | if (len > 4 && !strncmp (data, "say " , 4)) |
221 | if (len > 4 && data [3] == ' ' && !strncmp (data, "say " , 4)) return true; |
222 | return true; |
222 | if (len > 5 && data [4] == ' ' && !strncmp (data, "chat " , 5)) return true; |
223 | if (len > 5 && !strncmp (data, "chat ", 5)) |
223 | if (len > 6 && data [5] == ' ' && !strncmp (data, "shout ", 6)) return true; |
224 | return true; |
224 | |
|
|
225 | if (len == 7 && !strcmp (data, "suicide")) return true; |
225 | |
226 | |
226 | return false; |
227 | return false; |
227 | } |
228 | } |
228 | |
229 | |
229 | void |
230 | void |
… | |
… | |
351 | } |
352 | } |
352 | else |
353 | else |
353 | { |
354 | { |
354 | inbuf_len += amount; |
355 | inbuf_len += amount; |
355 | |
356 | |
356 | cmd_ev.start (); |
|
|
357 | } |
|
|
358 | } |
|
|
359 | } |
|
|
360 | |
|
|
361 | // called whenever we have additional commands to process |
|
|
362 | void |
|
|
363 | client::cmd_cb (iw &w) |
|
|
364 | { |
|
|
365 | if (handle_packet ()) |
357 | if (handle_packet ()) |
366 | w.start (); |
358 | { |
367 | else |
359 | while (handle_packet ()) |
368 | flush (); |
360 | ; |
|
|
361 | |
|
|
362 | flush (); |
|
|
363 | } |
|
|
364 | } |
|
|
365 | } |
369 | } |
366 | } |
370 | |
367 | |
371 | /******************************************************************************* |
368 | /******************************************************************************* |
372 | * |
369 | * |
373 | * Start of write related routines. |
370 | * Start of write related routines. |
… | |
… | |
493 | { |
490 | { |
494 | LOG (logBacktrace | llevError, "send_msg(%d,%p,%p) called with NULL msg or type.\n", color, type, msg); |
491 | LOG (logBacktrace | llevError, "send_msg(%d,%p,%p) called with NULL msg or type.\n", color, type, msg); |
495 | return; |
492 | return; |
496 | } |
493 | } |
497 | |
494 | |
|
|
495 | int len = strlen (msg); |
|
|
496 | |
498 | if (msg_is_special (msg) || (type [0] == 'c' && type [1] == '/')) |
497 | if (msg_is_special (msg) || (type [0] == 'c' && type [1] == '/') || len > (MAXSOCKBUF - 128)) |
499 | cfperl_send_msg (this, color, type, msg); |
498 | cfperl_send_msg (this, color, type, msg); |
500 | else if (can_msg) |
499 | else if (can_msg) |
501 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
500 | send_packet_printf ("msg %d %s %s", color & NDI_CLIENT_MASK, type, msg); |
502 | else if (color < 0) |
501 | else if (color < 0) |
503 | return; // client cannot handle this |
502 | return; // client cannot handle this |