… | |
… | |
769 | * etc.). It is a lot like PlayerCmd above, but is called with the |
769 | * etc.). It is a lot like PlayerCmd above, but is called with the |
770 | * 'ncom' method which gives more information back to the client so it |
770 | * 'ncom' method which gives more information back to the client so it |
771 | * can throttle. |
771 | * can throttle. |
772 | */ |
772 | */ |
773 | void |
773 | void |
774 | NewPlayerCmd (uint8 * buf, int len, player *pl) |
774 | NewPlayerCmd (char *buf, int len, player *pl) |
775 | { |
775 | { |
776 | int time, repeat; |
776 | int time, repeat; |
777 | char command[MAX_BUF]; |
777 | char command[MAX_BUF]; |
778 | int pktlen; |
778 | int pktlen; |
779 | |
779 | |
… | |
… | |
781 | { |
781 | { |
782 | LOG (llevDebug, "Corrupt ncom command <%s> not long enough - discarding\n", buf); |
782 | LOG (llevDebug, "Corrupt ncom command <%s> not long enough - discarding\n", buf); |
783 | return; |
783 | return; |
784 | } |
784 | } |
785 | |
785 | |
786 | pktlen = net_uint16 (buf); |
786 | pktlen = net_uint16 ((uint8 *)buf); |
787 | repeat = net_uint32 (buf + 2); |
787 | repeat = net_uint32 ((uint8 *)buf + 2); |
788 | |
788 | |
789 | /* -1 is special - no repeat, but don't update */ |
789 | /* -1 is special - no repeat, but don't update */ |
790 | if (repeat != -1) |
790 | if (repeat != -1) |
791 | pl->count = repeat; |
791 | pl->count = repeat; |
792 | |
792 | |
793 | if ((len - 4) >= MAX_BUF) |
793 | if ((len - 4) >= MAX_BUF) |
794 | len = MAX_BUF - 5; |
794 | len = MAX_BUF - 5; |
795 | |
795 | |
796 | strncpy ((char *) command, (char *) buf + 6, len - 4); |
796 | strncpy ((char *) command, (char *) buf + 6, len - 4); |
797 | command[len - 4] = '\0'; |
797 | command[len - 4] = 0; |
798 | |
|
|
799 | /* The following should never happen with a proper or honest client. |
|
|
800 | * Therefore, the error message doesn't have to be too clear - if |
|
|
801 | * someone is playing with a hacked/non working client, this gives them |
|
|
802 | * an idea of the problem, but they deserve what they get |
|
|
803 | */ |
|
|
804 | if (pl->state != ST_PLAYING) |
|
|
805 | { |
|
|
806 | new_draw_info_format (NDI_UNIQUE, 0, pl->ob, "You can not issue commands - state is not ST_PLAYING (%s)", buf); |
|
|
807 | return; |
|
|
808 | } |
|
|
809 | |
798 | |
810 | /* This should not happen anymore. */ |
799 | /* This should not happen anymore. */ |
811 | if (pl->ob->speed_left < -1.0) |
800 | if (pl->ob->speed_left < -1.0) |
812 | LOG (llevError, "Player has negative time - shouldn't do command.\n"); |
801 | LOG (llevError, "Player has negative time - shouldn't do command.\n"); |
813 | |
802 | |