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.13 by root, Wed Dec 13 21:27:09 2006 UTC vs.
Revision 1.19 by root, Thu Dec 14 20:39:54 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 char buf[HUGE_BUF]; 50 packet sl;
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); 51 sl.printf ("drawinfo %d %s", color, str);
59 } 52 ns->send_packet (sl);
60
61/* LOG(llevDebug,"sending %s to socket, len=%d\n", buf, strlen(buf));*/
62 Write_String_To_Socket (ns, buf, strlen (buf));
63} 53}
64 54
65/** 55/**
66 * Draws an extended message on the client. 56 * Draws an extended message on the client.
67 * ns the socket to send message to 57 * ns the socket to send message to
70 * subtype type and subtype of text message 60 * subtype type and subtype of text message
71 * 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
72 * message The main message 62 * message The main message
73 */ 63 */
74static void 64static void
75esrv_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)
76{ 66{
77 char buf[HUGE_BUF]; 67 packet sl;
78 68
79 snprintf (buf, HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message); 69 sl.printf ("drawextinfo %d %hhu %hhu %s", color, type, subtype, message);
80 Write_String_To_Socket (ns, buf, strlen (buf)); 70 ns->send_packet (sl);
81
82/* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/
83
84} 71}
85 72
86/** 73/**
87 * Frontend for esrv_print_msg 74 * Frontend for esrv_print_msg
88 * \param colr message color 75 * \param colr message color
103 90
104 if (!pl || (pl->type == PLAYER && pl->contr == NULL)) 91 if (!pl || (pl->type == PLAYER && pl->contr == NULL))
105 return; 92 return;
106 93
107 if (pl->type == PLAYER) 94 if (pl->type == PLAYER)
108 {
109 esrv_print_msg (&pl->contr->socket, colr, (char *) tmp); 95 esrv_print_msg (pl->contr->socket, colr, (char *) tmp);
110 return;
111 }
112} 96}
113 97
114/** 98/**
115 * Prints out the contents of specified buffer structures, 99 * Prints out the contents of specified buffer structures,
116 * and clears the string. 100 * and clears the string.
276 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) 260 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL))
277 return; 261 return;
278 262
279 if (pri >= pl->contr->listening) 263 if (pri >= pl->contr->listening)
280 return; 264 return;
265
281 if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) 266 if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type))
282 { 267 {
283 char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); 268 char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1);
284 269
285 if (buf == NULL) 270 if (buf == NULL)
286 LOG (llevError, "info::draw_ext_info -> Out of memory!"); 271 LOG (llevError, "info::draw_ext_info -> Out of memory!");
291 new_draw_info (flags, pri, pl, buf); 276 new_draw_info (flags, pri, pl, buf);
292 free (buf); 277 free (buf);
293 } 278 }
294 } 279 }
295 else 280 else
296 {
297 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);
298 }
299} 282}
300 283
301void 284void
302draw_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, ...)
303{ 286{
307 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) 290 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL))
308 return; 291 return;
309 292
310 if (pri >= pl->contr->listening) 293 if (pri >= pl->contr->listening)
311 return; 294 return;
295
312 if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) 296 if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type))
313 { 297 {
314 va_list ap; 298 va_list ap;
315 299
316 LOG (llevDebug, "Non supported extension text type for client.\n"); 300 LOG (llevDebug, "Non supported extension text type for client.\n");
317 va_start (ap, new_format); 301 va_start (ap, new_format);
326 310
327 va_start (ap, new_format); 311 va_start (ap, new_format);
328 vsnprintf (buf, HUGE_BUF, new_format, ap); 312 vsnprintf (buf, HUGE_BUF, new_format, ap);
329 va_end (ap); 313 va_end (ap);
330 strip_media_tag (buf); 314 strip_media_tag (buf);
331 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);
332 } 316 }
333} 317}
334 318
335/** 319/**
336 * 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.
637 xmax = x > xmax ? x : xmax; 621 xmax = x > xmax ? x : xmax;
638 ymin = y < ymin ? y : ymin; 622 ymin = y < ymin ? y : ymin;
639 ymax = y > ymax ? y : ymax; 623 ymax = y > ymax ? y : ymax;
640 } 624 }
641 625
642 SockList sl (MAXSOCKBUF); 626 packet sl;
643 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),
644 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); 628 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin);
645 629
646 for (int y = ymin; y <= ymax; y++) 630 for (int y = ymin; y <= ymax; y++)
647 for (int x = xmin; x <= xmax; x++) 631 for (int x = xmin; x <= xmax; x++)
648 sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR); 632 sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR);
649 633
650 Send_With_Handling (&pl->contr->socket, &sl); 634 pl->contr->socket->send_packet (sl);
651
652 sl.free ();
653 635
654 free (map_mark); 636 free (map_mark);
655} 637}
656 638
657 639

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines