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

Comparing deliantra/server/socket/item.C (file contents):
Revision 1.13 by root, Thu Dec 14 00:13:26 2006 UTC vs.
Revision 1.22 by root, Fri Dec 15 03:53:44 2006 UTC

45/******************************************************************************* 45/*******************************************************************************
46 * 46 *
47 * Functions related to sending object data to the client. 47 * Functions related to sending object data to the client.
48 * 48 *
49 ******************************************************************************/ 49 ******************************************************************************/
50
51/**
52 * Adds string to socklist.
53 *
54 * This is a simple function that we use a lot here. It basically
55 * adds the specified buffer into the socklist, but prepends a
56 * single byte in length. If the data is longer than that byte, it is
57 * truncated approprately.
58 */
59inline void
60add_stringlen_to_sockbuf (const char *buf, SockList * sl)
61{
62 int len;
63
64 len = strlen (buf);
65 if (len > 255)
66 len = 255;
67 SockList_AddChar (sl, (char) len);
68 strncpy ((char *) sl->buf + sl->len, buf, len);
69 sl->len += len;
70}
71 50
72/** 51/**
73 * This is a similar to query_name, but returns flags 52 * This is a similar to query_name, but returns flags
74 * to be sended to client. 53 * to be sended to client.
75 */ 54 */
130 flags |= F_LOCKED; 109 flags |= F_LOCKED;
131 110
132 return flags; 111 return flags;
133} 112}
134 113
135/* Used in the send_look to put object head into SockList 114/* Used in the send_look to put object head into packet
136 * sl for socket ns. Need socket to know if we need to send 115 * sl for socket ns. Need socket to know if we need to send
137 * animation of face to the client. 116 * animation of face to the client.
138 */ 117 */
139static void 118static void
140add_object_to_socklist (NewSocket &ns, SockList &sl, object *head) 119add_object_to_socklist (client_socket &ns, packet &sl, object *head)
141{ 120{
142 int flags, len, anim_speed; 121 int flags, len, anim_speed;
143 char item_n[MAX_BUF]; 122 char item_n[MAX_BUF];
144 const char *item_p; 123 const char *item_p;
145 124
220{ 199{
221 object *tmp, *last; 200 object *tmp, *last;
222 int got_one = 0, start_look = 0, end_look = 0; 201 int got_one = 0, start_look = 0, end_look = 0;
223 char buf[MAX_BUF]; 202 char buf[MAX_BUF];
224 203
225 if (!pl->contr->socket.update_look) 204 if (!pl->contr->socket->update_look)
226 { 205 {
227 LOG (llevDebug, "esrv_draw_look called when update_look was not set\n"); 206 LOG (llevDebug, "esrv_draw_look called when update_look was not set\n");
228 return; 207 return;
229 } 208 }
230 else 209 else
231 pl->contr->socket.update_look = 0; 210 pl->contr->socket->update_look = 0;
232 211
233 if (QUERY_FLAG (pl, FLAG_REMOVED) 212 if (QUERY_FLAG (pl, FLAG_REMOVED)
234 || !pl->map 213 || !pl->map
235 || pl->map->in_memory != MAP_IN_MEMORY 214 || pl->map->in_memory != MAP_IN_MEMORY
236 || out_of_map (pl->map, pl->x, pl->y)) 215 || out_of_map (pl->map, pl->x, pl->y))
237 return; 216 return;
238 217
239 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above); 218 for (tmp = get_map_ob (pl->map, pl->x, pl->y); tmp && tmp->above; tmp = tmp->above)
219 ;
240 220
241 SockList sl (MAXSOCKBUF); 221 packet sl;
242 222
243 Write_String_To_Socket (&pl->contr->socket, "delinv 0", sizeof ("delinv 0") - 1); 223 pl->contr->socket->send_packet ("delinv 0");
244 224
245 sl.printf ("item%d ", pl->contr->socket.itemcmd); 225 sl.printf ("item%d ", pl->contr->socket->itemcmd);
246 226
247 sl << uint32 (0); 227 sl << uint32 (0);
248 228
249 if (!(pl->contr->socket.faces_sent[empty_face->number] & NS_FACESENT_FACE)) 229 if (!(pl->contr->socket->faces_sent[empty_face->number] & NS_FACESENT_FACE))
250 esrv_send_face (&pl->contr->socket, empty_face->number, 0); 230 esrv_send_face (pl->contr->socket, empty_face->number, 0);
251 231
252 if (pl->contr->socket.look_position) 232 if (pl->contr->socket->look_position)
253 { 233 {
234 char buf[80];
235 snprintf (buf, 80, "Apply this to see %d previous items", NUM_LOOK_OBJECTS);
236
254 sl << uint32 (0x80000000 | (pl->contr->socket.look_position - NUM_LOOK_OBJECTS)) 237 sl << uint32 (0x80000000 | (pl->contr->socket->look_position - NUM_LOOK_OBJECTS))
255 << uint32 (0) 238 << uint32 (0)
256 << sint32 (-1) 239 << sint32 (-1)
257 << uint32 (empty_face->number); 240 << uint32 (empty_face->number)
258 241 << data8 (buf)
259 sl.printf ("Click here to see %d previous items", NUM_LOOK_OBJECTS);
260
261 sl << uint16 (0) 242 << uint16 (0)
262 << uint8 (0) 243 << uint8 (0)
263 << uint32 (0); 244 << uint32 (0);
264 245
265 if (pl->contr->socket.itemcmd == 2) 246 if (pl->contr->socket->itemcmd == 2)
266 sl << uint16 (0); 247 sl << uint16 (0);
267 } 248 }
268 249
269 for (last = NULL; tmp != last; tmp = tmp->below) 250 for (last = NULL; tmp != last; tmp = tmp->below)
270 { 251 {
277 last = last->below; 258 last = last->below;
278 } 259 }
279 260
280 if (LOOK_OBJ (tmp)) 261 if (LOOK_OBJ (tmp))
281 { 262 {
282 if (++start_look < pl->contr->socket.look_position) 263 if (++start_look < pl->contr->socket->look_position)
283 continue; 264 continue;
284 265
285 end_look++; 266 end_look++;
286 267
287 if (end_look > NUM_LOOK_OBJECTS) 268 if (end_look > NUM_LOOK_OBJECTS)
288 { 269 {
289 /* What we basically do is make a 'fake' object - when the user applies it, 270 /* What we basically do is make a 'fake' object - when the user applies it,
290 * we notice the special tag the object has, and act accordingly. 271 * we notice the special tag the object has, and act accordingly.
291 */ 272 */
292 SockList_AddInt (&sl, 0x80000000 | (pl->contr->socket.look_position + NUM_LOOK_OBJECTS)); 273 sl << uint32 (0x80000000 | (pl->contr->socket->look_position + NUM_LOOK_OBJECTS))
293 SockList_AddInt (&sl, 0); 274 << uint32 (0)
294 SockList_AddInt (&sl, (uint32) - 1); 275 << uint32 ((uint32) - 1)
295 SockList_AddInt (&sl, empty_face->number); 276 << uint32 (empty_face->number)
296 sprintf (buf, "Click here to see next group of items"); 277 << data8 ("Apply this to see next group of items")
297 add_stringlen_to_sockbuf (buf, &sl); 278 << uint16 (0)
298 SockList_AddShort (&sl, 0); 279 << uint8 (0)
299 SockList_AddChar (&sl, 0); 280 << uint32 (0);
300 SockList_AddInt (&sl, 0); 281
301 if (pl->contr->socket.itemcmd == 2) 282 if (pl->contr->socket->itemcmd == 2)
302 SockList_AddShort (&sl, 0); 283 sl << uint16 (0);
284
303 break; 285 break;
304 } 286 }
287
305 if (tmp->head) 288 if (tmp->head)
306 head = tmp->head; 289 head = tmp->head;
307 else 290 else
308 head = tmp; 291 head = tmp;
309 292
310 add_object_to_socklist (pl->contr->socket, sl, head); 293 add_object_to_socklist (*pl->contr->socket, sl, head);
311 got_one++; 294 got_one++;
312 295
313 if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) 296 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN))
314 { 297 {
315 Send_With_Handling (&pl->contr->socket, &sl); 298 pl->contr->socket->send_packet (sl);
299
300 sl.reset ();
316 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 301 sl.printf ("item%d ", pl->contr->socket->itemcmd);
317 sl.len = strlen ((char *) sl.buf); 302 sl << uint32 (0);
318 SockList_AddInt (&sl, 0);
319 got_one = 0; 303 got_one = 0;
320 } 304 }
321 } /* If LOOK_OBJ() */ 305 } /* If LOOK_OBJ() */
322 } 306 }
323 307
324 if (got_one) 308 if (got_one)
325 Send_With_Handling (&pl->contr->socket, &sl); 309 pl->contr->socket->send_packet (sl);
326 310
327 sl.free ();
328} 311}
329 312
330/** 313/**
331 * Sends whole inventory. 314 * Sends whole inventory.
332 */ 315 */
333void 316void
334esrv_send_inventory (object *pl, object *op) 317esrv_send_inventory (object *pl, object *op)
335{ 318{
336 object *tmp; 319 object *tmp;
337 int got_one = 0; 320 int got_one = 0;
338 SockList sl;
339 321
340 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 322 packet sl;
341 323
342 sprintf ((char *) sl.buf, "delinv %d", op->count); 324 sl.printf ("delinv %d", op->count);
343 sl.len = strlen ((char *) sl.buf); 325 pl->contr->socket->send_packet (sl);
344 Send_With_Handling (&pl->contr->socket, &sl);
345 326
327 sl.reset ();
346 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 328 sl.printf ("item%d ", pl->contr->socket->itemcmd);
347 sl.len = strlen ((char *) sl.buf);
348 329
349 SockList_AddInt (&sl, op->count); 330 sl << uint32 (op->count);
350 331
351 for (tmp = op->inv; tmp; tmp = tmp->below) 332 for (tmp = op->inv; tmp; tmp = tmp->below)
352 { 333 {
353 object *head; 334 object *head;
354 335
357 else 338 else
358 head = tmp; 339 head = tmp;
359 340
360 if (LOOK_OBJ (head)) 341 if (LOOK_OBJ (head))
361 { 342 {
362 add_object_to_socklist (pl->contr->socket, sl, head); 343 add_object_to_socklist (*pl->contr->socket, sl, head);
363 344
364 got_one++; 345 got_one++;
365 346
366 /* IT is possible for players to accumulate a huge amount of 347 /* IT is possible for players to accumulate a huge amount of
367 * items (especially with some of the bags out there) to 348 * items (especially with some of the bags out there) to
368 * overflow the buffer. IF so, send multiple item commands. 349 * overflow the buffer. IF so, send multiple item commands.
369 */ 350 */
370 if (sl.len >= (MAXSOCKBUF - MAXITEMLEN)) 351 if (sl.length () >= (MAXSOCKBUF - MAXITEMLEN))
371 { 352 {
372 Send_With_Handling (&pl->contr->socket, &sl); 353 pl->contr->socket->send_packet (sl);
354
355 sl.reset ();
373 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 356 sl.printf ("item%d ", pl->contr->socket->itemcmd);
374 sl.len = strlen ((char *) sl.buf); 357 sl << uint32 (op->count);
375 SockList_AddInt (&sl, op->count);
376 got_one = 0; 358 got_one = 0;
377 } 359 }
378 } /* If LOOK_OBJ() */ 360 } /* If LOOK_OBJ() */
379 } 361 }
362
380 if (got_one) 363 if (got_one)
381 Send_With_Handling (&pl->contr->socket, &sl); 364 pl->contr->socket->send_packet (sl);
382 sl.free (); 365
383} 366}
384 367
385/** 368/**
386 * Updates object *op for player *pl. 369 * Updates object *op for player *pl.
387 * 370 *
391 */ 374 */
392 375
393void 376void
394esrv_update_item (int flags, object *pl, object *op) 377esrv_update_item (int flags, object *pl, object *op)
395{ 378{
396 SockList sl;
397
398 /* If we have a request to send the player item, skip a few checks. */ 379 /* If we have a request to send the player item, skip a few checks. */
399 if (op != pl) 380 if (op != pl)
400 { 381 {
401 if (!LOOK_OBJ (op)) 382 if (!LOOK_OBJ (op))
402 return; 383 return;
413 * and track back the call. 394 * and track back the call.
414 */ 395 */
415 LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count); 396 LOG (llevDebug, "We have not sent item %s (%d)\n", &op->name, op->count);
416 } 397 }
417 398
418 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 399 packet sl;
419 400
420 strcpy ((char *) sl.buf, "upditem "); 401 sl << "upditem "
421 sl.len = strlen ((char *) sl.buf); 402 << uint8 (flags);
422
423 SockList_AddChar (&sl, (char) flags);
424 403
425 if (op->head) 404 if (op->head)
426 op = op->head; 405 op = op->head;
427 406
428 SockList_AddInt (&sl, op->count); 407 sl << uint32 (op->count);
429 408
430 if (flags & UPD_LOCATION) 409 if (flags & UPD_LOCATION)
431 SockList_AddInt (&sl, op->env ? op->env->count : 0); 410 sl << uint32 (op->env ? op->env->count : 0);
432 411
433 if (flags & UPD_FLAGS) 412 if (flags & UPD_FLAGS)
434 SockList_AddInt (&sl, query_flags (op)); 413 sl << uint32 (query_flags (op));
435 414
436 if (flags & UPD_WEIGHT) 415 if (flags & UPD_WEIGHT)
437 { 416 {
438 sint32 weight = WEIGHT (op); 417 sint32 weight = WEIGHT (op);
439 418
440 SockList_AddInt (&sl, QUERY_FLAG (op, FLAG_NO_PICK) ? -1 : weight); 419 sl << uint32 (QUERY_FLAG (op, FLAG_NO_PICK) ? -1 : weight);
420
441 if (pl == op) 421 if (pl == op)
442 {
443 op->contr->last_weight = weight; 422 op->contr->last_weight = weight;
444 }
445 } 423 }
446 424
447 if (flags & UPD_FACE) 425 if (flags & UPD_FACE)
448 { 426 {
449 if (!(pl->contr->socket.faces_sent[op->face->number] & NS_FACESENT_FACE)) 427 if (!(pl->contr->socket->faces_sent[op->face->number] & NS_FACESENT_FACE))
450 esrv_send_face (&pl->contr->socket, op->face->number, 0); 428 esrv_send_face (pl->contr->socket, op->face->number, 0);
451 SockList_AddInt (&sl, op->face->number); 429
430 sl << uint32 (op->face->number);
452 } 431 }
453 432
454 if (flags & UPD_NAME) 433 if (flags & UPD_NAME)
455 { 434 {
456 int len; 435 int len;
473 } 452 }
474 453
475 strncpy (item_n + len + 1, item_p, 127); 454 strncpy (item_n + len + 1, item_p, 127);
476 item_n[254] = 0; 455 item_n[254] = 0;
477 len += strlen (item_n + 1 + len) + 1; 456 len += strlen (item_n + 1 + len) + 1;
478 SockList_AddChar (&sl, (char) len); 457
479 memcpy (sl.buf + sl.len, item_n, len); 458 sl << data8 (item_n, len);
480 sl.len += len;
481 } 459 }
482 460
483 if (flags & UPD_ANIM) 461 if (flags & UPD_ANIM)
484 SockList_AddShort (&sl, op->animation_id); 462 sl << uint16 (op->animation_id);
485 463
486 if (flags & UPD_ANIMSPEED) 464 if (flags & UPD_ANIMSPEED)
487 { 465 {
488 int anim_speed = 0; 466 int anim_speed = 0;
489 467
498 else if (FABS (op->speed) >= 1.0) 476 else if (FABS (op->speed) >= 1.0)
499 anim_speed = 1; 477 anim_speed = 1;
500 else 478 else
501 anim_speed = (int) (1.0 / FABS (op->speed)); 479 anim_speed = (int) (1.0 / FABS (op->speed));
502 } 480 }
481
503 if (anim_speed > 255) 482 if (anim_speed > 255)
504 anim_speed = 255; 483 anim_speed = 255;
505 } 484 }
506 SockList_AddChar (&sl, (char) anim_speed); 485
486 sl << uint8 (anim_speed);
507 } 487 }
488
508 if (flags & UPD_NROF) 489 if (flags & UPD_NROF)
509 SockList_AddInt (&sl, op->nrof); 490 sl << uint32 (op->nrof);
510 491
511 Send_With_Handling (&pl->contr->socket, &sl); 492 pl->contr->socket->send_packet (sl);
512 sl.free ();
513} 493}
514 494
515/** 495/**
516 * Sends item's info to player. 496 * Sends item's info to player.
517 */ 497 */
518void 498void
519esrv_send_item (object *pl, object *op) 499esrv_send_item (object *pl, object *op)
520{ 500{
521 SockList sl;
522
523 /* If this is not the player object, do some more checks */ 501 /* If this is not the player object, do some more checks */
524 if (op != pl) 502 if (op != pl)
525 { 503 {
526 /* We only send 'visibile' objects to the client */ 504 /* We only send 'visibile' objects to the client */
527 if (!LOOK_OBJ (op)) 505 if (!LOOK_OBJ (op))
529 /* if the item is on the ground, mark that the look needs to 507 /* if the item is on the ground, mark that the look needs to
530 * be updated. 508 * be updated.
531 */ 509 */
532 if (!op->env) 510 if (!op->env)
533 { 511 {
534 pl->contr->socket.update_look = 1; 512 pl->contr->socket->update_look = 1;
535 return; 513 return;
536 } 514 }
537 } 515 }
538 516
539 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 517 packet sl;
540 518
541 sprintf ((char *) sl.buf, "item%d ", pl->contr->socket.itemcmd); 519 sl.printf ("item%d ", pl->contr->socket->itemcmd);
542 sl.len = strlen ((char *) sl.buf);
543 520
544 if (op->head) 521 if (op->head)
545 op = op->head; 522 op = op->head;
546 523
547 SockList_AddInt (&sl, op->env ? op->env->count : 0); 524 sl << uint32 (op->env ? op->env->count : 0);
548 525
549 add_object_to_socklist (pl->contr->socket, sl, op); 526 add_object_to_socklist (*pl->contr->socket, sl, op);
550 527
551 Send_With_Handling (&pl->contr->socket, &sl); 528 pl->contr->socket->send_packet (sl);
552 SET_FLAG (op, FLAG_CLIENT_SENT); 529 SET_FLAG (op, FLAG_CLIENT_SENT);
553 530
554 sl.free ();
555} 531}
556 532
557/** 533/**
558 * Tells the client to delete an item. Uses the item 534 * Tells the client to delete an item. Uses the item
559 * command with a -1 location. 535 * command with a -1 location.
560 */ 536 */
561 537
562void 538void
563esrv_del_item (player *pl, int tag) 539esrv_del_item (player *pl, int tag)
564{ 540{
565 SockList sl; 541 packet sl;
566 542
567 sl.buf = (unsigned char *) malloc (MAXSOCKBUF); 543 sl << "delitem "
544 << uint32 (tag);
568 545
569 strcpy ((char *) sl.buf, "delitem "); 546 pl->socket->send_packet (sl);
570 sl.len = strlen ((char *) sl.buf);
571 SockList_AddInt (&sl, tag);
572
573 Send_With_Handling (&pl->socket, &sl);
574 sl.free ();
575} 547}
576 548
577 549
578/******************************************************************************* 550/*******************************************************************************
579 * 551 *
650 return; 622 return;
651 623
652 /* If the high bit is set, player applied a pseudo object. */ 624 /* If the high bit is set, player applied a pseudo object. */
653 if (tag & 0x80000000) 625 if (tag & 0x80000000)
654 { 626 {
655 pl->socket.look_position = tag & 0x7fffffff; 627 pl->socket->look_position = tag & 0x7fffffff;
656 pl->socket.update_look = 1; 628 pl->socket->update_look = 1;
657 return; 629 return;
658 } 630 }
659 631
660 object *op = esrv_get_ob_from_count (pl->ob, tag); 632 object *op = esrv_get_ob_from_count (pl->ob, tag);
661 633
668 player_apply (pl->ob, op, 0, 0); 640 player_apply (pl->ob, op, 0, 0);
669} 641}
670 642
671/** Client wants to apply some object. Lets do so. */ 643/** Client wants to apply some object. Lets do so. */
672void 644void
673LockItem (uint8 *data, int len, player *pl) 645LockItem (char *data, int len, player *pl)
674{ 646{
675 int flag = data[0]; 647 int flag = data[0];
676 tag_t tag = net_uint32 (data + 1); 648 tag_t tag = net_uint32 ((uint8 *)data + 1);
677 object *op = esrv_get_ob_from_count (pl->ob, tag); 649 object *op = esrv_get_ob_from_count (pl->ob, tag);
678 650
679 if (!op) 651 if (!op)
680 { 652 {
681 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock"); 653 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to lock/unlock");
690 esrv_update_item (UPD_FLAGS, pl->ob, op); 662 esrv_update_item (UPD_FLAGS, pl->ob, op);
691} 663}
692 664
693/** Client wants to apply some object. Lets do so. */ 665/** Client wants to apply some object. Lets do so. */
694void 666void
695MarkItem (uint8 * data, int len, player *pl) 667MarkItem (char *data, int len, player *pl)
696{ 668{
697 tag_t tag = net_uint32 (data); 669 tag_t tag = net_uint32 ((uint8 *)data);
698 object *op = esrv_get_ob_from_count (pl->ob, tag); 670 object *op = esrv_get_ob_from_count (pl->ob, tag);
699 671
700 if (!op) 672 if (!op)
701 { 673 {
702 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark"); 674 new_draw_info (NDI_UNIQUE, 0, pl->ob, "Could not find object to mark");
786 { 758 {
787 return; 759 return;
788 } 760 }
789 dy = atoi (cp); 761 dy = atoi (cp);
790 762
791 if (FABS (dx) > pl->socket.mapx / 2 || FABS (dy) > pl->socket.mapy / 2) 763 if (FABS (dx) > pl->socket->mapx / 2 || FABS (dy) > pl->socket->mapy / 2)
792 return; 764 return;
793 765
794 if (pl->blocked_los[dx + pl->socket.mapx / 2][dy + pl->socket.mapy / 2]) 766 if (pl->blocked_los[dx + pl->socket->mapx / 2][dy + pl->socket->mapy / 2])
795 return; 767 return;
796 768
797 look_at (pl->ob, dx, dy); 769 look_at (pl->ob, dx, dy);
798} 770}
799 771
810 return; 782 return;
811 } 783 }
812 784
813 if (!to) 785 if (!to)
814 { /* drop it to the ground */ 786 { /* drop it to the ground */
815
816/* LOG(llevDebug, "Drop it on the ground.\n");*/
817
818 if (op->map && !op->env) 787 if (op->map && !op->env)
819 {
820
821/* LOG(llevDebug,"Dropping object to ground that is already on ground\n");*/
822 return; 788 return;
823 } 789
824 /* If it is an active container, then we should drop all objects 790 /* If it is an active container, then we should drop all objects
825 * in the container and not the container itself. 791 * in the container and not the container itself.
826 */ 792 */
827 if (op->inv && QUERY_FLAG (op, FLAG_APPLIED)) 793 if (op->inv && QUERY_FLAG (op, FLAG_APPLIED))
828 { 794 {
831 for (current = op->inv; current != NULL; current = next) 797 for (current = op->inv; current != NULL; current = next)
832 { 798 {
833 next = current->below; 799 next = current->below;
834 drop_object (pl, current, 0); 800 drop_object (pl, current, 0);
835 } 801 }
802
836 esrv_update_item (UPD_WEIGHT, pl, op); 803 esrv_update_item (UPD_WEIGHT, pl, op);
837 } 804 }
838 else 805 else
839 { 806 {
840 drop_object (pl, op, nrof); 807 drop_object (pl, op, nrof);
849 816
850 pl->contr->count = nrof; 817 pl->contr->count = nrof;
851 pick_up (pl, op); 818 pick_up (pl, op);
852 return; 819 return;
853 } 820 }
821
854 env = esrv_get_ob_from_count (pl, to); 822 env = esrv_get_ob_from_count (pl, to);
855 if (!env) 823 if (!env)
856 { 824 {
857 LOG (llevDebug, "Player '%s' tried to move object to the unknown location (%d)\n", &pl->name, to); 825 LOG (llevDebug, "Player '%s' tried to move object to the unknown location (%d)\n", &pl->name, to);
858 return; 826 return;
859 } 827 }
828
860 /* put_object_in_sack presumes that necessary sanity checking 829 /* put_object_in_sack presumes that necessary sanity checking
861 * has already been done (eg, it can be picked up and fits in 830 * has already been done (eg, it can be picked up and fits in
862 * in a sack, so check for those things. We should also check 831 * in a sack, so check for those things. We should also check
863 * an make sure env is in fact a container for that matter. 832 * an make sure env is in fact a container for that matter.
864 */ 833 */
865 if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof)) 834 if (env->type == CONTAINER && can_pick (pl, op) && sack_can_hold (pl, env, op, nrof))
866 { 835 {
867 put_object_in_sack (pl, env, op, nrof); 836 put_object_in_sack (pl, env, op, nrof);
868 } 837 }
869} 838}
839

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines