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

Comparing deliantra/server/socket/info.C (file contents):
Revision 1.8 by root, Tue Sep 19 09:38:32 2006 UTC vs.
Revision 1.12 by pippijn, Sat Dec 9 17:28:37 2006 UTC

96 96
97static void 97static void
98print_message (int colr, const object *pl, const char *tmp) 98print_message (int colr, const object *pl, const char *tmp)
99{ 99{
100 100
101 if (tmp == (char *) NULL) 101 if (!tmp)
102 {
103 tmp = "[NULL]"; 102 tmp = "[NULL]";
104 }
105 103
106 if (!pl || (pl->type == PLAYER && pl->contr == NULL)) 104 if (!pl || (pl->type == PLAYER && pl->contr == NULL))
107 return; 105 return;
108 106
109 if (pl->type == PLAYER) 107 if (pl->type == PLAYER)
110 { 108 {
111 esrv_print_msg (&pl->contr->socket, colr, (char *) tmp); 109 esrv_print_msg (&pl->contr->socket, colr, (char *) tmp);
112 return; 110 return;
113 } 111 }
114} 112}
115
116 113
117/** 114/**
118 * Prints out the contents of specified buffer structures, 115 * Prints out the contents of specified buffer structures,
119 * and clears the string. 116 * and clears the string.
120 */ 117 */
217{ 214{
218 215
219 if (flags & NDI_ALL) 216 if (flags & NDI_ALL)
220 { 217 {
221 player *tmppl; 218 player *tmppl;
222 int i;
223 219
224 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) 220 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next)
225 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); 221 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf);
226 222
227 for (i = 1; i < socket_info.allocated_sockets; i++)
228 {
229 if (init_sockets[i].status == Ns_Old && init_sockets[i].old_mode != Old_Listen && pri < 10)
230 {
231 cs_write_string (&init_sockets[i], buf, strlen (buf));
232 /* Most messages don't have a newline, so add one */
233 cs_write_string (&init_sockets[i], "\n", 1);
234 }
235 }
236
237 return; 223 return;
238 } 224 }
225
239 if (!pl || (pl->type == PLAYER && pl->contr == NULL)) 226 if (!pl || (pl->type == PLAYER && pl->contr == NULL))
240 { 227 {
241 /* Write to the socket? */ 228 /* Write to the socket? */
242 print_message (0, NULL, buf); 229 print_message (0, NULL, buf);
243 return; 230 return;
244 } 231 }
232
245 if (pl->type != PLAYER) 233 if (pl->type != PLAYER)
246 return; 234 return;
235
247 if (pri >= pl->contr->listening) 236 if (pri >= pl->contr->listening)
248 return; 237 return;
249 238
250 if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) 239 if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE))
251 {
252 /* following prints stuff out, as appropriate */ 240 /* following prints stuff out, as appropriate */
253 check_output_buffers (pl, buf); 241 check_output_buffers (pl, buf);
254 }
255 else 242 else
256 {
257 print_message (flags & NDI_COLOR_MASK, pl, buf); 243 print_message (flags & NDI_COLOR_MASK, pl, buf);
258 }
259} 244}
260 245
261/** 246/**
262 * Wrapper for new_draw_info printf-like. 247 * Wrapper for new_draw_info printf-like.
263 * 248 *
423 object *op; 408 object *op;
424 409
425 for (op = pl->inv; op; op = op->below) 410 for (op = pl->inv; op; op = op->below)
426 if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) 411 if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED))
427 break; 412 break;
413
428 if (op == NULL) 414 if (op == NULL)
429 break; 415 break;
430 416
431 sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing"); 417 sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing");
432 } 418 }
436 if (settings.casting_time == TRUE) 422 if (settings.casting_time == TRUE)
437 { 423 {
438 if (pl->casting_time > -1) 424 if (pl->casting_time > -1)
439 { 425 {
440 if (pl->casting_time == 0) 426 if (pl->casting_time == 0)
441 sprintf (obuf, "Range: Holding spell (%s)", (const char *) pl->spell->name); 427 sprintf (obuf, "Range: Holding spell (%s)", &pl->spell->name);
442 else 428 else
443 sprintf (obuf, "Range: Casting spell (%s)", (const char *) pl->spell->name); 429 sprintf (obuf, "Range: Casting spell (%s)", &pl->spell->name);
444 } 430 }
445 else 431 else
446 sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); 432 sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name);
447 } 433 }
448 else 434 else
682 */ 668 */
683 669
684void 670void
685Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType) 671Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType)
686{ 672{
687 int i;
688 size_t len; 673 size_t len;
689 char buf[MAX_BUF]; 674 char buf[MAX_BUF];
690 675
691 if (With != NULL) 676 if (With != NULL)
692 {
693 snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); 677 snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType);
694 }
695 else 678 else
696 {
697 snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType); 679 snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType);
698 } 680
699 len = strlen (buf); 681 len = strlen (buf);
700 for (i = 1; i < socket_info.allocated_sockets; i++)
701 {
702 if (init_sockets[i].old_mode == Old_Listen)
703 {
704 cs_write_string (&init_sockets[i], buf, len);
705 }
706 }
707} 682}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines