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.14 by root, Thu Dec 14 01:12:35 2006 UTC vs.
Revision 1.17 by root, Thu Dec 14 04:30:33 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines