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.91 by elmex, Tue Dec 26 10:51:52 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
1110 * job preparing multi-part monsters 1120 * job preparing multi-part monsters
1111 */ 1121 */
1112object * 1122object *
1113insert_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)
1114{ 1124{
1115 object *tmp;
1116
1117 if (op->head)
1118 op = op->head;
1119
1120 for (tmp = op; tmp; tmp = tmp->more) 1125 for (object *tmp = op->head_ (); tmp; tmp = tmp->more)
1121 { 1126 {
1122 tmp->x = x + tmp->arch->clone.x; 1127 tmp->x = x + tmp->arch->clone.x;
1123 tmp->y = y + tmp->arch->clone.y; 1128 tmp->y = y + tmp->arch->clone.y;
1124 } 1129 }
1125 1130
1439 tmp1->x = op->x; 1444 tmp1->x = op->x;
1440 tmp1->y = op->y; 1445 tmp1->y = op->y;
1441 insert_ob_in_map (tmp1, op->map, op, 0); 1446 insert_ob_in_map (tmp1, op->map, op, 0);
1442} 1447}
1443 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
1444/* 1455/*
1445 * 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
1446 * is returned contains nr objects, and the remaining parts contains 1457 * is returned contains nr objects, and the remaining parts contains
1447 * 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).
1448 * On failure, NULL is returned, and the reason put into the 1459 * On failure, NULL is returned, and the reason put into the
1449 * global static errmsg array. 1460 * global static errmsg array.
1450 */ 1461 */
1451
1452object * 1462object *
1453get_split_ob (object *orig_ob, uint32 nr) 1463get_split_ob (object *orig_ob, uint32 nr)
1454{ 1464{
1455 object *newob; 1465 object *newob;
1456 int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0); 1466 int is_removed = (QUERY_FLAG (orig_ob, FLAG_REMOVED) != 0);
1720 * 1730 *
1721 * 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
1722 * 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
1723 * on top. 1733 * on top.
1724 */ 1734 */
1725
1726int 1735int
1727check_move_on (object *op, object *originator) 1736check_move_on (object *op, object *originator)
1728{ 1737{
1729 object *tmp; 1738 object *tmp;
1730 maptile *m = op->map; 1739 maptile *m = op->map;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines