… | |
… | |
96 | |
96 | |
97 | static void |
97 | static void |
98 | print_message (int colr, const object *pl, const char *tmp) |
98 | print_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 | } |
… | |
… | |
682 | */ |
668 | */ |
683 | |
669 | |
684 | void |
670 | void |
685 | Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType) |
671 | Log_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 | } |