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.15 by root, Thu Dec 14 01:21:58 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 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
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 (NewSocket * 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
214{ 206{
215 207
216 if (flags & NDI_ALL) 208 if (flags & NDI_ALL)
217 { 209 {
218 player *tmppl; 210 player *tmppl;
219 int i;
220 211
221 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next) 212 for (tmppl = first_player; tmppl != NULL; tmppl = tmppl->next)
222 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf); 213 new_draw_info ((flags & ~NDI_ALL), pri, tmppl->ob, buf);
223 214
224 return; 215 return;
606 */ 597 */
607 598
608void 599void
609draw_magic_map (object *pl) 600draw_magic_map (object *pl)
610{ 601{
611 int x, y;
612 char *map_mark = (char *) calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); 602 char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1);
613 int xmin, xmax, ymin, ymax; 603 int xmin, xmax, ymin, ymax;
614 SockList sl;
615 604
616 if (pl->type != PLAYER) 605 if (pl->type != PLAYER)
617 { 606 {
618 LOG (llevError, "Non player object called draw_map.\n"); 607 LOG (llevError, "Non player object called draw_map.\n");
619 return; 608 return;
629 */ 618 */
630 xmin = MAGIC_MAP_SIZE; 619 xmin = MAGIC_MAP_SIZE;
631 ymin = MAGIC_MAP_SIZE; 620 ymin = MAGIC_MAP_SIZE;
632 xmax = 0; 621 xmax = 0;
633 ymax = 0; 622 ymax = 0;
623
634 for (x = 0; x < MAGIC_MAP_SIZE; x++) 624 for (int x = 0; x < MAGIC_MAP_SIZE; x++)
635 {
636 for (y = 0; y < MAGIC_MAP_SIZE; y++) 625 for (int y = 0; y < MAGIC_MAP_SIZE; y++)
637 {
638 if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR) 626 if (map_mark[x + MAP_WIDTH (pl->map) * y] | FACE_FLOOR)
639 { 627 {
640 xmin = x < xmin ? x : xmin; 628 xmin = x < xmin ? x : xmin;
641 xmax = x > xmax ? x : xmax; 629 xmax = x > xmax ? x : xmax;
642 ymin = y < ymin ? y : ymin; 630 ymin = y < ymin ? y : ymin;
643 ymax = y > ymax ? y : ymax; 631 ymax = y > ymax ? y : ymax;
644 } 632 }
645 }
646 }
647 633
648 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 634 packet sl;
649 snprintf ((char *) sl.buf, MAXSOCKBUF, "magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1), 635 sl.printf ("magicmap %d %d %d %d ", (xmax - xmin + 1), (ymax - ymin + 1),
650 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin); 636 MAGIC_MAP_HALF - xmin, MAGIC_MAP_HALF - ymin);
651 sl.len = strlen ((char *) sl.buf);
652 637
653 for (y = ymin; y <= ymax; y++) 638 for (int y = ymin; y <= ymax; y++)
654 {
655 for (x = xmin; x <= xmax; x++) 639 for (int x = xmin; x <= xmax; x++)
656 {
657 sl.buf[sl.len++] = map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR; 640 sl << uint8 (map_mark[x + MAGIC_MAP_SIZE * y] & ~FACE_FLOOR);
658 } /* x loop */
659 } /* y loop */
660 641
661 Send_With_Handling (&pl->contr->socket, &sl); 642 Send_With_Handling (&pl->contr->socket, &sl);
662 free (sl.buf); 643
644
663 free (map_mark); 645 free (map_mark);
664} 646}
665 647
666 648
667/** 649/**
669 */ 651 */
670 652
671void 653void
672Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType) 654Log_Kill (const char *Who, const char *What, int WhatType, const char *With, int WithType)
673{ 655{
674 int i;
675 size_t len; 656 size_t len;
676 char buf[MAX_BUF]; 657 char buf[MAX_BUF];
677 658
678 if (With != NULL) 659 if (With != NULL)
679 snprintf (buf, MAX_BUF, "%s\t%s\t%d\t%s\t%d\n", Who, What, WhatType, With, WithType); 660 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