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.11 by root, Wed Sep 20 21:53:50 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 char buf[HUGE_BUF]; 50 packet sl;
51 51
52 if (ns->status == Ns_Old) 52 if (ns->status == Ns_Old)
53 { 53 sl.printf ("%s\n", str);
54 snprintf (buf, HUGE_BUF, "%s\n", str);
55 }
56 else 54 else
57 {
58 snprintf (buf, HUGE_BUF, "drawinfo %d %s", color, str); 55 sl.printf ("drawinfo %d %s", color, str);
59 }
60 56
61/* LOG(llevDebug,"sending %s to socket, len=%d\n", buf, strlen(buf));*/ 57 ns->send_packet (sl);
62 Write_String_To_Socket (ns, buf, strlen (buf));
63} 58}
64 59
65/** 60/**
66 * Draws an extended message on the client. 61 * Draws an extended message on the client.
67 * ns the socket to send message to 62 * ns the socket to send message to
70 * subtype type and subtype of text message 65 * subtype type and subtype of text message
71 * 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
72 * message The main message 67 * message The main message
73 */ 68 */
74static void 69static void
75esrv_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)
76{ 71{
77 char buf[HUGE_BUF]; 72 packet sl;
78 73
79 snprintf (buf, HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message); 74 sl.printf ("drawextinfo %d %hhu %hhu %s", color, type, subtype, message);
80 Write_String_To_Socket (ns, buf, strlen (buf)); 75 ns->send_packet (sl);
81
82/* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/
83
84} 76}
85 77
86/** 78/**
87 * Frontend for esrv_print_msg 79 * Frontend for esrv_print_msg
88 * \param colr message color 80 * \param colr message color
103 95
104 if (!pl || (pl->type == PLAYER && pl->contr == NULL)) 96 if (!pl || (pl->type == PLAYER && pl->contr == NULL))
105 return; 97 return;
106 98
107 if (pl->type == PLAYER) 99 if (pl->type == PLAYER)
108 {
109 esrv_print_msg (&pl->contr->socket, colr, (char *) tmp); 100 esrv_print_msg (pl->contr->socket, colr, (char *) tmp);
110 return;
111 }
112} 101}
113 102
114/** 103/**
115 * Prints out the contents of specified buffer structures, 104 * Prints out the contents of specified buffer structures,
116 * and clears the string. 105 * and clears the string.
214{ 203{
215 204
216 if (flags & NDI_ALL) 205 if (flags & NDI_ALL)
217 { 206 {
218 player *tmppl; 207 player *tmppl;
219 int i;
220 208
221 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) 209 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next)
222 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); 210 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf);
223 211
224 return; 212 return;
277 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) 265 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL))
278 return; 266 return;
279 267
280 if (pri >= pl->contr->listening) 268 if (pri >= pl->contr->listening)
281 return; 269 return;
270
282 if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) 271 if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type))
283 { 272 {
284 char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1); 273 char *buf = (char *) malloc (strlen (oldmessage == NULL ? message : oldmessage) + 1);
285 274
286 if (buf == NULL) 275 if (buf == NULL)
287 LOG (llevError, "info::draw_ext_info -> Out of memory!"); 276 LOG (llevError, "info::draw_ext_info -> Out of memory!");
292 new_draw_info (flags, pri, pl, buf); 281 new_draw_info (flags, pri, pl, buf);
293 free (buf); 282 free (buf);
294 } 283 }
295 } 284 }
296 else 285 else
297 {
298 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);
299 }
300} 287}
301 288
302void 289void
303draw_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, ...)
304{ 291{
308 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) 295 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL))
309 return; 296 return;
310 297
311 if (pri >= pl->contr->listening) 298 if (pri >= pl->contr->listening)
312 return; 299 return;
300
313 if (!CLIENT_SUPPORT_READABLES (&pl->contr->socket, type)) 301 if (!CLIENT_SUPPORT_READABLES (pl->contr->socket, type))
314 { 302 {
315 va_list ap; 303 va_list ap;
316 304
317 LOG (llevDebug, "Non supported extension text type for client.\n"); 305 LOG (llevDebug, "Non supported extension text type for client.\n");
318 va_start (ap, new_format); 306 va_start (ap, new_format);
327 315
328 va_start (ap, new_format); 316 va_start (ap, new_format);
329 vsnprintf (buf, HUGE_BUF, new_format, ap); 317 vsnprintf (buf, HUGE_BUF, new_format, ap);
330 va_end (ap); 318 va_end (ap);
331 strip_media_tag (buf); 319 strip_media_tag (buf);
332 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);
333 } 321 }
334} 322}
335 323
336/** 324/**
337 * 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.
606 */ 594 */
607 595
608void 596void
609draw_magic_map (object *pl) 597draw_magic_map (object *pl)
610{ 598{
611 int x, y;
612 char *map_mark = (char *) calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); 599 char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1);
613 int xmin, xmax, ymin, ymax; 600 int xmin, xmax, ymin, ymax;
614 SockList sl;
615 601
616 if (pl->type != PLAYER) 602 if (pl->type != PLAYER)
617 { 603 {
618 LOG (llevError, "Non player object called draw_map.\n"); 604 LOG (llevError, "Non player object called draw_map.\n");
619 return; 605 return;
629 */ 615 */
630 xmin = MAGIC_MAP_SIZE; 616 xmin = MAGIC_MAP_SIZE;
631 ymin = MAGIC_MAP_SIZE; 617 ymin = MAGIC_MAP_SIZE;
632 xmax = 0; 618 xmax = 0;
633 ymax = 0; 619 ymax = 0;
620
634 for (x = 0; x < MAGIC_MAP_SIZE; x++) 621 for (int x = 0; x < MAGIC_MAP_SIZE; x++)
635 {
636 for (y = 0; y < MAGIC_MAP_SIZE; y++) 622 for (int y = 0; y < MAGIC_MAP_SIZE; y++)
637 {
638 if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) 623 if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR)
639 { 624 {
640 xmin = x < xmin ? x : xmin; 625 xmin = x < xmin ? x : xmin;
641 xmax = x > xmax ? x : xmax; 626 xmax = x > xmax ? x : xmax;
642 ymin = y < ymin ? y : ymin; 627 ymin = y < ymin ? y : ymin;
643 ymax = y > ymax ? y : ymax; 628 ymax = y > ymax ? y : ymax;
644 } 629 }
645 }
646 }
647 630
648 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 631 packet sl;
649 snprintf ((char *) sl.buf, MAXSOCKBUF, "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),
650 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); 633 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin);
651 sl.len = strlen ((char *) sl.buf);
652 634
653 for (y = ymin; y <= ymax; y++) 635 for (int y = ymin; y <= ymax; y++)
654 {
655 for (x = xmin; x <= xmax; x++) 636 for (int x = xmin; x <= xmax; x++)
656 {
657 sl.buf[sl.len++] = map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR; 637 sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR);
658 } /* x loop */
659 } /* y loop */
660 638
661 Send_With_Handling (&pl->contr->socket, &sl); 639 Send_With_Handling (pl->contr->socket, &sl);
662 free (sl.buf); 640
663 free (map_mark); 641 free (map_mark);
664} 642}
665 643
666 644
667/** 645/**
669 */ 647 */
670 648
671void 649void
672Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType) 650Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType)
673{ 651{
674 int i;
675 size_t len; 652 size_t len;
676 char buf[MAX_BUF]; 653 char buf[MAX_BUF];
677 654
678 if (With != NULL) 655 if (With != NULL)
679 snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); 656 snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines