1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_sock_info_c = |
|
|
4 | * "$Id: info.C,v 1.5 2006/09/10 13:43:33 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
1 | |
7 | /* |
2 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
3 | CrossFire, A Multiplayer game for X-windows |
9 | |
4 | |
10 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
… | |
… | |
22 | |
17 | |
23 | You should have received a copy of the GNU General Public License |
18 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
19 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
21 | |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
22 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
23 | */ |
29 | |
24 | |
30 | /** |
25 | /** |
31 | * \file |
26 | * \file |
32 | * Basic client output functions. |
27 | * Basic client output functions. |
… | |
… | |
48 | * much the same thing as the draw_info above, but takes a color |
43 | * much the same thing as the draw_info above, but takes a color |
49 | * parameter. the esrv_drawinfo functions should probably be |
44 | * parameter. the esrv_drawinfo functions should probably be |
50 | * replaced with this, just using black as the color. |
45 | * replaced with this, just using black as the color. |
51 | */ |
46 | */ |
52 | static void |
47 | static void |
53 | esrv_print_msg (NewSocket * ns, int color, const char *str) |
48 | esrv_print_msg (client_socket * ns, int color, const char *str) |
54 | { |
49 | { |
55 | char buf[HUGE_BUF]; |
50 | packet sl; |
56 | |
51 | |
57 | if (ns->status == Ns_Old) |
52 | if (ns->status == Ns_Old) |
58 | { |
53 | sl.printf ("%s\n", str); |
59 | snprintf (buf, HUGE_BUF, "%s\n", str); |
|
|
60 | } |
|
|
61 | else |
54 | else |
62 | { |
|
|
63 | snprintf (buf, HUGE_BUF, "drawinfo %d %s", color, str); |
55 | sl.printf ("drawinfo %d %s", color, str); |
64 | } |
|
|
65 | |
56 | |
66 | /* LOG(llevDebug,"sending %s to socket, len=%d\n", buf, strlen(buf));*/ |
57 | ns->send_packet (sl); |
67 | Write_String_To_Socket (ns, buf, strlen (buf)); |
|
|
68 | } |
58 | } |
69 | |
59 | |
70 | /** |
60 | /** |
71 | * Draws an extended message on the client. |
61 | * Draws an extended message on the client. |
72 | * ns the socket to send message to |
62 | * ns the socket to send message to |
… | |
… | |
75 | * subtype type and subtype of text message |
65 | * subtype type and subtype of text message |
76 | * intro Intro message to send with main message if client does not support the message type |
66 | * intro Intro message to send with main message if client does not support the message type |
77 | * message The main message |
67 | * message The main message |
78 | */ |
68 | */ |
79 | static void |
69 | static void |
80 | esrv_print_ext_msg (NewSocket * ns, int color, uint8 type, uint8 subtype, const char *message) |
70 | esrv_print_ext_msg (client_socket * ns, int color, uint8 type, uint8 subtype, const char *message) |
81 | { |
71 | { |
82 | char buf[HUGE_BUF]; |
72 | packet sl; |
83 | |
73 | |
84 | snprintf (buf, HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message); |
74 | sl.printf ("drawextinfo %d %hhu %hhu %s", color, type, subtype, message); |
85 | Write_String_To_Socket (ns, buf, strlen (buf)); |
75 | ns->send_packet (sl); |
86 | |
|
|
87 | /* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/ |
|
|
88 | |
|
|
89 | } |
76 | } |
90 | |
77 | |
91 | /** |
78 | /** |
92 | * Frontend for esrv_print_msg |
79 | * Frontend for esrv_print_msg |
93 | * \param colr message color |
80 | * \param colr message color |
… | |
… | |
101 | |
88 | |
102 | static void |
89 | static void |
103 | print_message (int colr, const object *pl, const char *tmp) |
90 | print_message (int colr, const object *pl, const char *tmp) |
104 | { |
91 | { |
105 | |
92 | |
106 | if (tmp == (char *) NULL) |
93 | if (!tmp) |
107 | { |
|
|
108 | tmp = "[NULL]"; |
94 | tmp = "[NULL]"; |
109 | } |
|
|
110 | |
95 | |
111 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
96 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
112 | return; |
97 | return; |
113 | |
98 | |
114 | if (pl->type == PLAYER) |
99 | if (pl->type == PLAYER) |
115 | { |
|
|
116 | esrv_print_msg (&pl->contr->socket, colr, (char *) tmp); |
100 | esrv_print_msg (pl->contr->socket, colr, (char *) tmp); |
117 | return; |
|
|
118 | } |
|
|
119 | } |
101 | } |
120 | |
|
|
121 | |
102 | |
122 | /** |
103 | /** |
123 | * Prints out the contents of specified buffer structures, |
104 | * Prints out the contents of specified buffer structures, |
124 | * and clears the string. |
105 | * and clears the string. |
125 | */ |
106 | */ |
… | |
… | |
222 | { |
203 | { |
223 | |
204 | |
224 | if (flags & NDI_ALL) |
205 | if (flags & NDI_ALL) |
225 | { |
206 | { |
226 | player *tmppl; |
207 | player *tmppl; |
227 | int i; |
|
|
228 | |
208 | |
229 | for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) |
209 | for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) |
230 | new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); |
210 | new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); |
231 | |
211 | |
232 | for (i = 1; i < socket_info.allocated_sockets; i++) |
|
|
233 | { |
|
|
234 | if (init_sockets[i].status == Ns_Old && init_sockets[i].old_mode != Old_Listen && pri < 10) |
|
|
235 | { |
|
|
236 | cs_write_string (&init_sockets[i], buf, strlen (buf)); |
|
|
237 | /* Most messages don't have a newline, so add one */ |
|
|
238 | cs_write_string (&init_sockets[i], "\n", 1); |
|
|
239 | } |
|
|
240 | } |
|
|
241 | |
|
|
242 | return; |
212 | return; |
243 | } |
213 | } |
|
|
214 | |
244 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
215 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
245 | { |
216 | { |
246 | /* Write to the socket? */ |
217 | /* Write to the socket? */ |
247 | print_message (0, NULL, buf); |
218 | print_message (0, NULL, buf); |
248 | return; |
219 | return; |
249 | } |
220 | } |
|
|
221 | |
250 | if (pl->type != PLAYER) |
222 | if (pl->type != PLAYER) |
251 | return; |
223 | return; |
|
|
224 | |
252 | if (pri >= pl->contr->listening) |
225 | if (pri >= pl->contr->listening) |
253 | return; |
226 | return; |
254 | |
227 | |
255 | if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) |
228 | if ((flags & NDI_COLOR_MASK) == NDI_BLACK && !(flags & NDI_UNIQUE)) |
256 | { |
|
|
257 | /* following prints stuff out, as appropriate */ |
229 | /* following prints stuff out, as appropriate */ |
258 | check_output_buffers (pl, buf); |
230 | check_output_buffers (pl, buf); |
259 | } |
|
|
260 | else |
231 | else |
261 | { |
|
|
262 | print_message (flags & NDI_COLOR_MASK, pl, buf); |
232 | print_message (flags & NDI_COLOR_MASK, pl, buf); |
263 | } |
|
|
264 | } |
233 | } |
265 | |
234 | |
266 | /** |
235 | /** |
267 | * Wrapper for new_draw_info printf-like. |
236 | * Wrapper for new_draw_info printf-like. |
268 | * |
237 | * |
… | |
… | |
296 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
265 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
297 | return; |
266 | return; |
298 | |
267 | |
299 | if (pri >= pl->contr->listening) |
268 | if (pri >= pl->contr->listening) |
300 | return; |
269 | return; |
|
|
270 | |
301 | if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) |
271 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
302 | { |
272 | { |
303 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
273 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
304 | |
274 | |
305 | if (buf == NULL) |
275 | if (buf == NULL) |
306 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
276 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
… | |
… | |
311 | new_draw_info (flags, pri, pl, buf); |
281 | new_draw_info (flags, pri, pl, buf); |
312 | free (buf); |
282 | free (buf); |
313 | } |
283 | } |
314 | } |
284 | } |
315 | else |
285 | else |
316 | { |
|
|
317 | esrv_print_ext_msg (&pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, message); |
286 | esrv_print_ext_msg (pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, message); |
318 | } |
|
|
319 | } |
287 | } |
320 | |
288 | |
321 | void |
289 | void |
322 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
290 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
323 | { |
291 | { |
… | |
… | |
327 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
295 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
328 | return; |
296 | return; |
329 | |
297 | |
330 | if (pri >= pl->contr->listening) |
298 | if (pri >= pl->contr->listening) |
331 | return; |
299 | return; |
|
|
300 | |
332 | if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) |
301 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
333 | { |
302 | { |
334 | va_list ap; |
303 | va_list ap; |
335 | |
304 | |
336 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
305 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
337 | va_start (ap, new_format); |
306 | va_start (ap, new_format); |
… | |
… | |
346 | |
315 | |
347 | va_start (ap, new_format); |
316 | va_start (ap, new_format); |
348 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
317 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
349 | va_end (ap); |
318 | va_end (ap); |
350 | strip_media_tag (buf); |
319 | strip_media_tag (buf); |
351 | esrv_print_ext_msg (&pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, buf); |
320 | esrv_print_ext_msg (pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, buf); |
352 | } |
321 | } |
353 | } |
322 | } |
354 | |
323 | |
355 | /** |
324 | /** |
356 | * Writes to everyone on the map *except* op. This is useful for emotions. |
325 | * Writes to everyone on the map *except* op. This is useful for emotions. |
357 | */ |
326 | */ |
358 | |
327 | |
359 | void |
328 | void |
360 | new_info_map_except (int color, mapstruct *map, object *op, const char *str) |
329 | new_info_map_except (int color, maptile * map, object *op, const char *str) |
361 | { |
330 | { |
362 | player *pl; |
331 | player *pl; |
363 | |
332 | |
364 | for (pl = first_player; pl != NULL; pl = pl->next) |
333 | for (pl = first_player; pl != NULL; pl = pl->next) |
365 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
334 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) |
… | |
… | |
371 | /** |
340 | /** |
372 | * Writes to everyone on the map except op1 and op2 |
341 | * Writes to everyone on the map except op1 and op2 |
373 | */ |
342 | */ |
374 | |
343 | |
375 | void |
344 | void |
376 | new_info_map_except2 (int color, mapstruct *map, object *op1, object *op2, const char *str) |
345 | new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str) |
377 | { |
346 | { |
378 | player *pl; |
347 | player *pl; |
379 | |
348 | |
380 | for (pl = first_player; pl != NULL; pl = pl->next) |
349 | for (pl = first_player; pl != NULL; pl = pl->next) |
381 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
350 | if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) |
… | |
… | |
387 | /** |
356 | /** |
388 | * Writes to everyone on the specified map |
357 | * Writes to everyone on the specified map |
389 | */ |
358 | */ |
390 | |
359 | |
391 | void |
360 | void |
392 | new_info_map (int color, mapstruct *map, const char *str) |
361 | new_info_map (int color, maptile * map, const char *str) |
393 | { |
362 | { |
394 | player *pl; |
363 | player *pl; |
395 | |
364 | |
396 | for (pl = first_player; pl != NULL; pl = pl->next) |
365 | for (pl = first_player; pl != NULL; pl = pl->next) |
397 | if (pl->ob != NULL && pl->ob->map == map) |
366 | if (pl->ob != NULL && pl->ob->map == map) |
… | |
… | |
417 | void |
386 | void |
418 | rangetostring (object *pl, char *obuf) |
387 | rangetostring (object *pl, char *obuf) |
419 | { |
388 | { |
420 | switch (pl->contr->shoottype) |
389 | switch (pl->contr->shoottype) |
421 | { |
390 | { |
422 | case range_none: |
391 | case range_none: |
423 | strcpy (obuf, "Range: nothing"); |
392 | strcpy (obuf, "Range: nothing"); |
424 | break; |
393 | break; |
425 | |
394 | |
426 | case range_bow: |
395 | case range_bow: |
|
|
396 | { |
|
|
397 | object *op; |
|
|
398 | |
|
|
399 | for (op = pl->inv; op; op = op->below) |
|
|
400 | if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) |
|
|
401 | break; |
|
|
402 | |
|
|
403 | if (op == NULL) |
|
|
404 | break; |
|
|
405 | |
|
|
406 | sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing"); |
|
|
407 | } |
|
|
408 | break; |
|
|
409 | |
|
|
410 | case range_magic: |
|
|
411 | if (settings.casting_time == TRUE) |
427 | { |
412 | { |
428 | object *op; |
413 | if (pl->casting_time > -1) |
429 | |
414 | { |
430 | for (op = pl->inv; op; op = op->below) |
415 | if (pl->casting_time == 0) |
431 | if (op->type == BOW && QUERY_FLAG (op, FLAG_APPLIED)) |
416 | sprintf (obuf, "Range: Holding spell (%s)", &pl->spell->name); |
432 | break; |
417 | else |
433 | if (op == NULL) |
418 | sprintf (obuf, "Range: Casting spell (%s)", &pl->spell->name); |
434 | break; |
419 | } |
435 | |
420 | else |
436 | sprintf (obuf, "Range: %s (%s)", query_base_name (op, 0), op->race ? (const char *) op->race : "nothing"); |
421 | sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); |
437 | } |
422 | } |
438 | break; |
|
|
439 | |
|
|
440 | case range_magic: |
|
|
441 | if (settings.casting_time == TRUE) |
|
|
442 | { |
|
|
443 | if (pl->casting_time > -1) |
|
|
444 | { |
|
|
445 | if (pl->casting_time == 0) |
|
|
446 | sprintf (obuf, "Range: Holding spell (%s)", (const char *) pl->spell->name); |
|
|
447 | else |
|
|
448 | sprintf (obuf, "Range: Casting spell (%s)", (const char *) pl->spell->name); |
|
|
449 | } |
|
|
450 | else |
|
|
451 | sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); |
|
|
452 | } |
|
|
453 | else |
423 | else |
454 | sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); |
424 | sprintf (obuf, "Range: spell (%s)", &pl->contr->ranges[range_magic]->name); |
455 | break; |
425 | break; |
456 | |
426 | |
457 | case range_misc: |
427 | case range_misc: |
458 | sprintf (obuf, "Range: %s", pl->contr->ranges[range_misc] ? query_base_name (pl->contr->ranges[range_misc], 0) : "none"); |
428 | sprintf (obuf, "Range: %s", pl->contr->ranges[range_misc] ? query_base_name (pl->contr->ranges[range_misc], 0) : "none"); |
459 | break; |
429 | break; |
460 | |
430 | |
461 | /* range_scroll is only used for controlling golems. If the |
431 | /* range_scroll is only used for controlling golems. If the |
462 | * the player does not have a golem, reset some things. |
432 | * the player does not have a golem, reset some things. |
463 | */ |
433 | */ |
464 | case range_golem: |
434 | case range_golem: |
465 | if (pl->contr->ranges[range_golem] != NULL) |
435 | if (pl->contr->ranges[range_golem] != NULL) |
466 | sprintf (obuf, "Range: golem (%s)", &pl->contr->ranges[range_golem]->name); |
436 | sprintf (obuf, "Range: golem (%s)", &pl->contr->ranges[range_golem]->name); |
467 | else |
437 | else |
468 | { |
438 | { |
469 | pl->contr->shoottype = range_none; |
439 | pl->contr->shoottype = range_none; |
470 | strcpy (obuf, "Range: nothing"); |
440 | strcpy (obuf, "Range: nothing"); |
471 | } |
441 | } |
472 | break; |
442 | break; |
473 | |
443 | |
474 | case range_skill: |
444 | case range_skill: |
475 | sprintf (obuf, "Skill: %s", pl->chosen_skill != NULL ? (const char *) pl->chosen_skill->name : "none"); |
445 | sprintf (obuf, "Skill: %s", pl->chosen_skill != NULL ? (const char *) pl->chosen_skill->name : "none"); |
476 | break; |
446 | break; |
477 | |
447 | |
478 | case range_builder: |
448 | case range_builder: |
479 | sprintf (obuf, "Builder: %s", query_base_name (pl->contr->ranges[range_builder], 0)); |
449 | sprintf (obuf, "Builder: %s", query_base_name (pl->contr->ranges[range_builder], 0)); |
480 | break; |
450 | break; |
481 | |
451 | |
482 | default: |
452 | default: |
483 | strcpy (obuf, "Range: illegal"); |
453 | strcpy (obuf, "Range: illegal"); |
484 | } |
454 | } |
485 | } |
455 | } |
486 | |
456 | |
487 | /** |
457 | /** |
488 | * Sets player title. |
458 | * Sets player title. |
… | |
… | |
512 | static void |
482 | static void |
513 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
483 | magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) |
514 | { |
484 | { |
515 | int x, y, dx, dy, mflags; |
485 | int x, y, dx, dy, mflags; |
516 | sint16 nx, ny; |
486 | sint16 nx, ny; |
517 | mapstruct *mp; |
487 | maptile *mp; |
518 | New_Face *f; |
488 | New_Face *f; |
519 | |
489 | |
520 | for (dx = -1; dx <= 1; dx++) |
490 | for (dx = -1; dx <= 1; dx++) |
521 | { |
491 | { |
522 | for (dy = -1; dy <= 1; dy++) |
492 | for (dy = -1; dy <= 1; dy++) |
… | |
… | |
578 | void |
548 | void |
579 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
549 | magic_mapping_mark (object *pl, char *map_mark, int strength) |
580 | { |
550 | { |
581 | int x, y, mflags; |
551 | int x, y, mflags; |
582 | sint16 nx, ny; |
552 | sint16 nx, ny; |
583 | mapstruct *mp; |
553 | maptile *mp; |
584 | New_Face *f; |
554 | New_Face *f; |
585 | |
555 | |
586 | for (x = -strength; x < strength; x++) |
556 | for (x = -strength; x < strength; x++) |
587 | { |
557 | { |
588 | for (y = -strength; y < strength; y++) |
558 | for (y = -strength; y < strength; y++) |
… | |
… | |
624 | */ |
594 | */ |
625 | |
595 | |
626 | void |
596 | void |
627 | draw_magic_map (object *pl) |
597 | draw_magic_map (object *pl) |
628 | { |
598 | { |
629 | int x, y; |
|
|
630 | char *map_mark = (char *) calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); |
599 | char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); |
631 | int xmin, xmax, ymin, ymax; |
600 | int xmin, xmax, ymin, ymax; |
632 | SockList sl; |
|
|
633 | |
601 | |
634 | if (pl->type != PLAYER) |
602 | if (pl->type != PLAYER) |
635 | { |
603 | { |
636 | LOG (llevError, "Non player object called draw_map.\n"); |
604 | LOG (llevError, "Non player object called draw_map.\n"); |
637 | return; |
605 | return; |
… | |
… | |
647 | */ |
615 | */ |
648 | xmin = MAGIC_MAP_SIZE; |
616 | xmin = MAGIC_MAP_SIZE; |
649 | ymin = MAGIC_MAP_SIZE; |
617 | ymin = MAGIC_MAP_SIZE; |
650 | xmax = 0; |
618 | xmax = 0; |
651 | ymax = 0; |
619 | ymax = 0; |
|
|
620 | |
652 | for (x = 0; x < MAGIC_MAP_SIZE; x++) |
621 | for (int x = 0; x < MAGIC_MAP_SIZE; x++) |
653 | { |
|
|
654 | for (y = 0; y < MAGIC_MAP_SIZE; y++) |
622 | for (int y = 0; y < MAGIC_MAP_SIZE; y++) |
655 | { |
|
|
656 | if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) |
623 | if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) |
657 | { |
624 | { |
658 | xmin = x < xmin ? x : xmin; |
625 | xmin = x < xmin ? x : xmin; |
659 | xmax = x > xmax ? x : xmax; |
626 | xmax = x > xmax ? x : xmax; |
660 | ymin = y < ymin ? y : ymin; |
627 | ymin = y < ymin ? y : ymin; |
661 | ymax = y > ymax ? y : ymax; |
628 | ymax = y > ymax ? y : ymax; |
662 | } |
629 | } |
663 | } |
|
|
664 | } |
|
|
665 | |
630 | |
666 | sl.buf = (unsigned char *) malloc (MAXSOCKBUF); |
631 | packet sl; |
667 | snprintf ((char *) sl.buf, MAXSOCKBUF, "magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1), |
632 | sl.printf ("magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1), |
668 | MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); |
633 | MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); |
669 | sl.len = strlen ((char *) sl.buf); |
|
|
670 | |
634 | |
671 | for (y = ymin; y <= ymax; y++) |
635 | for (int y = ymin; y <= ymax; y++) |
672 | { |
|
|
673 | for (x = xmin; x <= xmax; x++) |
636 | for (int x = xmin; x <= xmax; x++) |
674 | { |
|
|
675 | sl.buf[sl.len++] = map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR; |
637 | sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR); |
676 | } /* x loop */ |
|
|
677 | } /* y loop */ |
|
|
678 | |
638 | |
679 | Send_With_Handling (&pl->contr->socket, &sl); |
639 | Send_With_Handling (pl->contr->socket, &sl); |
680 | free (sl.buf); |
640 | |
681 | free (map_mark); |
641 | free (map_mark); |
682 | } |
642 | } |
683 | |
643 | |
684 | |
644 | |
685 | /** |
645 | /** |
… | |
… | |
687 | */ |
647 | */ |
688 | |
648 | |
689 | void |
649 | void |
690 | Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType) |
650 | Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType) |
691 | { |
651 | { |
692 | int i; |
|
|
693 | size_t len; |
652 | size_t len; |
694 | char buf[MAX_BUF]; |
653 | char buf[MAX_BUF]; |
695 | |
654 | |
696 | if (With != NULL) |
655 | if (With != NULL) |
697 | { |
|
|
698 | snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); |
656 | snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); |
699 | } |
|
|
700 | else |
657 | else |
701 | { |
|
|
702 | snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType); |
658 | snprintf (buf, MAX_BUF, "%s\t%s\t%d\n", Who, What, WhatType); |
703 | } |
659 | |
704 | len = strlen (buf); |
660 | len = strlen (buf); |
705 | for (i = 1; i < socket_info.allocated_sockets; i++) |
|
|
706 | { |
|
|
707 | if (init_sockets[i].old_mode == Old_Listen) |
|
|
708 | { |
|
|
709 | cs_write_string (&init_sockets[i], buf, len); |
|
|
710 | } |
|
|
711 | } |
|
|
712 | } |
661 | } |