… | |
… | |
492 | |
492 | |
493 | /* Makes processing easier */ |
493 | /* Makes processing easier */ |
494 | if (params && *params == '\0') |
494 | if (params && *params == '\0') |
495 | params = 0; |
495 | params = 0; |
496 | |
496 | |
|
|
497 | int cnt = MAX_ITEM_PER_DROP; |
|
|
498 | |
497 | while (tmp) |
499 | while (tmp) |
498 | { |
500 | { |
499 | next = tmp->below; |
501 | next = tmp->below; |
500 | |
502 | |
501 | if (tmp->invisible) |
503 | if (tmp->invisible) |
… | |
… | |
507 | /* This following two if and else if could be merged into line |
509 | /* This following two if and else if could be merged into line |
508 | * but that probably will make it more difficult to read, and |
510 | * but that probably will make it more difficult to read, and |
509 | * not make it any more efficient |
511 | * not make it any more efficient |
510 | */ |
512 | */ |
511 | if (params && item_matched_string (op, tmp, params)) |
513 | if (params && item_matched_string (op, tmp, params)) |
|
|
514 | { |
512 | pick_up (op, tmp); |
515 | pick_up (op, tmp); |
|
|
516 | if (--cnt <= 0) break; |
|
|
517 | } |
513 | else if (can_pick (op, tmp) && !params) |
518 | else if (can_pick (op, tmp) && !params) |
514 | { |
519 | { |
515 | pick_up (op, tmp); |
520 | pick_up (op, tmp); |
516 | break; |
521 | break; |
517 | } |
522 | } |
518 | |
523 | |
519 | tmp = next; |
524 | tmp = next; |
|
|
525 | } |
|
|
526 | |
|
|
527 | if (cnt <= 0) |
|
|
528 | { |
|
|
529 | op->failmsg ("Couldn't pick up so many items at once."); |
|
|
530 | return 0; |
520 | } |
531 | } |
521 | |
532 | |
522 | if (!params && !tmp) |
533 | if (!params && !tmp) |
523 | { |
534 | { |
524 | for (tmp = op->below; tmp; tmp = tmp->below) |
535 | for (tmp = op->below; tmp; tmp = tmp->below) |
… | |
… | |
622 | else |
633 | else |
623 | tmp->remove (); |
634 | tmp->remove (); |
624 | |
635 | |
625 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
636 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
626 | tmp2 = insert_ob_in_ob (tmp, sack); |
637 | tmp2 = insert_ob_in_ob (tmp, sack); |
627 | op->update_stats (); /* This is overkill, fix_player() is called somewhere */ |
638 | |
628 | /* in object.c */ |
639 | // elmex: 2007-11-26: removed update_stats and replaced |
|
|
640 | // it by update_after_inventory_change () in the caller |
|
|
641 | // of this function |
629 | |
642 | |
630 | /* If an object merged (and thus, different object), we need to |
643 | /* If an object merged (and thus, different object), we need to |
631 | * delete the original. |
644 | * delete the original. |
632 | */ |
645 | */ |
633 | if (tmp2 != tmp) |
646 | if (tmp2 != tmp) |
… | |
… | |
646 | * This is used when dropping objects onto the floor. |
659 | * This is used when dropping objects onto the floor. |
647 | */ |
660 | */ |
648 | void |
661 | void |
649 | drop_object (object *op, object *tmp, uint32 nrof) |
662 | drop_object (object *op, object *tmp, uint32 nrof) |
650 | { |
663 | { |
651 | char buf[MAX_BUF]; |
|
|
652 | object *floor; |
664 | object *floor; |
653 | |
665 | |
654 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
666 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
655 | return; |
667 | return; |
656 | |
668 | |
… | |
… | |
690 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
702 | if (INVOKE_OBJECT (DROP, tmp, ARG_OBJECT (op))) |
691 | return; |
703 | return; |
692 | |
704 | |
693 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
705 | if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
694 | { |
706 | { |
695 | sprintf (buf, "You drop the %s.", query_name (tmp)); |
707 | op->statusmsg (format ("You drop the %s.", query_name (tmp))); |
696 | new_draw_info (NDI_UNIQUE, 0, op, buf); |
708 | op->statusmsg ("The gods who lent it to you retrieves it."); |
697 | new_draw_info (NDI_UNIQUE, 0, op, "The gods who lent it to you retrieves it."); |
|
|
698 | |
709 | |
699 | if (op->type == PLAYER) |
710 | if (op->type == PLAYER) |
700 | esrv_del_item (op->contr, tmp->count); |
711 | esrv_del_item (op->contr, tmp->count); |
701 | |
712 | |
702 | tmp->destroy (); |
713 | tmp->destroy (); |
… | |
… | |
708 | esrv_del_item (op->contr, tmp->count); |
719 | esrv_del_item (op->contr, tmp->count); |
709 | |
720 | |
710 | /* Call this before we update the various windows/players. At least |
721 | /* Call this before we update the various windows/players. At least |
711 | * that we, we know the weight is correct. |
722 | * that we, we know the weight is correct. |
712 | */ |
723 | */ |
713 | op->update_stats (); /* This is overkill, fix_player() is called somewhere */ |
724 | // 2007-11-26: moved op->update_stats away and calling it later after |
714 | /* in object.c */ |
725 | // all items of a drop command have been processed. |
715 | |
726 | |
|
|
727 | for (floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above) |
|
|
728 | if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) |
|
|
729 | return; |
|
|
730 | |
|
|
731 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
|
|
732 | sell_item (tmp, op); |
|
|
733 | |
|
|
734 | tmp->x = op->x; |
|
|
735 | tmp->y = op->y; |
|
|
736 | |
|
|
737 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |
|
|
738 | } |
|
|
739 | |
|
|
740 | void update_after_inventory_change (object *op) |
|
|
741 | { |
|
|
742 | /* Call this before we update the various windows/players. At least |
|
|
743 | * that we, we know the weight is correct. |
|
|
744 | */ |
|
|
745 | op->update_stats (); |
|
|
746 | |
|
|
747 | // elmex: kept this for now, i have no idea what happens when i remove it: |
716 | if (op->type == PLAYER) |
748 | if (op->type == PLAYER) |
717 | { |
749 | { |
718 | /* Need to update the weight for the player */ |
750 | /* Need to update the weight for the player */ |
719 | esrv_send_item (op, op); |
751 | esrv_send_item (op, op); |
720 | op->contr->ns->floorbox_update (); |
752 | op->contr->ns->floorbox_update (); |
721 | } |
753 | } |
722 | |
|
|
723 | for (floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above) |
|
|
724 | if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) |
|
|
725 | return; |
|
|
726 | |
|
|
727 | if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) |
|
|
728 | sell_item (tmp, op); |
|
|
729 | |
|
|
730 | tmp->x = op->x; |
|
|
731 | tmp->y = op->y; |
|
|
732 | |
|
|
733 | insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); |
|
|
734 | } |
754 | } |
735 | |
755 | |
736 | void |
756 | void |
737 | drop (object *op, object *tmp) |
757 | drop (object *op, object *tmp) |
738 | { |
758 | { |
… | |
… | |
922 | curinv = nextinv; |
942 | curinv = nextinv; |
923 | } |
943 | } |
924 | } |
944 | } |
925 | |
945 | |
926 | if (cnt <= 0) |
946 | if (cnt <= 0) |
927 | op->failmsg (format ( |
947 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
928 | "Droppped only %d items, you can't drop more than that at once.", |
|
|
929 | MAX_ITEM_PER_DROP |
|
|
930 | )); |
|
|
931 | |
948 | |
932 | op->contr->ns->floorbox_update (); |
949 | update_after_inventory_change (op); |
933 | |
950 | |
934 | /* draw_look(op);*/ |
951 | /* draw_look(op);*/ |
935 | return 0; |
952 | return 0; |
936 | } |
953 | } |
937 | |
954 | |
… | |
… | |
970 | |
987 | |
971 | if (!did_one) |
988 | if (!did_one) |
972 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
989 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
973 | |
990 | |
974 | if (cnt <= 0) |
991 | if (cnt <= 0) |
975 | op->failmsg (format ( |
992 | op->failmsg ("Only dropped some items, can't drop that many items at once."); |
976 | "Droppped only %d items, you can't drop more than that at once.", |
993 | |
977 | MAX_ITEM_PER_DROP |
994 | update_after_inventory_change (op); |
978 | )); |
|
|
979 | } |
|
|
980 | if (op->type == PLAYER) |
|
|
981 | { |
|
|
982 | op->contr->count = 0; |
|
|
983 | op->contr->ns->floorbox_update (); |
|
|
984 | }; |
995 | } |
985 | |
996 | |
986 | /* draw_look(op);*/ |
|
|
987 | return 0; |
997 | return 0; |
988 | } |
998 | } |
989 | |
999 | |
990 | int |
1000 | int |
991 | command_examine (object *op, char *params) |
1001 | command_examine (object *op, char *params) |