… | |
… | |
429 | } |
429 | } |
430 | |
430 | |
431 | /* |
431 | /* |
432 | * Sets the owner and sets the skill and exp pointers to owner's current |
432 | * Sets the owner and sets the skill and exp pointers to owner's current |
433 | * skill and experience objects. |
433 | * skill and experience objects. |
|
|
434 | * ACTUALLY NO! investigate! TODO |
434 | */ |
435 | */ |
435 | void |
436 | void |
436 | object::set_owner (object *owner) |
437 | object::set_owner (object *owner) |
437 | { |
438 | { |
|
|
439 | // allow objects which own objects |
438 | if (!owner) |
440 | if (owner) |
439 | return; |
|
|
440 | |
|
|
441 | /* next line added to allow objects which own objects */ |
|
|
442 | /* Add a check for ownercounts in here, as I got into an endless loop |
|
|
443 | * with the fireball owning a poison cloud which then owned the |
|
|
444 | * fireball. I believe that was caused by one of the objects getting |
|
|
445 | * freed and then another object replacing it. Since the ownercounts |
|
|
446 | * didn't match, this check is valid and I believe that cause is valid. |
|
|
447 | */ |
|
|
448 | while (owner->owner) |
441 | while (owner->owner) |
449 | owner = owner->owner; |
442 | owner = owner->owner; |
450 | |
443 | |
451 | this->owner = owner; |
444 | this->owner = owner; |
452 | } |
445 | } |
453 | |
446 | |
454 | int |
447 | int |
… | |
… | |
1663 | * be != op, if items are merged. -Tero |
1656 | * be != op, if items are merged. -Tero |
1664 | */ |
1657 | */ |
1665 | object * |
1658 | object * |
1666 | object::insert (object *op) |
1659 | object::insert (object *op) |
1667 | { |
1660 | { |
1668 | object *tmp, *otmp; |
|
|
1669 | |
|
|
1670 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1661 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1671 | op->remove (); |
1662 | op->remove (); |
1672 | |
1663 | |
1673 | if (op->more) |
1664 | if (op->more) |
1674 | { |
1665 | { |
… | |
… | |
1676 | return op; |
1667 | return op; |
1677 | } |
1668 | } |
1678 | |
1669 | |
1679 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1670 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1680 | CLEAR_FLAG (op, FLAG_REMOVED); |
1671 | CLEAR_FLAG (op, FLAG_REMOVED); |
|
|
1672 | |
1681 | if (op->nrof) |
1673 | if (op->nrof) |
1682 | { |
1674 | { |
1683 | for (tmp = inv; tmp != NULL; tmp = tmp->below) |
1675 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1684 | if (object::can_merge (tmp, op)) |
1676 | if (object::can_merge (tmp, op)) |
1685 | { |
1677 | { |
1686 | /* return the original object and remove inserted object |
1678 | /* return the original object and remove inserted object |
1687 | (client needs the original object) */ |
1679 | (client needs the original object) */ |
1688 | tmp->nrof += op->nrof; |
1680 | tmp->nrof += op->nrof; |
… | |
… | |
1707 | add_weight (this, op->weight * op->nrof); |
1699 | add_weight (this, op->weight * op->nrof); |
1708 | } |
1700 | } |
1709 | else |
1701 | else |
1710 | add_weight (this, (op->weight + op->carrying)); |
1702 | add_weight (this, (op->weight + op->carrying)); |
1711 | |
1703 | |
1712 | otmp = this->in_player (); |
1704 | if (object *otmp = this->in_player ()) |
1713 | if (otmp && otmp->contr) |
|
|
1714 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1705 | if (otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1715 | otmp->update_stats (); |
1706 | otmp->update_stats (); |
1716 | |
1707 | |
|
|
1708 | op->owner = 0; // its his/hers now. period. |
1717 | op->map = 0; |
1709 | op->map = 0; |
1718 | op->env = this; |
1710 | op->env = this; |
1719 | op->above = 0; |
1711 | op->above = 0; |
1720 | op->below = 0; |
1712 | op->below = 0; |
1721 | op->x = 0, op->y = 0; |
1713 | op->x = op->y = 0; |
1722 | |
1714 | |
1723 | /* reset the light list and los of the players on the map */ |
1715 | /* reset the light list and los of the players on the map */ |
1724 | if ((op->glow_radius != 0) && map) |
1716 | if (op->glow_radius && map) |
1725 | { |
1717 | { |
1726 | #ifdef DEBUG_LIGHTS |
1718 | #ifdef DEBUG_LIGHTS |
1727 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1719 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1728 | #endif /* DEBUG_LIGHTS */ |
1720 | #endif /* DEBUG_LIGHTS */ |
1729 | if (map->darkness) |
1721 | if (map->darkness) |
… | |
… | |
2600 | &name, |
2592 | &name, |
2601 | title ? "\",title:\"" : "", |
2593 | title ? "\",title:\"" : "", |
2602 | title ? (const char *)title : "", |
2594 | title ? (const char *)title : "", |
2603 | flag_desc (flagdesc, 512), type); |
2595 | flag_desc (flagdesc, 512), type); |
2604 | |
2596 | |
2605 | if (env) |
2597 | if (!this->flag[FLAG_REMOVED] && env) |
2606 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2598 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2607 | |
2599 | |
2608 | if (map) |
2600 | if (map) |
2609 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2601 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2610 | |
2602 | |