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

Comparing deliantra/server/server/c_object.C (file contents):
Revision 1.69 by root, Tue Apr 22 07:01:47 2008 UTC vs.
Revision 1.70 by root, Wed Apr 23 07:49:57 2008 UTC

580 if (!can_split (op, tmp, nrof)) 580 if (!can_split (op, tmp, nrof))
581 return; 581 return;
582 582
583 new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); 583 new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack));
584 sack->insert (tmp); 584 sack->insert (tmp);
585
586 // elmex: 2007-11-26: removed update_stats and replaced
587 // it by update_after_inventory_change () in the caller
588 // of this function
589} 585}
590 586
591/* 587/*
592 * This function was part of drop, now is own function. 588 * This function was part of drop, now is own function.
593 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then 589 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then
642 638
643 insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR); 639 insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR);
644} 640}
645 641
646void 642void
647update_after_inventory_change (object *op)
648{
649 /* Call this before we update the various windows/players. At least
650 * that we, we know the weight is correct.
651 */
652 op->update_stats ();
653
654 // elmex: kept this for now, i have no idea what happens when i remove it:
655 if (op->type == PLAYER)
656 {
657 /* Need to update the weight for the player */
658 esrv_send_item (op, op);
659 op->contr->ns->floorbox_update ();
660 }
661}
662
663void
664drop (object *op, object *tmp) 643drop (object *op, object *tmp)
665{ 644{
666 /* Hopeful fix for disappearing objects when dropping from a container - 645 /* Hopeful fix for disappearing objects when dropping from a container -
667 * somehow, players get an invisible object in the container, and the 646 * somehow, players get an invisible object in the container, and the
668 * old logic would skip over invisible objects - works fine for the 647 * old logic would skip over invisible objects - works fine for the
680 tmp->destroy (); 659 tmp->destroy ();
681 return; 660 return;
682 } 661 }
683 else 662 else
684 { 663 {
685 while (tmp != NULL && tmp->invisible) 664 while (tmp && tmp->invisible)
686 tmp = tmp->below; 665 tmp = tmp->below;
687 } 666 }
688 } 667 }
689 668
690 if (tmp == NULL) 669 if (tmp == NULL)
691 { 670 {
692 new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop."); 671 new_draw_info (NDI_UNIQUE, 0, op, "You don't have anything to drop.");
693 return; 672 return;
694 } 673 }
674
695 if (QUERY_FLAG (tmp, FLAG_INV_LOCKED)) 675 if (QUERY_FLAG (tmp, FLAG_INV_LOCKED))
696 { 676 {
697 new_draw_info (NDI_UNIQUE, 0, op, "This item is locked"); 677 new_draw_info (NDI_UNIQUE, 0, op, "This item is locked");
698 return; 678 return;
699 } 679 }
680
700 if (QUERY_FLAG (tmp, FLAG_NO_DROP)) 681 if (QUERY_FLAG (tmp, FLAG_NO_DROP))
701 { 682 {
702#if 0 683#if 0
703 /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */ 684 /* Eneq(@csd.uu.se): Objects with NO_DROP defined can't be dropped. */
704 new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); 685 new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped.");
728 709
729 if (op->type == PLAYER) 710 if (op->type == PLAYER)
730 op->contr->count = 0; 711 op->contr->count = 0;
731} 712}
732 713
733
734
735/* Command will drop all items that have not been locked */ 714/* Command will drop all items that have not been locked */
736int 715int
737command_dropall (object *op, char *params) 716command_dropall (object *op, char *params)
738{ 717{
739 718
740 object *curinv, *nextinv;
741
742 if (op->inv == NULL) 719 if (op->inv == NULL)
743 { 720 {
744 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!"); 721 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop!");
745 return 0; 722 return 0;
746 } 723 }
747 724
748 curinv = op->inv; 725 object *curinv = op->inv;
726 object *nextinv;
749 727
750 /* 728 /*
751 This is the default. Drops everything not locked or considered 729 This is the default. Drops everything not locked or considered
752 not something that should be dropped. 730 not something that should be dropped.
753 */ 731 */
757 in a shop. --Tero.Pelander@utu.fi 735 in a shop. --Tero.Pelander@utu.fi
758 */ 736 */
759 737
760 int cnt = MAX_ITEM_PER_DROP; 738 int cnt = MAX_ITEM_PER_DROP;
761 739
762 if (params == NULL) 740 if (!params)
763 { 741 {
764 while (curinv != NULL) 742 while (curinv)
765 { 743 {
766 nextinv = curinv->below; 744 nextinv = curinv->below;
745
767 while (nextinv && nextinv->type == MONEY) 746 while (nextinv && nextinv->type == MONEY)
768 nextinv = nextinv->below; 747 nextinv = nextinv->below;
748
769 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY && 749 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && curinv->type != MONEY &&
770 curinv->type != FOOD && curinv->type != KEY && 750 curinv->type != FOOD && curinv->type != KEY &&
771 curinv->type != SPECIAL_KEY && curinv->type != GEM && 751 curinv->type != SPECIAL_KEY && curinv->type != GEM &&
772 !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv)) 752 !curinv->invisible && (curinv->type != CONTAINER || op->container != curinv))
773 { 753 {
774 drop (op, curinv); 754 drop (op, curinv);
775 if (--cnt <= 0) break; 755 if (--cnt <= 0) break;
776 } 756 }
757
777 curinv = nextinv; 758 curinv = nextinv;
778 } 759 }
779 } 760 }
780
781 else if (strcmp (params, "weapons") == 0) 761 else if (strcmp (params, "weapons") == 0)
782 { 762 {
783 while (curinv != NULL) 763 while (curinv)
784 { 764 {
785 nextinv = curinv->below; 765 nextinv = curinv->below;
766
786 while (nextinv && nextinv->type == MONEY) 767 while (nextinv && nextinv->type == MONEY)
787 nextinv = nextinv->below; 768 nextinv = nextinv->below;
769
788 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW))) 770 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == WEAPON) || (curinv->type == BOW) || (curinv->type == ARROW)))
789 { 771 {
790 drop (op, curinv); 772 drop (op, curinv);
791 if (--cnt <= 0) break; 773 if (--cnt <= 0) break;
792 } 774 }
775
793 curinv = nextinv; 776 curinv = nextinv;
794 } 777 }
795 } 778 }
796
797 else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0) 779 else if (strcmp (params, "armor") == 0 || strcmp (params, "armour") == 0)
798 { 780 {
799 while (curinv != NULL) 781 while (curinv)
800 { 782 {
801 nextinv = curinv->below; 783 nextinv = curinv->below;
784
802 while (nextinv && nextinv->type == MONEY) 785 while (nextinv && nextinv->type == MONEY)
803 nextinv = nextinv->below; 786 nextinv = nextinv->below;
787
804 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET)) 788 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && ((curinv->type == ARMOUR) || curinv->type == SHIELD || curinv->type == HELMET))
805 { 789 {
806 drop (op, curinv); 790 drop (op, curinv);
807 if (--cnt <= 0) break; 791 if (--cnt <= 0) break;
808 } 792 }
793
809 curinv = nextinv; 794 curinv = nextinv;
810 } 795 }
811 } 796 }
812
813 else if (strcmp (params, "misc") == 0) 797 else if (strcmp (params, "misc") == 0)
814 { 798 {
815 while (curinv != NULL) 799 while (curinv)
816 { 800 {
817 nextinv = curinv->below; 801 nextinv = curinv->below;
802
818 while (nextinv && nextinv->type == MONEY) 803 while (nextinv && nextinv->type == MONEY)
819 nextinv = nextinv->below; 804 nextinv = nextinv->below;
805
820 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED)) 806 if (!QUERY_FLAG (curinv, FLAG_INV_LOCKED) && !QUERY_FLAG (curinv, FLAG_APPLIED))
821 { 807 {
822 switch (curinv->type) 808 switch (curinv->type)
823 { 809 {
824 case HORN: 810 case HORN:
842 break; 828 break;
843 default: 829 default:
844 curinv = nextinv; 830 curinv = nextinv;
845 break; 831 break;
846 } 832 }
833
847 if (--cnt <= 0) break; 834 if (--cnt <= 0) break;
848 } 835 }
836
849 curinv = nextinv; 837 curinv = nextinv;
850 } 838 }
851 } 839 }
852 840
853 if (cnt <= 0) 841 if (cnt <= 0)
854 op->failmsg ("Only dropped some items, can't drop that many items at once."); 842 op->failmsg ("Only dropped some items, can't drop that many items at once.");
855
856 update_after_inventory_change (op);
857 843
858/* draw_look(op);*/ 844/* draw_look(op);*/
859 return 0; 845 return 0;
860} 846}
861 847
862/* Object op wants to drop object(s) params. params can be a 848/* Object op wants to drop object(s) params. params can be a
863 * comma seperated list. 849 * comma seperated list.
864 */ 850 */
865
866int 851int
867command_drop (object *op, char *params) 852command_drop (object *op, char *params)
868{ 853{
869 object *tmp, *next; 854 object *tmp, *next;
870 int did_one = 0; 855 int did_one = 0;
895 if (!did_one) 880 if (!did_one)
896 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); 881 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop.");
897 882
898 if (cnt <= 0) 883 if (cnt <= 0)
899 op->failmsg ("Only dropped some items, can't drop that many items at once."); 884 op->failmsg ("Only dropped some items, can't drop that many items at once.");
900
901 update_after_inventory_change (op);
902 } 885 }
903 886
904 return 0; 887 return 0;
905} 888}
906 889

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines