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.177 by root, Sun Aug 12 13:10:00 2007 UTC vs.
Revision 1.182 by root, Mon Aug 20 18:11:02 2007 UTC

1238 1238
1239 object *top, *floor = NULL; 1239 object *top, *floor = NULL;
1240 1240
1241 op->remove (); 1241 op->remove ();
1242 1242
1243#if 0
1244 if (!m->active != !op->active)
1245 if (m->active)
1246 op->activate_recursive ();
1247 else
1248 op->deactivate_recursive ();
1249#endif
1250
1251 if (out_of_map (m, op->x, op->y)) 1243 if (out_of_map (m, op->x, op->y))
1252 { 1244 {
1253 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ()); 1245 LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ());
1254#ifdef MANY_CORES 1246#ifdef MANY_CORES
1255 /* Better to catch this here, as otherwise the next use of this object 1247 /* Better to catch this here, as otherwise the next use of this object
1421 op->map->touch (); 1413 op->map->touch ();
1422 } 1414 }
1423 1415
1424 op->map->dirty = true; 1416 op->map->dirty = true;
1425 1417
1426 /* If we have a floor, we know the player, if any, will be above
1427 * it, so save a few ticks and start from there.
1428 */
1429 if (!(flag & INS_MAP_LOAD)) 1418 if (!(flag & INS_MAP_LOAD))
1430 if (object *pl = ms.player ()) 1419 if (object *pl = ms.player ())
1431 pl->contr->ns->floorbox_update (); 1420 pl->contr->ns->floorbox_update ();
1432 1421
1433 /* If this object glows, it may affect lighting conditions that are 1422 /* If this object glows, it may affect lighting conditions that are
1674 * be != op, if items are merged. -Tero 1663 * be != op, if items are merged. -Tero
1675 */ 1664 */
1676object * 1665object *
1677object::insert (object *op) 1666object::insert (object *op)
1678{ 1667{
1679 object *tmp, *otmp;
1680
1681 if (!QUERY_FLAG (op, FLAG_REMOVED)) 1668 if (!QUERY_FLAG (op, FLAG_REMOVED))
1682 op->remove (); 1669 op->remove ();
1683 1670
1684 if (op->more) 1671 if (op->more)
1685 { 1672 {
1687 return op; 1674 return op;
1688 } 1675 }
1689 1676
1690 CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); 1677 CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL);
1691 CLEAR_FLAG (op, FLAG_REMOVED); 1678 CLEAR_FLAG (op, FLAG_REMOVED);
1679
1692 if (op->nrof) 1680 if (op->nrof)
1693 { 1681 {
1694 for (tmp = inv; tmp != NULL; tmp = tmp->below) 1682 for (object *tmp = inv; tmp; tmp = tmp->below)
1695 if (object::can_merge (tmp, op)) 1683 if (object::can_merge (tmp, op))
1696 { 1684 {
1697 /* return the original object and remove inserted object 1685 /* return the original object and remove inserted object
1698 (client needs the original object) */ 1686 (client needs the original object) */
1699 tmp->nrof += op->nrof; 1687 tmp->nrof += op->nrof;
1718 add_weight (this, op->weight * op->nrof); 1706 add_weight (this, op->weight * op->nrof);
1719 } 1707 }
1720 else 1708 else
1721 add_weight (this, (op->weight + op->carrying)); 1709 add_weight (this, (op->weight + op->carrying));
1722 1710
1723 otmp = this->in_player (); 1711 if (object *otmp = this->in_player ())
1724 if (otmp && otmp->contr)
1725 if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) 1712 if (otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER))
1726 otmp->update_stats (); 1713 otmp->update_stats ();
1727 1714
1715 op->owner = 0; // its his/hers now. period.
1728 op->map = 0; 1716 op->map = 0;
1729 op->env = this; 1717 op->env = this;
1730 op->above = 0; 1718 op->above = 0;
1731 op->below = 0; 1719 op->below = 0;
1732 op->x = 0, op->y = 0; 1720 op->x = op->y = 0;
1733 1721
1734 /* 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 */
1735 if ((op->glow_radius != 0) && map) 1723 if (op->glow_radius && map)
1736 { 1724 {
1737#ifdef DEBUG_LIGHTS 1725#ifdef DEBUG_LIGHTS
1738 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);
1739#endif /* DEBUG_LIGHTS */ 1727#endif /* DEBUG_LIGHTS */
1740 if (map->darkness) 1728 if (map->darkness)
2611 &name, 2599 &name,
2612 title ? "\",title:\"" : "", 2600 title ? "\",title:\"" : "",
2613 title ? (const char *)title : "", 2601 title ? (const char *)title : "",
2614 flag_desc (flagdesc, 512), type); 2602 flag_desc (flagdesc, 512), type);
2615 2603
2616 if (env) 2604 if (!this->flag[FLAG_REMOVED] && env)
2617 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); 2605 p += snprintf (p, 256, "(in %s)", env->debug_desc (info2));
2618 2606
2619 if (map) 2607 if (map)
2620 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); 2608 p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y);
2621 2609
2730 force->flag [FLAG_APPLIED] = true; 2718 force->flag [FLAG_APPLIED] = true;
2731 2719
2732 insert (force); 2720 insert (force);
2733} 2721}
2734 2722
2723void
2724object::play_sound (faceidx sound) const
2725{
2726 if (!sound)
2727 return;
2728
2729 if (flag [FLAG_REMOVED])
2730 return;
2731
2732 if (env)
2733 {
2734 if (object *pl = in_player ())
2735 pl->contr->play_sound (sound);
2736 }
2737 else
2738 map->play_sound (sound, x, y);
2739}
2740

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines