… | |
… | |
374 | /* |
374 | /* |
375 | * get_nearest_part(multi-object, object 2) returns the part of the |
375 | * get_nearest_part(multi-object, object 2) returns the part of the |
376 | * multi-object 1 which is closest to the second object. |
376 | * multi-object 1 which is closest to the second object. |
377 | * If it's not a multi-object, it is returned. |
377 | * If it's not a multi-object, it is returned. |
378 | */ |
378 | */ |
379 | |
|
|
380 | object * |
379 | object * |
381 | get_nearest_part (object *op, const object *pl) |
380 | get_nearest_part (object *op, const object *pl) |
382 | { |
381 | { |
383 | object *tmp, *closest; |
382 | object *tmp, *closest; |
384 | int last_dist, i; |
383 | int last_dist, i; |
… | |
… | |
429 | } |
428 | } |
430 | |
429 | |
431 | /* |
430 | /* |
432 | * Sets the owner and sets the skill and exp pointers to owner's current |
431 | * Sets the owner and sets the skill and exp pointers to owner's current |
433 | * skill and experience objects. |
432 | * skill and experience objects. |
|
|
433 | * ACTUALLY NO! investigate! TODO |
434 | */ |
434 | */ |
435 | void |
435 | void |
436 | object::set_owner (object *owner) |
436 | object::set_owner (object *owner) |
437 | { |
437 | { |
|
|
438 | // allow objects which own objects |
438 | if (!owner) |
439 | 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) |
440 | while (owner->owner) |
449 | owner = owner->owner; |
441 | owner = owner->owner; |
450 | |
442 | |
451 | this->owner = owner; |
443 | this->owner = owner; |
452 | } |
444 | } |
453 | |
445 | |
454 | int |
446 | int |
… | |
… | |
586 | object::copy_to (object *dst) |
578 | object::copy_to (object *dst) |
587 | { |
579 | { |
588 | *dst = *this; |
580 | *dst = *this; |
589 | |
581 | |
590 | if (speed < 0) |
582 | if (speed < 0) |
591 | dst->speed_left = speed_left - rndm (); |
583 | dst->speed_left -= rndm (); |
592 | |
584 | |
593 | dst->set_speed (dst->speed); |
585 | dst->set_speed (dst->speed); |
594 | } |
586 | } |
595 | |
587 | |
596 | void |
588 | void |
… | |
… | |
923 | |
915 | |
924 | if (!freed_map) |
916 | if (!freed_map) |
925 | { |
917 | { |
926 | freed_map = new maptile; |
918 | freed_map = new maptile; |
927 | |
919 | |
|
|
920 | freed_map->path = "<freed objects map>"; |
928 | freed_map->name = "/internal/freed_objects_map"; |
921 | freed_map->name = "/internal/freed_objects_map"; |
929 | freed_map->width = 3; |
922 | freed_map->width = 3; |
930 | freed_map->height = 3; |
923 | freed_map->height = 3; |
931 | |
924 | |
932 | freed_map->alloc (); |
925 | freed_map->alloc (); |
… | |
… | |
1413 | op->map->touch (); |
1406 | op->map->touch (); |
1414 | } |
1407 | } |
1415 | |
1408 | |
1416 | op->map->dirty = true; |
1409 | op->map->dirty = true; |
1417 | |
1410 | |
1418 | /* If we have a floor, we know the player, if any, will be above |
|
|
1419 | * it, so save a few ticks and start from there. |
|
|
1420 | */ |
|
|
1421 | if (!(flag & INS_MAP_LOAD)) |
1411 | if (!(flag & INS_MAP_LOAD)) |
1422 | if (object *pl = ms.player ()) |
1412 | if (object *pl = ms.player ()) |
1423 | pl->contr->ns->floorbox_update (); |
1413 | pl->contr->ns->floorbox_update (); |
1424 | |
1414 | |
1425 | /* If this object glows, it may affect lighting conditions that are |
1415 | /* If this object glows, it may affect lighting conditions that are |
… | |
… | |
1666 | * be != op, if items are merged. -Tero |
1656 | * be != op, if items are merged. -Tero |
1667 | */ |
1657 | */ |
1668 | object * |
1658 | object * |
1669 | object::insert (object *op) |
1659 | object::insert (object *op) |
1670 | { |
1660 | { |
1671 | object *tmp, *otmp; |
|
|
1672 | |
|
|
1673 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1661 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1674 | op->remove (); |
1662 | op->remove (); |
1675 | |
1663 | |
1676 | if (op->more) |
1664 | if (op->more) |
1677 | { |
1665 | { |
… | |
… | |
1679 | return op; |
1667 | return op; |
1680 | } |
1668 | } |
1681 | |
1669 | |
1682 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1670 | CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); |
1683 | CLEAR_FLAG (op, FLAG_REMOVED); |
1671 | CLEAR_FLAG (op, FLAG_REMOVED); |
|
|
1672 | |
1684 | if (op->nrof) |
1673 | if (op->nrof) |
1685 | { |
1674 | { |
1686 | for (tmp = inv; tmp != NULL; tmp = tmp->below) |
1675 | for (object *tmp = inv; tmp; tmp = tmp->below) |
1687 | if (object::can_merge (tmp, op)) |
1676 | if (object::can_merge (tmp, op)) |
1688 | { |
1677 | { |
1689 | /* return the original object and remove inserted object |
1678 | /* return the original object and remove inserted object |
1690 | (client needs the original object) */ |
1679 | (client needs the original object) */ |
1691 | tmp->nrof += op->nrof; |
1680 | tmp->nrof += op->nrof; |
… | |
… | |
1710 | add_weight (this, op->weight * op->nrof); |
1699 | add_weight (this, op->weight * op->nrof); |
1711 | } |
1700 | } |
1712 | else |
1701 | else |
1713 | add_weight (this, (op->weight + op->carrying)); |
1702 | add_weight (this, (op->weight + op->carrying)); |
1714 | |
1703 | |
1715 | otmp = this->in_player (); |
1704 | if (object *otmp = this->in_player ()) |
1716 | if (otmp && otmp->contr) |
|
|
1717 | if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1705 | if (otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) |
1718 | otmp->update_stats (); |
1706 | otmp->update_stats (); |
1719 | |
1707 | |
|
|
1708 | op->owner = 0; // its his/hers now. period. |
1720 | op->map = 0; |
1709 | op->map = 0; |
1721 | op->env = this; |
1710 | op->env = this; |
1722 | op->above = 0; |
1711 | op->above = 0; |
1723 | op->below = 0; |
1712 | op->below = 0; |
1724 | op->x = 0, op->y = 0; |
1713 | op->x = op->y = 0; |
1725 | |
1714 | |
1726 | /* 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 */ |
1727 | if ((op->glow_radius != 0) && map) |
1716 | if (op->glow_radius && map) |
1728 | { |
1717 | { |
1729 | #ifdef DEBUG_LIGHTS |
1718 | #ifdef DEBUG_LIGHTS |
1730 | 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); |
1731 | #endif /* DEBUG_LIGHTS */ |
1720 | #endif /* DEBUG_LIGHTS */ |
1732 | if (map->darkness) |
1721 | if (map->darkness) |
… | |
… | |
2603 | &name, |
2592 | &name, |
2604 | title ? "\",title:\"" : "", |
2593 | title ? "\",title:\"" : "", |
2605 | title ? (const char *)title : "", |
2594 | title ? (const char *)title : "", |
2606 | flag_desc (flagdesc, 512), type); |
2595 | flag_desc (flagdesc, 512), type); |
2607 | |
2596 | |
2608 | if (env) |
2597 | if (!this->flag[FLAG_REMOVED] && env) |
2609 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2598 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2610 | |
2599 | |
2611 | if (map) |
2600 | if (map) |
2612 | 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); |
2613 | |
2602 | |