… | |
… | |
1663 | * be != op, if items are merged. -Tero |
1663 | * be != op, if items are merged. -Tero |
1664 | */ |
1664 | */ |
1665 | object * |
1665 | object * |
1666 | object::insert (object *op) |
1666 | object::insert (object *op) |
1667 | { |
1667 | { |
1668 | object *tmp, *otmp; |
|
|
1669 | |
|
|
1670 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1668 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1671 | op->remove (); |
1669 | op->remove (); |
1672 | |
1670 | |
1673 | if (op->more) |
1671 | if (op->more) |
1674 | { |
1672 | { |
… | |
… | |
1676 | return op; |
1674 | return op; |
1677 | } |
1675 | } |
1678 | |
1676 | |
1679 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1677 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1680 | CLEAR_FLAG (op, FLAG_REMOVED); |
1678 | CLEAR_FLAG (op, FLAG_REMOVED); |
|
|
1679 | |
1681 | if (op->nrof) |
1680 | if (op->nrof) |
1682 | { |
1681 | { |
1683 | for (tmp = inv; tmp != NULL; tmp = tmp->below) |
1682 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1684 | if (object::can_merge (tmp, op)) |
1683 | if (object::can_merge (tmp, op)) |
1685 | { |
1684 | { |
1686 | /* return the original object and remove inserted object |
1685 | /* return the original object and remove inserted object |
1687 | (client needs the original object) */ |
1686 | (client needs the original object) */ |
1688 | tmp->nrof += op->nrof; |
1687 | tmp->nrof += op->nrof; |
… | |
… | |
1707 | add_weight (this, op->weight * op->nrof); |
1706 | add_weight (this, op->weight * op->nrof); |
1708 | } |
1707 | } |
1709 | else |
1708 | else |
1710 | add_weight (this, (op->weight + op->carrying)); |
1709 | add_weight (this, (op->weight + op->carrying)); |
1711 | |
1710 | |
1712 | otmp = this->in_player (); |
1711 | if (object *otmp = this->in_player ()) |
1713 | if (otmp && otmp->contr) |
|
|
1714 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1712 | if (otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1715 | otmp->update_stats (); |
1713 | otmp->update_stats (); |
1716 | |
1714 | |
|
|
1715 | op->owner = 0; // its his/hers now. period. |
1717 | op->map = 0; |
1716 | op->map = 0; |
1718 | op->env = this; |
1717 | op->env = this; |
1719 | op->above = 0; |
1718 | op->above = 0; |
1720 | op->below = 0; |
1719 | op->below = 0; |
1721 | op->x = 0, op->y = 0; |
1720 | op->x = op->y = 0; |
1722 | |
1721 | |
1723 | /* reset the light list and los of the players on the map */ |
1722 | /* reset the light list and los of the players on the map */ |
1724 | if ((op->glow_radius != 0) && map) |
1723 | if (op->glow_radius && map) |
1725 | { |
1724 | { |
1726 | #ifdef DEBUG_LIGHTS |
1725 | #ifdef DEBUG_LIGHTS |
1727 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1726 | LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); |
1728 | #endif /* DEBUG_LIGHTS */ |
1727 | #endif /* DEBUG_LIGHTS */ |
1729 | if (map->darkness) |
1728 | if (map->darkness) |