… | |
… | |
449 | |
449 | |
450 | /* Makes processing easier */ |
450 | /* Makes processing easier */ |
451 | if (params && *params == '\0') |
451 | if (params && *params == '\0') |
452 | params = 0; |
452 | params = 0; |
453 | |
453 | |
454 | int cnt = MAX_ITEM_PER_DROP; |
454 | int cnt = MAX_ITEM_PER_ACTION; |
455 | |
455 | |
456 | while (tmp) |
456 | while (tmp) |
457 | { |
457 | { |
458 | next = tmp->below; |
458 | next = tmp->below; |
459 | |
459 | |
… | |
… | |
567 | if (!can_split (op, tmp, nrof)) |
567 | if (!can_split (op, tmp, nrof)) |
568 | return; |
568 | return; |
569 | |
569 | |
570 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
570 | new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); |
571 | sack->insert (tmp); |
571 | sack->insert (tmp); |
572 | } |
|
|
573 | |
|
|
574 | /* |
|
|
575 | * This function was part of drop, now is own function. |
|
|
576 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
|
|
577 | * nrof objects is tried to dropped. |
|
|
578 | * This is used when dropping objects onto the floor. |
|
|
579 | */ |
|
|
580 | void |
|
|
581 | drop_object (object *op, object *tmp, uint32 nrof) |
|
|
582 | { |
|
|
583 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
|
|
584 | return; |
|
|
585 | |
|
|
586 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
|
|
587 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
|
|
588 | return; /* can't unapply it */ |
|
|
589 | |
|
|
590 | /* We are only dropping some of the items. We split the current object |
|
|
591 | * off |
|
|
592 | */ |
|
|
593 | if (!can_split (op, tmp, nrof)) |
|
|
594 | return; |
|
|
595 | |
|
|
596 | drop_object (op, tmp); |
|
|
597 | |
|
|
598 | if (!tmp->destroyed () && !tmp->is_inserted ()) |
|
|
599 | { |
|
|
600 | // if nothing happened with the object we give it back |
|
|
601 | op->insert (tmp); |
|
|
602 | } |
|
|
603 | } |
572 | } |
604 | |
573 | |
605 | /* In contrast to drop_object (op, tmp, nrof) above this function takes the |
574 | /* In contrast to drop_object (op, tmp, nrof) above this function takes the |
606 | * already split off object, and feeds it to the event handlers and does |
575 | * already split off object, and feeds it to the event handlers and does |
607 | * other magic with it. |
576 | * other magic with it. |
… | |
… | |
642 | |
611 | |
643 | if (is_in_shop (dropper) && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY) |
612 | if (is_in_shop (dropper) && !QUERY_FLAG (obj, FLAG_UNPAID) && obj->type != MONEY) |
644 | if (!sell_item (obj, dropper)) |
613 | if (!sell_item (obj, dropper)) |
645 | return; |
614 | return; |
646 | |
615 | |
|
|
616 | if (!obj->can_drop_at (dropper->map, dropper->x, dropper->y, dropper)) |
|
|
617 | return; |
|
|
618 | |
647 | /* If nothing special happened with this object, the default action is to |
619 | /* If nothing special happened with this object, the default action is to |
648 | * insert it below the dropper: |
620 | * insert it below the dropper: |
649 | */ |
621 | */ |
650 | |
622 | |
651 | obj->x = dropper->x; |
623 | obj->x = dropper->x; |
652 | obj->y = dropper->y; |
624 | obj->y = dropper->y; |
653 | |
625 | |
654 | insert_ob_in_map (obj, dropper->map, dropper, INS_BELOW_ORIGINATOR); |
626 | insert_ob_in_map (obj, dropper->map, dropper, INS_BELOW_ORIGINATOR); |
|
|
627 | } |
|
|
628 | |
|
|
629 | /* |
|
|
630 | * This function was part of drop, now is own function. |
|
|
631 | * Player 'op' tries to drop object 'tmp', if tmp is non zero, then |
|
|
632 | * nrof objects are tried to drop. |
|
|
633 | * This is used when dropping objects onto the floor. |
|
|
634 | */ |
|
|
635 | void |
|
|
636 | drop_object (object *op, object *tmp, uint32 nrof) |
|
|
637 | { |
|
|
638 | if (QUERY_FLAG (tmp, FLAG_NO_DROP)) |
|
|
639 | return; |
|
|
640 | |
|
|
641 | if (QUERY_FLAG (tmp, FLAG_APPLIED)) |
|
|
642 | if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) |
|
|
643 | return; /* can't unapply it */ |
|
|
644 | |
|
|
645 | /* We are only dropping some of the items. We split the current object |
|
|
646 | * off |
|
|
647 | */ |
|
|
648 | if (!can_split (op, tmp, nrof)) |
|
|
649 | return; |
|
|
650 | |
|
|
651 | drop_object (op, tmp); |
|
|
652 | |
|
|
653 | if (!tmp->destroyed () && !tmp->is_inserted ()) |
|
|
654 | { |
|
|
655 | // if nothing happened with the object we give it back |
|
|
656 | op->insert (tmp); |
|
|
657 | } |
655 | } |
658 | } |
656 | |
659 | |
657 | void |
660 | void |
658 | drop (object *op, object *tmp) |
661 | drop (object *op, object *tmp) |
659 | { |
662 | { |
… | |
… | |
672 | */ |
675 | */ |
673 | tmp->destroy (); |
676 | tmp->destroy (); |
674 | return; |
677 | return; |
675 | } |
678 | } |
676 | else |
679 | else |
677 | { |
|
|
678 | while (tmp && tmp->invisible) |
680 | while (tmp && tmp->invisible) |
679 | tmp = tmp->below; |
681 | tmp = tmp->below; |
680 | } |
|
|
681 | } |
682 | } |
682 | |
683 | |
683 | if (tmp == NULL) |
684 | if (!tmp) |
684 | { |
685 | { |
685 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
686 | new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); |
686 | return; |
687 | return; |
687 | } |
688 | } |
688 | |
689 | |
… | |
… | |
746 | /* |
747 | /* |
747 | Care must be taken that the next item pointer is not to money as |
748 | Care must be taken that the next item pointer is not to money as |
748 | the drop() routine will do unknown things to it when dropping |
749 | the drop() routine will do unknown things to it when dropping |
749 | in a shop. --Tero.Pelander@utu.fi |
750 | in a shop. --Tero.Pelander@utu.fi |
750 | */ |
751 | */ |
751 | |
|
|
752 | int cnt = MAX_ITEM_PER_DROP; |
752 | int cnt = MAX_ITEM_PER_ACTION; |
753 | |
753 | |
754 | if (!params) |
754 | if (!params) |
755 | { |
755 | { |
756 | while (curinv) |
756 | while (curinv) |
757 | { |
757 | { |
758 | nextinv = curinv->below; |
758 | nextinv = curinv->below; |
759 | |
759 | |
760 | while (nextinv && nextinv->type == MONEY) |
760 | while (nextinv && nextinv->type == MONEY) |
761 | nextinv = nextinv->below; |
761 | nextinv = nextinv->below; |
762 | |
762 | |
763 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY && |
763 | if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) |
764 | curinv->type != FOOD && curinv->type != KEY && |
764 | && curinv->type != MONEY |
765 | curinv->type != SPECIAL_KEY && curinv->type != GEM && |
765 | && curinv->type != FOOD |
|
|
766 | && curinv->type != KEY |
|
|
767 | && curinv->type != SPECIAL_KEY |
|
|
768 | && curinv->type != GEM |
|
|
769 | && !curinv->invisible |
766 | !curinv->invisible && (curinv->type != CONTAINER || op->container_ () != curinv)) |
770 | && (curinv->type != CONTAINER || op->container_ () != curinv)) |
767 | { |
771 | { |
768 | drop (op, curinv); |
772 | drop (op, curinv); |
769 | if (--cnt <= 0) break; |
773 | if (--cnt <= 0) break; |
770 | } |
774 | } |
771 | |
775 | |
… | |
… | |
910 | |
914 | |
911 | if (item_matched_string (op, tmp, params)) |
915 | if (item_matched_string (op, tmp, params)) |
912 | matched_objs.push_back (tmp); |
916 | matched_objs.push_back (tmp); |
913 | } |
917 | } |
914 | |
918 | |
915 | int cnt = MAX_ITEM_PER_DROP; |
919 | int cnt = MAX_ITEM_PER_ACTION; |
916 | |
920 | |
917 | if (!drop_vector (op, matched_objs, &cnt)) |
921 | if (!drop_vector (op, matched_objs, &cnt)) |
918 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
922 | new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); |
919 | |
923 | |
920 | if (cnt <= 0) |
924 | if (cnt <= 0) |
… | |
… | |
1172 | } |
1176 | } |
1173 | |
1177 | |
1174 | if (weight) |
1178 | if (weight) |
1175 | buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0); |
1179 | buf.printf ("%s %3.3f kg.\r", nrof > 1 ? "They weigh" : "It weighs", weight * (nrof ? nrof : 1) / 1000.0); |
1176 | |
1180 | |
|
|
1181 | if (flag [FLAG_STARTEQUIP]) |
|
|
1182 | buf << (nrof > 1 ? "They were" : "It was") |
|
|
1183 | << " given by a god and will vanish when dropped.\r"; |
|
|
1184 | |
1177 | if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) |
1185 | if (value && !flag [FLAG_STARTEQUIP] && !flag [FLAG_NO_PICK] && who) |
1178 | { |
1186 | { |
1179 | buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); |
1187 | buf.printf ("You reckon %s worth %s.\r", nrof > 1 ? "they are" : "it is", query_cost_string (this, who, F_TRUE | F_APPROX)); |
1180 | |
1188 | |
1181 | if (is_in_shop (who)) |
1189 | if (is_in_shop (who)) |