ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/request.C
(Generate patch)

Comparing deliantra/server/socket/request.C (file contents):
Revision 1.37 by root, Thu Dec 14 20:39:54 2006 UTC vs.
Revision 1.39 by root, Fri Dec 15 03:53:44 2006 UTC

60#include <sys/time.h> 60#include <sys/time.h>
61#include <sys/socket.h> 61#include <sys/socket.h>
62#include <netinet/in.h> 62#include <netinet/in.h>
63#include <netdb.h> 63#include <netdb.h>
64 64
65#ifdef HAVE_UNISTD_H
66# include <unistd.h> 65#include <unistd.h>
67#endif
68
69#ifdef HAVE_SYS_TIME_H
70# include <sys/time.h> 66#include <sys/time.h>
71#endif
72 67
73#include "sounds.h" 68#include "sounds.h"
74 69
75/** 70/**
76 * This table translates the attack numbers as used within the 71 * This table translates the attack numbers as used within the
774 * 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
775 * '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
776 * can throttle. 771 * can throttle.
777 */ 772 */
778void 773void
779NewPlayerCmd (uint8 * buf, int len, player *pl) 774NewPlayerCmd (char *buf, int len, player *pl)
780{ 775{
781 int time, repeat; 776 int time, repeat;
782 char command[MAX_BUF]; 777 char command[MAX_BUF];
783 int pktlen; 778 int pktlen;
784 779
786 { 781 {
787 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);
788 return; 783 return;
789 } 784 }
790 785
791 pktlen = net_uint16 (buf); 786 pktlen = net_uint16 ((uint8 *)buf);
792 repeat = net_uint32 (buf + 2); 787 repeat = net_uint32 ((uint8 *)buf + 2);
793 788
794 /* -1 is special - no repeat, but don't update */ 789 /* -1 is special - no repeat, but don't update */
795 if (repeat != -1) 790 if (repeat != -1)
796 pl->count = repeat; 791 pl->count = repeat;
797 792
798 if ((len - 4) >= MAX_BUF) 793 if ((len - 4) >= MAX_BUF)
799 len = MAX_BUF - 5; 794 len = MAX_BUF - 5;
800 795
801 strncpy ((char *) command, (char *) buf + 6, len - 4); 796 strncpy ((char *) command, (char *) buf + 6, len - 4);
802 command[len - 4] = '\0'; 797 command[len - 4] = 0;
803
804 /* The following should never happen with a proper or honest client.
805 * Therefore, the error message doesn't have to be too clear - if
806 * someone is playing with a hacked/non working client, this gives them
807 * an idea of the problem, but they deserve what they get
808 */
809 if (pl->state != ST_PLAYING)
810 {
811 new_draw_info_format (NDI_UNIQUE, 0, pl->ob, "You can not issue commands - state is not ST_PLAYING (%s)", buf);
812 return;
813 }
814 798
815 /* This should not happen anymore. */ 799 /* This should not happen anymore. */
816 if (pl->ob->speed_left < -1.0) 800 if (pl->ob->speed_left < -1.0)
817 LOG (llevError, "Player has negative time - shouldn't do command.\n"); 801 LOG (llevError, "Player has negative time - shouldn't do command.\n");
818 802

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines