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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines