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.12 by pippijn, Sat Dec 9 17:28:37 2006 UTC vs.
Revision 1.14 by root, Thu Dec 14 01:12:35 2006 UTC

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 (NewSocket * ns, int color, const char *str)
49{ 49{
50 char buf[HUGE_BUF]; 50 SockList sl (MAXSOCKBUF);
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)); 58 sl.free ();
63} 59}
64 60
65/** 61/**
66 * Draws an extended message on the client. 62 * Draws an extended message on the client.
67 * ns the socket to send message to 63 * ns the socket to send message to
72 * message The main message 68 * message The main message
73 */ 69 */
74static void 70static void
75esrv_print_ext_msg (NewSocket * ns, int color, uint8 type, uint8 subtype, const char *message) 71esrv_print_ext_msg (NewSocket * ns, int color, uint8 type, uint8 subtype, const char *message)
76{ 72{
77 char buf[HUGE_BUF]; 73 SockList sl (MAXSOCKBUF);
78 74
79 snprintf (buf, HUGE_BUF, "drawextinfo %d %hhu %hhu %s", color, type, subtype, message); 75 sl.printf ("drawextinfo %d %hhu %hhu %s", color, type, subtype, message);
80 Write_String_To_Socket (ns, buf, strlen (buf)); 76 ns->send_packet (sl);
81 77 sl.free ();
82/* LOG(llevDebug,"sending %s to socket, len=%d", buf, strlen(buf));*/
83
84} 78}
85 79
86/** 80/**
87 * Frontend for esrv_print_msg 81 * Frontend for esrv_print_msg
88 * \param colr message color 82 * \param colr message color
605 */ 599 */
606 600
607void 601void
608draw_magic_map (object *pl) 602draw_magic_map (object *pl)
609{ 603{
610 int x, y;
611 char *map_mark = (char *) calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); 604 char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1);
612 int xmin, xmax, ymin, ymax; 605 int xmin, xmax, ymin, ymax;
613 SockList sl;
614 606
615 if (pl->type != PLAYER) 607 if (pl->type != PLAYER)
616 { 608 {
617 LOG (llevError, "Non player object called draw_map.\n"); 609 LOG (llevError, "Non player object called draw_map.\n");
618 return; 610 return;
628 */ 620 */
629 xmin = MAGIC_MAP_SIZE; 621 xmin = MAGIC_MAP_SIZE;
630 ymin = MAGIC_MAP_SIZE; 622 ymin = MAGIC_MAP_SIZE;
631 xmax = 0; 623 xmax = 0;
632 ymax = 0; 624 ymax = 0;
625
633 for (x = 0; x < MAGIC_MAP_SIZE; x++) 626 for (int x = 0; x < MAGIC_MAP_SIZE; x++)
634 {
635 for (y = 0; y < MAGIC_MAP_SIZE; y++) 627 for (int y = 0; y < MAGIC_MAP_SIZE; y++)
636 {
637 if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) 628 if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR)
638 { 629 {
639 xmin = x < xmin ? x : xmin; 630 xmin = x < xmin ? x : xmin;
640 xmax = x > xmax ? x : xmax; 631 xmax = x > xmax ? x : xmax;
641 ymin = y < ymin ? y : ymin; 632 ymin = y < ymin ? y : ymin;
642 ymax = y > ymax ? y : ymax; 633 ymax = y > ymax ? y : ymax;
643 } 634 }
644 }
645 }
646 635
647 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 636 SockList sl (MAXSOCKBUF);
648 snprintf ((char *) sl.buf, MAXSOCKBUF, "magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1), 637 sl.printf ("magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1),
649 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); 638 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin);
650 sl.len = strlen ((char *) sl.buf);
651 639
652 for (y = ymin; y <= ymax; y++) 640 for (int y = ymin; y <= ymax; y++)
653 {
654 for (x = xmin; x <= xmax; x++) 641 for (int x = xmin; x <= xmax; x++)
655 {
656 sl.buf[sl.len++] = map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR; 642 sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR);
657 } /* x loop */
658 } /* y loop */
659 643
660 Send_With_Handling (&pl->contr->socket, &sl); 644 Send_With_Handling (&pl->contr->socket, &sl);
661 free (sl.buf); 645
646 sl.free ();
647
662 free (map_mark); 648 free (map_mark);
663} 649}
664 650
665 651
666/** 652/**

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines