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.1.1.1 by root, Fri Feb 3 07:14:29 2006 UTC vs.
Revision 1.1.1.2 by elmex, Wed Feb 22 18:03:20 2006 UTC

1/* 1/*
2 * static char *rcsid_c_object_c = 2 * static char *rcsid_c_object_c =
3 * "$Id: c_object.c,v 1.1.1.1 2006/02/03 07:14:29 root Exp $"; 3 * "$Id: c_object.c,v 1.1.1.2 2006/02/22 18:03:20 elmex Exp $";
4 */ 4 */
5/* 5/*
6 CrossFire, A Multiplayer game for X-windows 6 CrossFire, A Multiplayer game for X-windows
7 7
8 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 8 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
810 810
811/* 811/*
812 * This function was part of drop, now is own function. 812 * This function was part of drop, now is own function.
813 * Player 'op' tries to put object 'tmp' into sack 'sack', 813 * Player 'op' tries to put object 'tmp' into sack 'sack',
814 * if nrof is non zero, then nrof objects is tried to put into sack. 814 * if nrof is non zero, then nrof objects is tried to put into sack.
815 * Note that the 'sack' in question can now be a transport,
816 * so this function isn't named very good anymore.
815 */ 817 */
816void put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof) 818void put_object_in_sack (object *op, object *sack, object *tmp, uint32 nrof)
817{ 819{
818 tag_t tmp_tag, tmp2_tag; 820 tag_t tmp_tag, tmp2_tag;
819 object *tmp2, *sack2; 821 object *tmp2, *sack2;
820 char buf[MAX_BUF]; 822 char buf[MAX_BUF];
821 823
822 if (sack==tmp) return; /* Can't put an object in itself */ 824 if (sack==tmp) return; /* Can't put an object in itself */
823 if (sack->type != CONTAINER) { 825 if (sack->type != CONTAINER && sack->type != TRANSPORT) {
824 new_draw_info_format(NDI_UNIQUE, 0,op, 826 new_draw_info_format(NDI_UNIQUE, 0,op,
825 "The %s is not a container.", query_name(sack)); 827 "The %s is not a container.", query_name(sack));
826 return; 828 return;
827 } 829 }
828 if (QUERY_FLAG(tmp,FLAG_STARTEQUIP)) { 830 if (QUERY_FLAG(tmp,FLAG_STARTEQUIP)) {
829 new_draw_info_format(NDI_UNIQUE, 0,op, 831 new_draw_info_format(NDI_UNIQUE, 0,op,
830 "You cannot put the %s in the container.", query_name(tmp)); 832 "You cannot put the %s in the %s.", query_name(tmp),
831 return; 833 query_name(sack));
834 return;
832 } 835 }
833 if (tmp->type == CONTAINER && tmp->inv) { 836 if (tmp->type == CONTAINER && tmp->inv) {
834 837
835 /* Eneq(@csd.uu.se): If the object to be dropped is a container 838 /* Eneq(@csd.uu.se): If the object to be dropped is a container
836 * we instead move the contents of that container into the active 839 * we instead move the contents of that container into the active
837 * container, this is only done if the object has something in it. 840 * container, this is only done if the object has something in it.
838 */ 841 */
839 sack2 = tmp; 842 sack2 = tmp;
840 new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.", 843 new_draw_info_format(NDI_UNIQUE, 0,op, "You move the items from %s into %s.",
841 query_name(tmp), query_name(op->container)); 844 query_name(tmp), query_name(sack));
842 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) { 845 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp) {
843 tmp = tmp2->below; 846 tmp = tmp2->below;
844 if (sack_can_hold(op, op->container, tmp2,tmp2->nrof)) 847 if ((sack->type == CONTAINER && sack_can_hold(op, op->container, tmp2,tmp2->nrof)) ||
848 (sack->type == TRANSPORT && transport_can_hold(sack, tmp2, tmp2->nrof))) {
845 put_object_in_sack (op, sack, tmp2, 0); 849 put_object_in_sack (op, sack, tmp2, 0);
846 else { 850 } else {
847 sprintf(buf,"Your %s fills up.", query_name(op->container)); 851 sprintf(buf,"Your %s fills up.", query_name(sack));
848 new_draw_info(NDI_UNIQUE, 0,op, buf); 852 new_draw_info(NDI_UNIQUE, 0,op, buf);
849 break; 853 break;
850 }
851 } 854 }
855 }
852 esrv_update_item (UPD_WEIGHT, op, sack2); 856 esrv_update_item (UPD_WEIGHT, op, sack2);
853 return; 857 return;
854 } 858 }
855 859
860 /* Don't worry about this for containers - our caller should have
861 * already checked this.
862 */
856 if (! sack_can_hold (op, sack, tmp,(nrof?nrof:tmp->nrof))) 863 if ((sack->type == CONTAINER) && !sack_can_hold (op, sack, tmp,(nrof?nrof:tmp->nrof)))
857 return; 864 return;
858 865
859 if(QUERY_FLAG(tmp, FLAG_APPLIED)) { 866 if(QUERY_FLAG(tmp, FLAG_APPLIED)) {
860 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE)) 867 if (apply_special (op, tmp, AP_UNAPPLY | AP_NO_MERGE))
861 return; 868 return;
862 } 869 }
863 870
864 /* we want to put some portion of the item into the container */ 871 /* we want to put some portion of the item into the container */
865 if (nrof && tmp->nrof != nrof) { 872 if (nrof && tmp->nrof != nrof) {
866 object *tmp2 = tmp; 873 object *tmp2 = tmp;
877 else /* this can proably be replaced with an update */ 884 else /* this can proably be replaced with an update */
878 esrv_send_item (op, tmp2); 885 esrv_send_item (op, tmp2);
879 } else 886 } else
880 remove_ob(tmp); 887 remove_ob(tmp);
881 888
882 sprintf(buf, "You put the %s in ", query_name(tmp)); 889 new_draw_info_format(NDI_UNIQUE, 0,op, "You put the %s in %s.",
883 strcat (buf, query_name(sack)); 890 query_name(tmp), query_name(sack));
884 strcat (buf, ".");
885 tmp_tag = tmp->count; 891 tmp_tag = tmp->count;
886 tmp2 = insert_ob_in_ob(tmp, sack); 892 tmp2 = insert_ob_in_ob(tmp, sack);
887 new_draw_info(NDI_UNIQUE, 0,op,buf);
888 fix_player(op); /* This is overkill, fix_player() is called somewhere */ 893 fix_player(op); /* This is overkill, fix_player() is called somewhere */
889 /* in object.c */ 894 /* in object.c */
890 895
891 /* If an object merged (and thus, different object), we need to 896 /* If an object merged (and thus, different object), we need to
892 * delete the original. 897 * delete the original.
893 */ 898 */
894 if (tmp2 != tmp) 899 if (tmp2 != tmp)
895 esrv_del_item (op->contr, tmp_tag); 900 esrv_del_item (op->contr, tmp_tag);
896 901
897 esrv_send_item (op, tmp2); 902 esrv_send_item (op, tmp2);
903
904 /* If a transport, need to update all the players in the transport
905 * the view of what is in it.
906 */
907 if (sack->type == TRANSPORT) {
908 for (tmp=sack->inv; tmp; tmp=tmp->below) {
909 if (tmp->type == PLAYER) tmp->contr->socket.update_look=1;
910 }
911 } else {
898 /* update the sacks weight */ 912 /* update the sacks weight */
899 esrv_update_item (UPD_WEIGHT, op, sack); 913 esrv_update_item (UPD_WEIGHT, op, sack);
914 }
900} 915}
901 916
902/* 917/*
903 * This function was part of drop, now is own function. 918 * This function was part of drop, now is own function.
904 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then 919 * Player 'op' tries to drop object 'tmp', if tmp is non zero, then
944 else 959 else
945 esrv_send_item (op, tmp2); 960 esrv_send_item (op, tmp2);
946 } 961 }
947 } else 962 } else
948 remove_ob (tmp); 963 remove_ob (tmp);
964
949 /* Lauwenmark: Handle for plugin drop event */ 965 /* Lauwenmark: Handle for plugin drop event */
950 if (execute_event(tmp, EVENT_DROP,op,NULL,NULL,SCRIPT_FIX_ALL)!= 0) 966 if (execute_event(tmp, EVENT_DROP,op,NULL,NULL,SCRIPT_FIX_ALL)!= 0)
951 return; 967 return;
952 968
953 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) { 969 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) {
1002 fix_player(op); /* This is overkill, fix_player() is called somewhere */ 1018 fix_player(op); /* This is overkill, fix_player() is called somewhere */
1003 /* in object.c */ 1019 /* in object.c */
1004 1020
1005 if (op->type == PLAYER) 1021 if (op->type == PLAYER)
1006 { 1022 {
1007 op->contr->socket.update_look = 1; 1023 op->contr->socket.update_look = 1;
1008/* esrv_send_item (op, tmp);*/
1009 /* Need to update the weight for the player */ 1024 /* Need to update the weight for the player */
1010 esrv_send_item (op, op); 1025 esrv_send_item (op, op);
1011 } 1026 }
1012} 1027}
1013 1028
1014void drop(object *op, object *tmp) 1029void drop(object *op, object *tmp)
1015{ 1030{
1775 if (params) { 1790 if (params) {
1776 /* Let's skip white spaces */ 1791 /* Let's skip white spaces */
1777 while(' '==*params) params++; 1792 while(' '==*params) params++;
1778 1793
1779 /* Checking the first part */ 1794 /* Checking the first part */
1780 if (itemnumber = atoi(params)) { 1795 if ((itemnumber = atoi(params))!=0) {
1781 for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below); 1796 for (item=op->inv; item && ((item->count != itemnumber) || item->invisible); item=item->below);
1782 if (!item) { 1797 if (!item) {
1783 new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item."); 1798 new_draw_info(NDI_UNIQUE,0,op,"Tried to rename an invalid item.");
1784 return 1; 1799 return 1;
1785 } 1800 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines