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.38 by root, Thu Dec 14 22:45:41 2006 UTC vs.
Revision 1.40 by root, Fri Dec 15 04:21:29 2006 UTC

214 } 214 }
215 } 215 }
216 216
217 socket.current_x = ob->x; 217 socket.current_x = ob->x;
218 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);
219} 263}
220 264
221void 265void
222ExtCmd (char *buf, int len, player *pl) 266ExtCmd (char *buf, int len, player *pl)
223{ 267{
769 * 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
770 * '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
771 * can throttle. 815 * can throttle.
772 */ 816 */
773void 817void
774NewPlayerCmd (uint8 * buf, int len, player *pl) 818NewPlayerCmd (char *buf, int len, player *pl)
775{ 819{
776 int time, repeat; 820 int time, repeat;
777 char command[MAX_BUF]; 821 char command[MAX_BUF];
778 int pktlen; 822 int pktlen;
779 823
781 { 825 {
782 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);
783 return; 827 return;
784 } 828 }
785 829
786 pktlen = net_uint16 (buf); 830 pktlen = net_uint16 ((uint8 *)buf);
787 repeat = net_uint32 (buf + 2); 831 repeat = net_uint32 ((uint8 *)buf + 2);
788 832
789 /* -1 is special - no repeat, but don't update */ 833 /* -1 is special - no repeat, but don't update */
790 if (repeat != -1) 834 if (repeat != -1)
791 pl->count = repeat; 835 pl->count = repeat;
792 836
793 if ((len - 4) >= MAX_BUF) 837 if ((len - 4) >= MAX_BUF)
794 len = MAX_BUF - 5; 838 len = MAX_BUF - 5;
795 839
796 strncpy ((char *) command, (char *) buf + 6, len - 4); 840 strncpy ((char *) command, (char *) buf + 6, len - 4);
797 command[len - 4] = '\0'; 841 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 842
810 /* This should not happen anymore. */ 843 /* This should not happen anymore. */
811 if (pl->ob->speed_left < -1.0) 844 if (pl->ob->speed_left < -1.0)
812 LOG (llevError, "Player has negative time - shouldn't do command.\n"); 845 LOG (llevError, "Player has negative time - shouldn't do command.\n");
813 846

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines