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.40 by root, Fri Dec 15 04:21:29 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
219 } 214 }
220 } 215 }
221 216
222 socket.current_x = ob->x; 217 socket.current_x = ob->x;
223 socket.current_y = ob->y; 218 socket.current_y = ob->y;
219}
220
221/**
222 * RequestInfo is sort of a meta command. There is some specific
223 * request of information, but we call other functions to provide
224 * that information.
225 */
226void
227RequestInfo (char *buf, int len, client_socket * ns)
228{
229 char *params = NULL, *cp;
230
231 /* No match */
232 char bigbuf[MAX_BUF];
233 int slen;
234
235 /* Set up replyinfo before we modify any of the buffers - this is used
236 * if we don't find a match.
237 */
238 strcpy (bigbuf, "replyinfo ");
239 slen = strlen (bigbuf);
240 safe_strcat (bigbuf, buf, &slen, MAX_BUF);
241
242 /* find the first space, make it null, and update the
243 * params pointer.
244 */
245 for (cp = buf; *cp != '\0'; cp++)
246 if (*cp == ' ')
247 {
248 *cp = '\0';
249 params = cp + 1;
250 break;
251 }
252
253 if (!strcmp (buf, "image_info"))
254 send_image_info (ns, params);
255 else if (!strcmp (buf, "image_sums"))
256 send_image_sums (ns, params);
257 else if (!strcmp (buf, "skill_info"))
258 send_skill_info (ns, params);
259 else if (!strcmp (buf, "spell_paths"))
260 send_spell_paths (ns, params);
261 else
262 ns->send_packet (bigbuf, len);
224} 263}
225 264
226void 265void
227ExtCmd (char *buf, int len, player *pl) 266ExtCmd (char *buf, int len, player *pl)
228{ 267{
774 * etc.). It is a lot like PlayerCmd above, but is called with the 813 * 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 814 * 'ncom' method which gives more information back to the client so it
776 * can throttle. 815 * can throttle.
777 */ 816 */
778void 817void
779NewPlayerCmd (uint8 * buf, int len, player *pl) 818NewPlayerCmd (char *buf, int len, player *pl)
780{ 819{
781 int time, repeat; 820 int time, repeat;
782 char command[MAX_BUF]; 821 char command[MAX_BUF];
783 int pktlen; 822 int pktlen;
784 823
786 { 825 {
787 LOG (llevDebug, "Corrupt ncom command <%s> not long enough - discarding\n", buf); 826 LOG (llevDebug, "Corrupt ncom command <%s> not long enough - discarding\n", buf);
788 return; 827 return;
789 } 828 }
790 829
791 pktlen = net_uint16 (buf); 830 pktlen = net_uint16 ((uint8 *)buf);
792 repeat = net_uint32 (buf + 2); 831 repeat = net_uint32 ((uint8 *)buf + 2);
793 832
794 /* -1 is special - no repeat, but don't update */ 833 /* -1 is special - no repeat, but don't update */
795 if (repeat != -1) 834 if (repeat != -1)
796 pl->count = repeat; 835 pl->count = repeat;
797 836
798 if ((len - 4) >= MAX_BUF) 837 if ((len - 4) >= MAX_BUF)
799 len = MAX_BUF - 5; 838 len = MAX_BUF - 5;
800 839
801 strncpy ((char *) command, (char *) buf + 6, len - 4); 840 strncpy ((char *) command, (char *) buf + 6, len - 4);
802 command[len - 4] = '\0'; 841 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 842
815 /* This should not happen anymore. */ 843 /* This should not happen anymore. */
816 if (pl->ob->speed_left < -1.0) 844 if (pl->ob->speed_left < -1.0)
817 LOG (llevError, "Player has negative time - shouldn't do command.\n"); 845 LOG (llevError, "Player has negative time - shouldn't do command.\n");
818 846

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines