1 | |
1 | |
2 | /* |
2 | /* |
3 | * static char *rcsid_init_c = |
3 | * static char *rcsid_init_c = |
4 | * "$Id: request.C,v 1.16 2006/09/10 13:43:33 root Exp $"; |
4 | * "$Id: request.C,v 1.17 2006/09/12 19:20:09 root Exp $"; |
5 | */ |
5 | */ |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
9 | |
9 | |
… | |
… | |
581 | char command[50]; |
581 | char command[50]; |
582 | int info, nextinfo; |
582 | int info, nextinfo; |
583 | |
583 | |
584 | cmdback[0] = '\0'; |
584 | cmdback[0] = '\0'; |
585 | nextinfo = 0; |
585 | nextinfo = 0; |
|
|
586 | |
586 | while (1) |
587 | while (1) |
587 | { |
588 | { |
588 | /* 1. Extract an info */ |
589 | /* 1. Extract an info */ |
589 | info = nextinfo; |
590 | info = nextinfo; |
|
|
591 | |
590 | while ((info < len) && (buf[info] == ' ')) |
592 | while ((info < len) && (buf[info] == ' ')) |
591 | info++; |
593 | info++; |
|
|
594 | |
592 | if (info >= len) |
595 | if (info >= len) |
593 | break; |
596 | break; |
|
|
597 | |
594 | nextinfo = info + 1; |
598 | nextinfo = info + 1; |
|
|
599 | |
595 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
600 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
596 | nextinfo++; |
601 | nextinfo++; |
|
|
602 | |
597 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
603 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
598 | continue; |
604 | continue; |
|
|
605 | |
599 | strncpy (command, &(buf[info]), nextinfo - info); |
606 | strncpy (command, &(buf[info]), nextinfo - info); |
600 | command[nextinfo - info] = '\0'; |
607 | |
601 | /* 2. Interpret info */ |
608 | /* 2. Interpret info */ |
602 | if (!strcmp ("smooth", command)) |
609 | if (!strcmp ("smooth", command)) |
603 | { |
|
|
604 | /* Toggle smoothing */ |
610 | /* Toggle smoothing */ |
605 | ns->EMI_smooth = !ns->EMI_smooth; |
611 | ns->EMI_smooth = !ns->EMI_smooth; |
606 | } |
|
|
607 | else |
612 | else |
608 | { |
|
|
609 | /*bad value */ |
613 | /*bad value */; |
610 | } |
614 | |
611 | /*3. Next info */ |
615 | /*3. Next info */ |
612 | } |
616 | } |
|
|
617 | |
613 | strcpy (cmdback, "ExtendedInfoSet"); |
618 | strcpy (cmdback, "ExtendedInfoSet"); |
|
|
619 | |
614 | if (ns->EMI_smooth) |
620 | if (ns->EMI_smooth) |
615 | { |
621 | { |
616 | strcat (cmdback, " "); |
622 | strcat (cmdback, " "); |
617 | strcat (cmdback, "smoothing"); |
623 | strcat (cmdback, "smoothing"); |
618 | } |
624 | } |
|
|
625 | |
619 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
626 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
620 | } |
627 | } |
621 | |
628 | |
622 | /* |
629 | /* |
623 | #define MSG_TYPE_BOOK 1 |
630 | #define MSG_TYPE_BOOK 1 |
… | |
… | |
635 | char temp[10]; |
642 | char temp[10]; |
636 | char command[50]; |
643 | char command[50]; |
637 | int info, nextinfo, i, flag; |
644 | int info, nextinfo, i, flag; |
638 | |
645 | |
639 | cmdback[0] = '\0'; |
646 | cmdback[0] = '\0'; |
|
|
647 | |
640 | nextinfo = 0; |
648 | nextinfo = 0; |
641 | while (1) |
649 | while (1) |
642 | { |
650 | { |
643 | /* 1. Extract an info */ |
651 | /* 1. Extract an info */ |
644 | info = nextinfo; |
652 | info = nextinfo; |
|
|
653 | |
645 | while ((info < len) && (buf[info] == ' ')) |
654 | while ((info < len) && (buf[info] == ' ')) |
646 | info++; |
655 | info++; |
|
|
656 | |
647 | if (info >= len) |
657 | if (info >= len) |
648 | break; |
658 | break; |
|
|
659 | |
649 | nextinfo = info + 1; |
660 | nextinfo = info + 1; |
|
|
661 | |
650 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
662 | while ((nextinfo < len) && (buf[nextinfo] != ' ')) |
651 | nextinfo++; |
663 | nextinfo++; |
|
|
664 | |
652 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
665 | if (nextinfo - info >= 49) /*Erroneous info asked */ |
653 | continue; |
666 | continue; |
|
|
667 | |
654 | strncpy (command, &(buf[info]), nextinfo - info); |
668 | strncpy (command, &(buf[info]), nextinfo - info); |
655 | command[nextinfo - info] = '\0'; |
669 | command[nextinfo - info] = '\0'; |
656 | /* 2. Interpret info */ |
670 | /* 2. Interpret info */ |
657 | i = sscanf (command, "%d", &flag); |
671 | i = sscanf (command, "%d", &flag); |
|
|
672 | |
658 | if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) |
673 | if ((i == 1) && (flag > 0) && (flag <= MSG_TYPE_LAST)) |
659 | ns->supported_readables |= (1 << flag); |
674 | ns->supported_readables |= (1 << flag); |
660 | /*3. Next info */ |
675 | /*3. Next info */ |
661 | } |
676 | } |
|
|
677 | |
662 | /* Send resulting state */ |
678 | /* Send resulting state */ |
663 | strcpy (cmdback, "ExtendedTextSet"); |
679 | strcpy (cmdback, "ExtendedTextSet"); |
|
|
680 | |
664 | for (i = 0; i <= MSG_TYPE_LAST; i++) |
681 | for (i = 0; i <= MSG_TYPE_LAST; i++) |
665 | if (ns->supported_readables & (1 << i)) |
682 | if (ns->supported_readables & (1 << i)) |
666 | { |
683 | { |
667 | strcat (cmdback, " "); |
684 | strcat (cmdback, " "); |
668 | snprintf (temp, sizeof (temp), "%d", i); |
685 | snprintf (temp, sizeof (temp), "%d", i); |
669 | strcat (cmdback, temp); |
686 | strcat (cmdback, temp); |
670 | } |
687 | } |
|
|
688 | |
671 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
689 | Write_String_To_Socket (ns, cmdback, strlen (cmdback)); |
672 | } |
690 | } |
673 | |
691 | |
674 | /** |
692 | /** |
675 | * A lot like the old AskSmooth (in fact, now called by AskSmooth). |
693 | * A lot like the old AskSmooth (in fact, now called by AskSmooth). |