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.113 by root, Mon Jul 2 02:29:34 2007 UTC vs.
Revision 1.117 by root, Sun Jul 29 18:34:46 2007 UTC

190 socket.current_y = ob->y; 190 socket.current_y = ob->y;
191 191
192 region *reg = ob->region (); 192 region *reg = ob->region ();
193 if (socket.current_region != reg) 193 if (socket.current_region != reg)
194 { 194 {
195 INVOKE_PLAYER (REGION_CHANGE, pl, ARG_REGION (reg), ARG_REGION (socket.current_region));
195 socket.current_region = reg; 196 socket.current_region = reg;
196 socket.send_packet_printf ("drawinfo 0 You are now %s.\n(use whereami for more details)", &reg->longname);
197 } 197 }
198} 198}
199 199
200/** 200/**
201 * RequestInfo is sort of a meta command. There is some specific 201 * RequestInfo is sort of a meta command. There is some specific
202 * request of information, but we call other functions to provide 202 * request of information, but we call other functions to provide
203 * that information. 203 * that information.
204 */ 204 */
205void 205void
206RequestInfo (char *buf, int len, client * ns) 206RequestInfo (char *buf, int len, client *ns)
207{ 207{
208 char *params = NULL, *cp; 208 char *params;
209
210 /* No match */
211 char bigbuf[MAX_BUF];
212 int slen;
213
214 /* Set up replyinfo before we modify any of the buffers - this is used
215 * if we don't find a match.
216 */
217 strcpy (bigbuf, "replyinfo ");
218 slen = strlen (bigbuf);
219 safe_strcat (bigbuf, buf, &slen, MAX_BUF);
220 209
221 /* find the first space, make it null, and update the 210 /* find the first space, make it null, and update the
222 * params pointer. 211 * params pointer.
223 */ 212 */
224 for (cp = buf; *cp != '\0'; cp++) 213 for (params = buf; *params; params++)
225 if (*cp == ' ') 214 if (*params == ' ')
226 { 215 {
227 *cp = '\0';
228 params = cp + 1; 216 *params++ = 0;
229 break; 217 break;
230 } 218 }
231 219
232 if (!strcmp (buf, "image_info")) 220 if (!strcmp (buf, "image_info"))
233 send_image_info (ns, params); 221 send_image_info (ns, params);
236 else if (!strcmp (buf, "skill_info")) 224 else if (!strcmp (buf, "skill_info"))
237 send_skill_info (ns, params); 225 send_skill_info (ns, params);
238 else if (!strcmp (buf, "spell_paths")) 226 else if (!strcmp (buf, "spell_paths"))
239 send_spell_paths (ns, params); 227 send_spell_paths (ns, params);
240 else 228 else
241 ns->send_packet (bigbuf, len); 229 {
230 // undo tokenisation above and send replyinfo with the request unchanged
231 if (*params)
232 *--params = ' ';
233
234 ns->send_packet_printf ("replyinfo %s", buf);
235 }
242} 236}
243 237
244void 238void
245ExtCmd (char *buf, int len, player *pl) 239ExtCmd (char *buf, int len, player *pl)
246{ 240{
937 931
938 if (!ns.faces_sent[face_num]) 932 if (!ns.faces_sent[face_num])
939 if (ob) 933 if (ob)
940 ns.send_faces (ob); 934 ns.send_faces (ob);
941 else 935 else
942 ns.send_face (face_num); 936 ns.send_face (face_num, 10);
943 937
944 sl << uint16 (face_num); 938 sl << uint16 (face_num);
945 return 1; 939 return 1;
946 } 940 }
947 941
1536 { 1530 {
1537 LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name); 1531 LOG (llevError, "%s: spell has no face, but face is mandatory.\n", &spell->name);
1538 spell->face = face_find ("burnout.x11", blank_face); 1532 spell->face = face_find ("burnout.x11", blank_face);
1539 } 1533 }
1540 1534
1535 pl->ns->send_face (spell->face);
1536
1541 /* send the current values */ 1537 /* send the current values */
1542 sl << uint32 (spell->count) 1538 sl << uint32 (spell->count)
1543 << uint16 (spell->level) 1539 << uint16 (spell->level)
1544 << uint16 (spell->casting_time) 1540 << uint16 (spell->casting_time)
1545 << uint16 (spell->last_sp) 1541 << uint16 (spell->last_sp)
1580 * bytes and 3 strings (because that is the spec) so we need to 1576 * bytes and 3 strings (because that is the spec) so we need to
1581 * check that the length of those 3 strings, plus the 23 bytes, 1577 * check that the length of those 3 strings, plus the 23 bytes,
1582 * won't take us over the length limit for the socket, if it does, 1578 * won't take us over the length limit for the socket, if it does,
1583 * we need to send what we already have, and restart packet formation 1579 * we need to send what we already have, and restart packet formation
1584 */ 1580 */
1581 if (spell->type != SPELL)
1582 continue;
1583
1585 /* Seeing crashes by overflowed buffers. Quick arithemetic seems 1584 /* Seeing crashes by overflowed buffers. Quick arithemetic seems
1586 * to show add_spell is 26 bytes + 2 strings. However, the overun 1585 * to show add_spell is 26 bytes + 2 strings. However, the overun
1587 * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem 1586 * is hundreds of bytes off, so correcting 22 vs 26 doesn't seem
1588 * like it will fix this 1587 * like it will fix this
1589 */ 1588 */
1590 if (spell->type != SPELL)
1591 continue;
1592
1593 if (sl.length () >= (MAXSOCKBUF - (26 + strlen (spell->name) + (spell->msg ? strlen (spell->msg) : 0)))) 1589 if (sl.length () >= (MAXSOCKBUF - (26 + strlen (spell->name) + (spell->msg ? strlen (spell->msg) : 0))))
1594 { 1590 {
1591 pl->ns->flush_fx ();
1595 pl->ns->send_packet (sl); 1592 pl->ns->send_packet (sl);
1596 1593
1597 sl.reset (); 1594 sl.reset ();
1598 sl << "addspell "; 1595 sl << "addspell ";
1599 } 1596 }
1614 LOG (llevError, "Buffer overflow in esrv_add_spells!\n"); 1611 LOG (llevError, "Buffer overflow in esrv_add_spells!\n");
1615 fatal (0); 1612 fatal (0);
1616 } 1613 }
1617 1614
1618 /* finally, we can send the packet */ 1615 /* finally, we can send the packet */
1616 pl->ns->flush_fx ();
1619 pl->ns->send_packet (sl); 1617 pl->ns->send_packet (sl);
1620} 1618}
1621 1619

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines