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.25 by root, Tue Dec 12 21:39:57 2006 UTC vs.
Revision 1.33 by root, Tue Jan 2 11:08:36 2007 UTC

24*/ 24*/
25 25
26#include <global.h> 26#include <global.h>
27#include <loader.h> 27#include <loader.h>
28#include <skills.h> 28#include <skills.h>
29#ifndef __CEXTRACT__
30# include <sproto.h> 29#include <sproto.h>
31#endif
32#include <living.h> 30#include <living.h>
33#include <math.h> 31#include <math.h>
34 32
35/* 33/*
36 * Object id parsing functions 34 * Object id parsing functions
259 /* IF the player is flying & trying to take the item out of a container 257 /* IF the player is flying & trying to take the item out of a container
260 * that is in his inventory, let him. tmp->env points to the container 258 * that is in his inventory, let him. tmp->env points to the container
261 * (sack, luggage, etc), tmp->env->env then points to the player (nested 259 * (sack, luggage, etc), tmp->env->env then points to the player (nested
262 * containers not allowed as of now) 260 * containers not allowed as of now)
263 */ 261 */
264 if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && is_player_inv (tmp) != pl) 262 if ((pl->move_type & MOVE_FLYING) && !QUERY_FLAG (pl, FLAG_WIZ) && tmp->in_player () != pl)
265 { 263 {
266 new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!"); 264 new_draw_info (NDI_UNIQUE, 0, pl, "You are levitating, you can't reach the ground!");
267 return; 265 return;
268 } 266 }
269 267
633 else 631 else
634 tmp->remove (); 632 tmp->remove ();
635 633
636 new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack)); 634 new_draw_info_format (NDI_UNIQUE, 0, op, "You put the %s in %s.", query_name (tmp), query_name (sack));
637 tmp2 = insert_ob_in_ob (tmp, sack); 635 tmp2 = insert_ob_in_ob (tmp, sack);
638 fix_player (op); /* This is overkill, fix_player() is called somewhere */ 636 op->update_stats (); /* This is overkill, fix_player() is called somewhere */
639 /* in object.c */ 637 /* in object.c */
640 638
641 /* If an object merged (and thus, different object), we need to 639 /* If an object merged (and thus, different object), we need to
642 * delete the original. 640 * delete the original.
643 */ 641 */
702 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 700 if (QUERY_FLAG (tmp, FLAG_STARTEQUIP))
703 { 701 {
704 sprintf (buf, "You drop the %s.", query_name (tmp)); 702 sprintf (buf, "You drop the %s.", query_name (tmp));
705 new_draw_info (NDI_UNIQUE, 0, op, buf); 703 new_draw_info (NDI_UNIQUE, 0, op, buf);
706 new_draw_info (NDI_UNIQUE, 0, op, "The gods who lent it to you retrieves it."); 704 new_draw_info (NDI_UNIQUE, 0, op, "The gods who lent it to you retrieves it.");
705
707 if (op->type == PLAYER) 706 if (op->type == PLAYER)
708 esrv_del_item (op->contr, tmp->count); 707 esrv_del_item (op->contr, tmp->count);
708
709 tmp->destroy (); 709 tmp->destroy ();
710 fix_player (op); 710 op->update_stats ();
711 return; 711 return;
712 } 712 }
713
714/* If SAVE_INTERVAL is commented out, we never want to save
715 * the player here.
716 */
717#ifdef SAVE_INTERVAL
718 /* I'm not sure why there is a value check - since the save
719 * is done every SAVE_INTERVAL seconds, why care the value
720 * of what he is dropping?
721 */
722 if (op->type == PLAYER && !QUERY_FLAG (tmp, FLAG_UNPAID) &&
723 (tmp->nrof ? tmp->value * tmp->nrof : tmp->value > 2000) && (op->contr->last_save_time + SAVE_INTERVAL) <= time (NULL))
724 {
725 save_player (op, 1);
726 op->contr->last_save_time = time (NULL);
727 }
728#endif /* SAVE_INTERVAL */
729 713
730 if (op->type == PLAYER) 714 if (op->type == PLAYER)
731 esrv_del_item (op->contr, tmp->count); 715 esrv_del_item (op->contr, tmp->count);
732 716
733 /* Call this before we update the various windows/players. At least 717 /* Call this before we update the various windows/players. At least
734 * that we, we know the weight is correct. 718 * that we, we know the weight is correct.
735 */ 719 */
736 fix_player (op); /* This is overkill, fix_player() is called somewhere */ 720 op->update_stats (); /* This is overkill, fix_player() is called somewhere */
737 /* in object.c */ 721 /* in object.c */
738 722
739 if (op->type == PLAYER) 723 if (op->type == PLAYER)
740 { 724 {
741 op->contr->socket.update_look = 1;
742 /* Need to update the weight for the player */ 725 /* Need to update the weight for the player */
743 esrv_send_item (op, op); 726 esrv_send_item (op, op);
727 op->contr->ns->floorbox_update ();
744 } 728 }
745 729
746 for (floor = get_map_ob (op->map, op->x, op->y); floor; floor = floor->above) 730 for (floor = GET_MAP_OB (op->map, op->x, op->y); floor; floor = floor->above)
747 if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op))) 731 if (INVOKE_OBJECT (DROP_ON, floor, ARG_OBJECT (tmp), ARG_OBJECT (op)))
748 return; 732 return;
749 733
750 if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY) 734 if (is_in_shop (op) && !QUERY_FLAG (tmp, FLAG_UNPAID) && tmp->type != MONEY)
751 sell_item (tmp, op); 735 sell_item (tmp, op);
800 new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped."); 784 new_draw_info (NDI_UNIQUE, 0, op, "This item can't be dropped.");
801#endif 785#endif
802 return; 786 return;
803 } 787 }
804 788
805 if (op->type == PLAYER) 789 if (op->type == PLAYER && op->contr->last_used == tmp)
806 { 790 op->contr->last_used = tmp->below ? tmp->below
807 if (op->contr->last_used == tmp && op->contr->last_used_id == tmp->count) 791 : tmp->above ? tmp->above
808 { 792 : 0;
809 object *n = NULL;
810
811 if (tmp->below != NULL)
812 n = tmp->below;
813 else if (tmp->above != NULL)
814 n = tmp->above;
815 op->contr->last_used = n;
816 if (n != NULL)
817 op->contr->last_used_id = n->count;
818 else
819 op->contr->last_used_id = 0;
820 }
821 };
822 793
823 if (op->container) 794 if (op->container)
824 { 795 {
825 if (op->type == PLAYER) 796 if (op->type == PLAYER)
826 {
827 put_object_in_sack (op, op->container, tmp, op->contr->count); 797 put_object_in_sack (op, op->container, tmp, op->contr->count);
828 }
829 else 798 else
830 {
831 put_object_in_sack (op, op->container, tmp, 0); 799 put_object_in_sack (op, op->container, tmp, 0);
832 };
833 } 800 }
834 else 801 else
835 { 802 {
836 if (op->type == PLAYER) 803 if (op->type == PLAYER)
837 {
838 drop_object (op, tmp, op->contr->count); 804 drop_object (op, tmp, op->contr->count);
839 }
840 else 805 else
841 {
842 drop_object (op, tmp, 0); 806 drop_object (op, tmp, 0);
843 };
844 } 807 }
808
845 if (op->type == PLAYER) 809 if (op->type == PLAYER)
846 op->contr->count = 0; 810 op->contr->count = 0;
847} 811}
848 812
849 813
957 } 921 }
958 } 922 }
959 curinv = nextinv; 923 curinv = nextinv;
960 } 924 }
961 } 925 }
962 op->contr->socket.update_look = 1; 926
927 op->contr->ns->floorbox_update ();
963 928
964/* draw_look(op);*/ 929/* draw_look(op);*/
965 return 0; 930 return 0;
966} 931}
967 932
997 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop."); 962 new_draw_info (NDI_UNIQUE, 0, op, "Nothing to drop.");
998 } 963 }
999 if (op->type == PLAYER) 964 if (op->type == PLAYER)
1000 { 965 {
1001 op->contr->count = 0; 966 op->contr->count = 0;
1002 op->contr->socket.update_look = 1; 967 op->contr->ns->floorbox_update ();
1003 }; 968 };
1004 969
1005/* draw_look(op);*/ 970/* draw_look(op);*/
1006 return 0; 971 return 0;
1007} 972}
1578 new_draw_info (NDI_UNIQUE, 0, op, "items containing the word 'magic+1'."); 1543 new_draw_info (NDI_UNIQUE, 0, op, "items containing the word 'magic+1'.");
1579 return 1; 1544 return 1;
1580 } 1545 }
1581 op->contr->search_str[0] = '\0'; 1546 op->contr->search_str[0] = '\0';
1582 new_draw_info (NDI_UNIQUE, 0, op, "Search mode turned off."); 1547 new_draw_info (NDI_UNIQUE, 0, op, "Search mode turned off.");
1583 fix_player (op); 1548 op->update_stats ();
1584 return 1; 1549 return 1;
1585 } 1550 }
1586 if ((int) strlen (params) >= MAX_BUF) 1551 if ((int) strlen (params) >= MAX_BUF)
1587 { 1552 {
1588 new_draw_info (NDI_UNIQUE, 0, op, "Search string too long."); 1553 new_draw_info (NDI_UNIQUE, 0, op, "Search string too long.");
1589 return 1; 1554 return 1;
1590 } 1555 }
1591 strcpy (op->contr->search_str, params); 1556 strcpy (op->contr->search_str, params);
1592 sprintf (buf, "Searching for '%s'.", op->contr->search_str); 1557 sprintf (buf, "Searching for '%s'.", op->contr->search_str);
1593 new_draw_info (NDI_UNIQUE, 0, op, buf); 1558 new_draw_info (NDI_UNIQUE, 0, op, buf);
1594 fix_player (op); 1559 op->update_stats ();
1595 return 1; 1560 return 1;
1596} 1561}
1597 1562

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines