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.61 by root, Mon Dec 11 21:32:16 2006 UTC vs.
Revision 1.63 by root, Tue Dec 12 20:53:02 2006 UTC

909 909
910 if (QUERY_FLAG (this, FLAG_FRIENDLY)) 910 if (QUERY_FLAG (this, FLAG_FRIENDLY))
911 remove_friendly_object (this); 911 remove_friendly_object (this);
912 912
913 if (!QUERY_FLAG (this, FLAG_REMOVED)) 913 if (!QUERY_FLAG (this, FLAG_REMOVED))
914 remove_ob (this); 914 remove ();
915 915
916 SET_FLAG (this, FLAG_FREED); 916 SET_FLAG (this, FLAG_FREED);
917 917
918 if (more) 918 if (more)
919 { 919 {
944 944
945 while (op) 945 while (op)
946 { 946 {
947 object *tmp = op->below; 947 object *tmp = op->below;
948 948
949 remove_ob (op); 949 op->remove ();
950 950
951 if (QUERY_FLAG (op, FLAG_STARTEQUIP) 951 if (QUERY_FLAG (op, FLAG_STARTEQUIP)
952 || QUERY_FLAG (op, FLAG_NO_DROP) || op->type == RUNE || op->type == TRAP || QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 952 || QUERY_FLAG (op, FLAG_NO_DROP) || op->type == RUNE || op->type == TRAP || QUERY_FLAG (op, FLAG_IS_A_TEMPLATE))
953 free_object (op); 953 op->destroy (0);
954 else 954 else
955 { 955 {
956 op->x = x; 956 op->x = x;
957 op->y = y; 957 op->y = y;
958 insert_ob_in_map (op, map, 0, 0); /* Insert in same map as the envir */ 958 insert_ob_in_map (op, map, 0, 0); /* Insert in same map as the envir */
1015 op->carrying -= weight; 1015 op->carrying -= weight;
1016 op = op->env; 1016 op = op->env;
1017 } 1017 }
1018} 1018}
1019 1019
1020/* remove_ob(op): 1020/* op->remove ():
1021 * This function removes the object op from the linked list of objects 1021 * This function removes the object op from the linked list of objects
1022 * which it is currently tied to. When this function is done, the 1022 * which it is currently tied to. When this function is done, the
1023 * object will have no environment. If the object previously had an 1023 * object will have no environment. If the object previously had an
1024 * environment, the x and y coordinates will be updated to 1024 * environment, the x and y coordinates will be updated to
1025 * the previous environment. 1025 * the previous environment.
1203 { 1203 {
1204 top->nrof += op->nrof; 1204 top->nrof += op->nrof;
1205 1205
1206/* CLEAR_FLAG(top,FLAG_STARTEQUIP);*/ 1206/* CLEAR_FLAG(top,FLAG_STARTEQUIP);*/
1207 op->weight = 0; /* Don't want any adjustements now */ 1207 op->weight = 0; /* Don't want any adjustements now */
1208 remove_ob (op); 1208 op->remove ();
1209 free_object (op); 1209 op->destroy (0);
1210 return top; 1210 return top;
1211 } 1211 }
1212 } 1212 }
1213 1213
1214 return 0; 1214 return 0;
1344 if (op->nrof && !(flag & INS_NO_MERGE)) 1344 if (op->nrof && !(flag & INS_NO_MERGE))
1345 for (tmp = GET_MAP_OB (op->map, x, y); tmp != NULL; tmp = tmp->above) 1345 for (tmp = GET_MAP_OB (op->map, x, y); tmp != NULL; tmp = tmp->above)
1346 if (CAN_MERGE (op, tmp)) 1346 if (CAN_MERGE (op, tmp))
1347 { 1347 {
1348 op->nrof += tmp->nrof; 1348 op->nrof += tmp->nrof;
1349 remove_ob (tmp); 1349 tmp->remove ();
1350 free_object (tmp); 1350 tmp->destroy (0);
1351 } 1351 }
1352 1352
1353 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */ 1353 CLEAR_FLAG (op, FLAG_APPLIED); /* hack for fixing F_APPLIED in items of dead people */
1354 CLEAR_FLAG (op, FLAG_INV_LOCKED); 1354 CLEAR_FLAG (op, FLAG_INV_LOCKED);
1355 1355
1544 1544
1545 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1545 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
1546 { 1546 {
1547 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */ 1547 if (!strcmp (tmp->arch->name, arch_string)) /* same archetype */
1548 { 1548 {
1549 remove_ob (tmp); 1549 tmp->remove ();
1550 free_object (tmp); 1550 tmp->destroy (0);
1551 } 1551 }
1552 } 1552 }
1553 1553
1554 tmp1 = arch_to_object (archetype::find (arch_string)); 1554 tmp1 = arch_to_object (archetype::find (arch_string));
1555 1555
1581 } 1581 }
1582 1582
1583 newob = object_create_clone (orig_ob); 1583 newob = object_create_clone (orig_ob);
1584 1584
1585 if ((orig_ob->nrof -= nr) < 1) 1585 if ((orig_ob->nrof -= nr) < 1)
1586 { 1586 orig_ob->destroy (1);
1587 if (!is_removed)
1588 remove_ob (orig_ob);
1589 free_object2 (orig_ob, 1);
1590 }
1591 else if (!is_removed) 1587 else if (!is_removed)
1592 { 1588 {
1593 if (orig_ob->env != NULL) 1589 if (orig_ob->env != NULL)
1594 sub_weight (orig_ob->env, orig_ob->weight * nr); 1590 sub_weight (orig_ob->env, orig_ob->weight * nr);
1595 if (orig_ob->env == NULL && orig_ob->map->in_memory != MAP_IN_MEMORY) 1591 if (orig_ob->env == NULL && orig_ob->map->in_memory != MAP_IN_MEMORY)
1659 esrv_send_item (tmp, op); 1655 esrv_send_item (tmp, op);
1660 } 1656 }
1661 } 1657 }
1662 else 1658 else
1663 { 1659 {
1664 remove_ob (op); 1660 op->remove ();
1665 op->nrof = 0; 1661 op->nrof = 0;
1666 if (tmp) 1662 if (tmp)
1667 { 1663 {
1668 esrv_del_item (tmp->contr, op->count); 1664 esrv_del_item (tmp->contr, op->count);
1669 } 1665 }
1675 1671
1676 if (i < op->nrof) 1672 if (i < op->nrof)
1677 op->nrof -= i; 1673 op->nrof -= i;
1678 else 1674 else
1679 { 1675 {
1680 remove_ob (op); 1676 op->remove ();
1681 op->nrof = 0; 1677 op->nrof = 0;
1682 } 1678 }
1683 1679
1684 /* Since we just removed op, op->above is null */ 1680 /* Since we just removed op, op->above is null */
1685 for (tmp = above; tmp != NULL; tmp = tmp->above) 1681 for (tmp = above; tmp != NULL; tmp = tmp->above)
1694 1690
1695 if (op->nrof) 1691 if (op->nrof)
1696 return op; 1692 return op;
1697 else 1693 else
1698 { 1694 {
1699 free_object (op); 1695 op->destroy (0);
1700 return NULL; 1696 return NULL;
1701 } 1697 }
1702} 1698}
1703 1699
1704/* 1700/*
2524 * create clone from object to another 2520 * create clone from object to another
2525 */ 2521 */
2526object * 2522object *
2527object_create_clone (object *asrc) 2523object_create_clone (object *asrc)
2528{ 2524{
2529 object *
2530 dst = NULL, *tmp, *src, *part, *prev, *item; 2525 object *dst = 0, *tmp, *src, *part, *prev, *item;
2531 2526
2532 if (!asrc) 2527 if (!asrc)
2533 return NULL; 2528 return 0;
2529
2534 src = asrc; 2530 src = asrc;
2535 if (src->head) 2531 if (src->head)
2536 src = src->head; 2532 src = src->head;
2537 2533
2538 prev = NULL; 2534 prev = 0;
2539 for (part = src; part; part = part->more) 2535 for (part = src; part; part = part->more)
2540 { 2536 {
2541 tmp = get_object (); 2537 tmp = get_object ();
2542 copy_object (part, tmp); 2538 copy_object (part, tmp);
2543 tmp->x -= src->x; 2539 tmp->x -= src->x;
2544 tmp->y -= src->y; 2540 tmp->y -= src->y;
2541
2545 if (!part->head) 2542 if (!part->head)
2546 { 2543 {
2547 dst = tmp; 2544 dst = tmp;
2548 tmp->head = NULL; 2545 tmp->head = 0;
2549 } 2546 }
2550 else 2547 else
2551 { 2548 {
2552 tmp->head = dst; 2549 tmp->head = dst;
2553 } 2550 }
2551
2554 tmp->more = NULL; 2552 tmp->more = 0;
2553
2555 if (prev) 2554 if (prev)
2556 prev->more = tmp; 2555 prev->more = tmp;
2556
2557 prev = tmp; 2557 prev = tmp;
2558 } 2558 }
2559 2559
2560 for (item = src->inv; item; item = item->below) 2560 for (item = src->inv; item; item = item->below)
2561 insert_ob_in_ob (object_create_clone (item), dst); 2561 insert_ob_in_ob (object_create_clone (item), dst);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines