… | |
… | |
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 (client_socket * ns, int color, const char *str) |
48 | esrv_print_msg (client * ns, int color, const char *str) |
49 | { |
49 | { |
50 | packet sl; |
|
|
51 | |
|
|
52 | if (ns->status == Ns_Old) |
|
|
53 | sl.printf ("%s\n", str); |
|
|
54 | else |
|
|
55 | sl.printf ("drawinfo %d %s", color, str); |
50 | ns->send_packet_printf ("drawinfo %d %s", color, str); |
56 | |
|
|
57 | ns->send_packet (sl); |
|
|
58 | } |
51 | } |
59 | |
52 | |
60 | /** |
53 | /** |
61 | * Draws an extended message on the client. |
54 | * Draws an extended message on the client. |
62 | * ns the socket to send message to |
55 | * ns the socket to send message to |
… | |
… | |
65 | * subtype type and subtype of text message |
58 | * subtype type and subtype of text message |
66 | * 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 |
67 | * message The main message |
60 | * message The main message |
68 | */ |
61 | */ |
69 | static void |
62 | static void |
70 | esrv_print_ext_msg (client_socket * 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) |
71 | { |
64 | { |
72 | packet sl; |
|
|
73 | |
|
|
74 | sl.printf ("drawextinfo %d %hhu %hhu %s", color, type, subtype, message); |
65 | ns->send_packet_printf ("drawextinfo %d %hhu %hhu %s", color, type, subtype, message); |
75 | ns->send_packet (sl); |
|
|
76 | } |
66 | } |
77 | |
67 | |
78 | /** |
68 | /** |
79 | * Frontend for esrv_print_msg |
69 | * Frontend for esrv_print_msg |
80 | * \param colr message color |
70 | * \param colr message color |
… | |
… | |
95 | |
85 | |
96 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
86 | if (!pl || (pl->type == PLAYER && pl->contr == NULL)) |
97 | return; |
87 | return; |
98 | |
88 | |
99 | if (pl->type == PLAYER) |
89 | if (pl->type == PLAYER) |
100 | { |
|
|
101 | esrv_print_msg (&pl->contr->socket, colr, (char *) tmp); |
90 | esrv_print_msg (pl->contr->socket, colr, (char *) tmp); |
102 | return; |
|
|
103 | } |
|
|
104 | } |
91 | } |
105 | |
92 | |
106 | /** |
93 | /** |
107 | * Prints out the contents of specified buffer structures, |
94 | * Prints out the contents of specified buffer structures, |
108 | * and clears the string. |
95 | * and clears the string. |
… | |
… | |
268 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
255 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
269 | return; |
256 | return; |
270 | |
257 | |
271 | if (pri >= pl->contr->listening) |
258 | if (pri >= pl->contr->listening) |
272 | return; |
259 | return; |
|
|
260 | |
273 | if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) |
261 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
274 | { |
262 | { |
275 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
263 | char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); |
276 | |
264 | |
277 | if (buf == NULL) |
265 | if (buf == NULL) |
278 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
266 | LOG (llevError, "info::draw_ext_info -> Out of memory!"); |
… | |
… | |
283 | new_draw_info (flags, pri, pl, buf); |
271 | new_draw_info (flags, pri, pl, buf); |
284 | free (buf); |
272 | free (buf); |
285 | } |
273 | } |
286 | } |
274 | } |
287 | else |
275 | else |
288 | { |
|
|
289 | 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); |
290 | } |
|
|
291 | } |
277 | } |
292 | |
278 | |
293 | void |
279 | void |
294 | 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, ...) |
295 | { |
281 | { |
… | |
… | |
299 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
285 | if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) |
300 | return; |
286 | return; |
301 | |
287 | |
302 | if (pri >= pl->contr->listening) |
288 | if (pri >= pl->contr->listening) |
303 | return; |
289 | return; |
|
|
290 | |
304 | if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) |
291 | if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type)) |
305 | { |
292 | { |
306 | va_list ap; |
293 | va_list ap; |
307 | |
294 | |
308 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
295 | LOG (llevDebug, "Non supported extension text type for client.\n"); |
309 | va_start (ap, new_format); |
296 | va_start (ap, new_format); |
… | |
… | |
318 | |
305 | |
319 | va_start (ap, new_format); |
306 | va_start (ap, new_format); |
320 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
307 | vsnprintf (buf, HUGE_BUF, new_format, ap); |
321 | va_end (ap); |
308 | va_end (ap); |
322 | strip_media_tag (buf); |
309 | strip_media_tag (buf); |
323 | 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); |
324 | } |
311 | } |
325 | } |
312 | } |
326 | |
313 | |
327 | /** |
314 | /** |
328 | * 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. |
… | |
… | |
637 | |
624 | |
638 | for (int y = ymin; y <= ymax; y++) |
625 | for (int y = ymin; y <= ymax; y++) |
639 | for (int x = xmin; x <= xmax; x++) |
626 | for (int x = xmin; x <= xmax; x++) |
640 | sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR); |
627 | sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR); |
641 | |
628 | |
642 | Send_With_Handling (&pl->contr->socket, &sl); |
629 | pl->contr->socket->send_packet (sl); |
643 | |
|
|
644 | |
630 | |
645 | free (map_mark); |
631 | free (map_mark); |
646 | } |
632 | } |
647 | |
633 | |
648 | |
634 | |