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

Comparing deliantra/server/common/object.C (file contents):
Revision 1.90 by root, Tue Dec 26 10:14:24 2006 UTC vs.
Revision 1.95 by root, Wed Dec 27 05:42:08 2006 UTC

785 * object.c ? 785 * object.c ?
786 */ 786 */
787void 787void
788object::destroy_inv (bool drop_to_ground) 788object::destroy_inv (bool drop_to_ground)
789{ 789{
790 // need to check first, because the checks below might segfault
791 // as we might be on an invalid mapspace and crossfire code
792 // is too buggy to ensure that the inventory is empty.
793 // corollary: if you create arrows etc. with stuff in tis inventory,
794 // cf will crash below with off-map x and y
795 if (!inv)
796 return;
797
790 /* Only if the space blocks everything do we not process - 798 /* Only if the space blocks everything do we not process -
791 * if some form of movement is allowed, let objects 799 * if some form of movement is allowed, let objects
792 * drop on that space. 800 * drop on that space.
793 */ 801 */
794 if (!drop_to_ground || !map || map->in_memory != MAP_IN_MEMORY || GET_MAP_MOVE_BLOCK (map, x, y) == MOVE_ALL) 802 if (!drop_to_ground
803 || !map
804 || map->in_memory != MAP_IN_MEMORY
805 || ms ().move_block == MOVE_ALL)
795 { 806 {
796 while (inv) 807 while (inv)
808 {
809 inv->destroy_inv (drop_to_ground);
797 inv->destroy (); 810 inv->destroy ();
811 }
798 } 812 }
799 else 813 else
800 { /* Put objects in inventory onto this space */ 814 { /* Put objects in inventory onto this space */
801 while (inv) 815 while (inv)
802 { 816 {
807 || op->type == RUNE 821 || op->type == RUNE
808 || op->type == TRAP 822 || op->type == TRAP
809 || op->flag [FLAG_IS_A_TEMPLATE]) 823 || op->flag [FLAG_IS_A_TEMPLATE])
810 op->destroy (); 824 op->destroy ();
811 else 825 else
812 { 826 map->insert (op, x, y);
813 op->remove ();
814 op->x = x;
815 op->y = y;
816 insert_ob_in_map (op, map, 0, 0); /* Insert in same map as the envir */
817 }
818 } 827 }
819 } 828 }
820} 829}
821 830
822object *object::create () 831object *object::create ()
839 remove (); 848 remove ();
840 849
841 if (flag [FLAG_FREED]) 850 if (flag [FLAG_FREED])
842 return; 851 return;
843 852
853 set_speed (0);
854
844 flag [FLAG_FREED] = 1; 855 flag [FLAG_FREED] = 1;
845 856
846 attachable::do_destroy (); 857 attachable::do_destroy ();
847 858
848 destroy_inv (true); 859 destroy_inv (true);
849 set_speed (0);
850 unlink (); 860 unlink ();
851 861
852 // hack to ensure that freed objects still have a valid map 862 // hack to ensure that freed objects still have a valid map
853 { 863 {
854 static maptile *freed_map; // freed objects are moved here to avoid crashes 864 static maptile *freed_map; // freed objects are moved here to avoid crashes
1045 { 1055 {
1046 move_apply (tmp, this, 0); 1056 move_apply (tmp, this, 0);
1047 1057
1048 if (destroyed ()) 1058 if (destroyed ())
1049 LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ()); 1059 LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ());
1050 LOG (llevError, "BUG: remove_ob(): name %s, destroyed leaving object\n", tmp->debug_desc ());
1051 } 1060 }
1052 1061
1053 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */ 1062 /* Eneq(@csd.uu.se): Fixed this to skip tmp->above=tmp */
1054 1063
1055 if (tmp->above == tmp) 1064 if (tmp->above == tmp)
1111 * job preparing multi-part monsters 1120 * job preparing multi-part monsters
1112 */ 1121 */
1113object * 1122object *
1114insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y) 1123insert_ob_in_map_at (object *op, maptile *m, object *originator, int flag, int x, int y)
1115{ 1124{
1116 object *tmp;
1117
1118 if (op->head)
1119 op = op->head;
1120
1121 for (tmp = op; tmp; tmp = tmp->more) 1125 for (object *tmp = op->head_ (); tmp; tmp = tmp->more)
1122 { 1126 {
1123 tmp->x = x + tmp->arch->clone.x; 1127 tmp->x = x + tmp->arch->clone.x;
1124 tmp->y = y + tmp->arch->clone.y; 1128 tmp->y = y + tmp->arch->clone.y;
1125 } 1129 }
1126 1130
1440 tmp1->x = op->x; 1444 tmp1->x = op->x;
1441 tmp1->y = op->y; 1445 tmp1->y = op->y;
1442 insert_ob_in_map (tmp1, op->map, op, 0); 1446 insert_ob_in_map (tmp1, op->map, op, 0);
1443} 1447}
1444 1448
1449object *
1450object::insert_at (object *where, object *originator, int flags)
1451{
1452 where->map->insert (this, where->x, where->y, originator, flags);
1453}
1454
1445/* 1455/*
1446 * get_split_ob(ob,nr) splits up ob into two parts. The part which 1456 * get_split_ob(ob,nr) splits up ob into two parts. The part which
1447 * is returned contains nr objects, and the remaining parts contains 1457 * is returned contains nr objects, and the remaining parts contains
1448 * the rest (or is removed and freed if that number is 0). 1458 * the rest (or is removed and freed if that number is 0).
1449 * On failure, NULL is returned, and the reason put into the 1459 * On failure, NULL is returned, and the reason put into the
1450 * global static errmsg array. 1460 * global static errmsg array.
1451 */ 1461 */
1452
1453object * 1462object *
1454get_split_ob (object *orig_ob, uint32 nr) 1463get_split_ob (object *orig_ob, uint32 nr)
1455{ 1464{
1456 object *newob; 1465 object *newob;
1457 int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0); 1466 int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0);
1721 * 1730 *
1722 * MSW 2001-07-08: Check all objects on space, not just those below 1731 * MSW 2001-07-08: Check all objects on space, not just those below
1723 * object being inserted. insert_ob_in_map may not put new objects 1732 * object being inserted. insert_ob_in_map may not put new objects
1724 * on top. 1733 * on top.
1725 */ 1734 */
1726
1727int 1735int
1728check_move_on (object *op, object *originator) 1736check_move_on (object *op, object *originator)
1729{ 1737{
1730 object *tmp; 1738 object *tmp;
1731 maptile *m = op->map; 1739 maptile *m = op->map;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines