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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines