… | |
… | |
43 | * 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 |
44 | * parameter. the esrv_drawinfo functions should probably be |
44 | * parameter. the esrv_drawinfo functions should probably be |
45 | * replaced with this, just using black as the color. |
45 | * replaced with this, just using black as the color. |
46 | */ |
46 | */ |
47 | static void |
47 | static void |
48 | esrv_print_msg (NewSocket * ns, int color, const char *str) |
48 | esrv_print_msg (client * ns, int color, const char *str) |
49 | { |
49 | { |
50 | char buf[HUGE_BUF]; |
50 | ns->send_packet_printf ("drawinfo %d %s", color, str); |
51 | |
|
|
52 | if (ns->status == Ns_Old) |
|
|
53 | { |
|
|
54 | snprintf (buf, HUGE_BUF, "%s\n", str); |
|
|
55 | } |
|
|
56 | else |
|
|
57 | { |
|
|
58 | snprintf (buf, HUGE_BUF, "drawinfo %d %s", color, str); |
|
|
59 | } |
|
|
60 | |
|
|
61 | /* LOG(llevDebug,"sending %s to socket, len=%d\n", buf, strlen(buf));*/ |
|
|
62 | Write_String_To_Socket (ns, buf, strlen (buf)); |
|
|
63 | } |
51 | } |
64 | |
52 | |
65 | /** |
53 | /** |
66 | * Draws an extended message on the client. |
54 | * Draws an extended message on the client. |
67 | * ns the socket to send message to |
55 | * ns the socket to send message to |
… | |
… | |
70 | * subtype type and subtype of text message |
58 | * subtype type and subtype of text message |
71 | * intro Intro message to send with main message if client does not support the message type |
59 | * intro Intro message to send with main message if client does not support the message type |
72 | * message The main message |
60 | * message The main message |
73 | */ |
61 | */ |
74 | static void |
62 | static void |
75 | esrv_print_ext_msg (NewSocket * ns, int color, uint8 type, uint8 subtype, const char *message) |
63 | esrv_print_ext_msg (client * ns, int color, uint8 type, uint8 subtype, const char *message) |
76 | { |
64 | { |
77 | char buf[HUGE_BUF]; |
|
|
78 | |
|
|
79 | snprintf (buf, HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message); |
65 | ns->send_packet_printf ("drawextinfo %d %hhu %hhu %s", color, type, subtype, message); |
80 | Write_String_To_Socket (ns, buf, strlen (buf)); |
|
|
81 | |
|
|
82 | /* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/ |
|
|
83 | |
|
|
84 | } |
66 | } |
85 | |
67 | |
86 | /** |
68 | /** |
87 | * Frontend for esrv_print_msg |
69 | * Frontend for esrv_print_msg |
88 | * \param colr message color |
70 | * \param colr message color |
… | |
… | |
103 | |
85 | |
104 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
86 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
105 | return; |
87 | return; |
106 | |
88 | |
107 | if (pl->type == PLAYER) |
89 | if (pl->type == PLAYER) |
108 | { |
|
|
109 | esrv_print_msg (&pl->contr->socket, colr, (char *) tmp); |
90 | esrv_print_msg (pl->contr->socket, colr, (char *) tmp); |
110 | return; |
|
|
111 | } |
|
|
112 | } |
91 | } |
113 | |
92 | |
114 | /** |
93 | /** |
115 | * Prints out the contents of specified buffer structures, |
94 | * Prints out the contents of specified buffer structures, |
116 | * and clears the string. |
95 | * and clears the string. |
… | |
… | |
276 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
255 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
277 | return; |
256 | return; |
278 | |
257 | |
279 | if (pri >= pl->contr->listening) |
258 | if (pri >= pl->contr->listening) |
280 | return; |
259 | return; |
|
|
260 | |
281 | if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) |
261 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
282 | { |
262 | { |
283 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
263 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
284 | |
264 | |
285 | if (buf == NULL) |
265 | if (buf == NULL) |
286 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
266 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
… | |
… | |
291 | new_draw_info (flags, pri, pl, buf); |
271 | new_draw_info (flags, pri, pl, buf); |
292 | free (buf); |
272 | free (buf); |
293 | } |
273 | } |
294 | } |
274 | } |
295 | else |
275 | else |
296 | { |
|
|
297 | esrv_print_ext_msg (&pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, message); |
276 | esrv_print_ext_msg (pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, message); |
298 | } |
|
|
299 | } |
277 | } |
300 | |
278 | |
301 | void |
279 | void |
302 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
280 | draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) |
303 | { |
281 | { |
… | |
… | |
307 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
285 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
308 | return; |
286 | return; |
309 | |
287 | |
310 | if (pri >= pl->contr->listening) |
288 | if (pri >= pl->contr->listening) |
311 | return; |
289 | return; |
|
|
290 | |
312 | if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) |
291 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
313 | { |
292 | { |
314 | va_list ap; |
293 | va_list ap; |
315 | |
294 | |
316 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
295 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
317 | va_start (ap, new_format); |
296 | va_start (ap, new_format); |
… | |
… | |
326 | |
305 | |
327 | va_start (ap, new_format); |
306 | va_start (ap, new_format); |
328 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
307 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
329 | va_end (ap); |
308 | va_end (ap); |
330 | strip_media_tag (buf); |
309 | strip_media_tag (buf); |
331 | esrv_print_ext_msg (&pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, buf); |
310 | esrv_print_ext_msg (pl->contr->socket, flags & NDI_COLOR_MASK, type, subtype, buf); |
332 | } |
311 | } |
333 | } |
312 | } |
334 | |
313 | |
335 | /** |
314 | /** |
336 | * Writes to everyone on the map *except* op. This is useful for emotions. |
315 | * Writes to everyone on the map *except* op. This is useful for emotions. |
… | |
… | |
605 | */ |
584 | */ |
606 | |
585 | |
607 | void |
586 | void |
608 | draw_magic_map (object *pl) |
587 | draw_magic_map (object *pl) |
609 | { |
588 | { |
610 | int x, y; |
|
|
611 | char *map_mark = (char *) calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); |
589 | char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); |
612 | int xmin, xmax, ymin, ymax; |
590 | int xmin, xmax, ymin, ymax; |
613 | SockList sl; |
|
|
614 | |
591 | |
615 | if (pl->type != PLAYER) |
592 | if (pl->type != PLAYER) |
616 | { |
593 | { |
617 | LOG (llevError, "Non player object called draw_map.\n"); |
594 | LOG (llevError, "Non player object called draw_map.\n"); |
618 | return; |
595 | return; |
… | |
… | |
628 | */ |
605 | */ |
629 | xmin = MAGIC_MAP_SIZE; |
606 | xmin = MAGIC_MAP_SIZE; |
630 | ymin = MAGIC_MAP_SIZE; |
607 | ymin = MAGIC_MAP_SIZE; |
631 | xmax = 0; |
608 | xmax = 0; |
632 | ymax = 0; |
609 | ymax = 0; |
|
|
610 | |
633 | for (x = 0; x < MAGIC_MAP_SIZE; x++) |
611 | for (int x = 0; x < MAGIC_MAP_SIZE; x++) |
634 | { |
|
|
635 | for (y = 0; y < MAGIC_MAP_SIZE; y++) |
612 | for (int y = 0; y < MAGIC_MAP_SIZE; y++) |
636 | { |
|
|
637 | if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) |
613 | if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) |
638 | { |
614 | { |
639 | xmin = x < xmin ? x : xmin; |
615 | xmin = x < xmin ? x : xmin; |
640 | xmax = x > xmax ? x : xmax; |
616 | xmax = x > xmax ? x : xmax; |
641 | ymin = y < ymin ? y : ymin; |
617 | ymin = y < ymin ? y : ymin; |
642 | ymax = y > ymax ? y : ymax; |
618 | ymax = y > ymax ? y : ymax; |
643 | } |
619 | } |
644 | } |
|
|
645 | } |
|
|
646 | |
620 | |
647 | sl.buf = (unsigned char *) malloc (MAXSOCKBUF); |
621 | packet sl; |
648 | snprintf ((char *) sl.buf, MAXSOCKBUF, "magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1), |
622 | sl.printf ("magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1), |
649 | MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); |
623 | MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); |
650 | sl.len = strlen ((char *) sl.buf); |
|
|
651 | |
624 | |
652 | for (y = ymin; y <= ymax; y++) |
625 | for (int y = ymin; y <= ymax; y++) |
653 | { |
|
|
654 | for (x = xmin; x <= xmax; x++) |
626 | for (int x = xmin; x <= xmax; x++) |
655 | { |
|
|
656 | sl.buf[sl.len++] = map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR; |
627 | sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR); |
657 | } /* x loop */ |
|
|
658 | } /* y loop */ |
|
|
659 | |
628 | |
660 | Send_With_Handling (&pl->contr->socket, &sl); |
629 | pl->contr->socket->send_packet (sl); |
661 | free (sl.buf); |
630 | |
662 | free (map_mark); |
631 | free (map_mark); |
663 | } |
632 | } |
664 | |
633 | |
665 | |
634 | |
666 | /** |
635 | /** |