--- deliantra/server/common/object.C 2007/08/08 04:52:59 1.174 +++ deliantra/server/common/object.C 2007/08/20 18:11:02 1.182 @@ -1091,18 +1091,23 @@ int check_walk_off = !flag [FLAG_NO_APPLY]; - for (tmp = ms.bot; tmp; tmp = tmp->above) + if (object *pl = ms.player ()) { - /* No point updating the players look faces if he is the object - * being removed. - */ - - if (tmp->type == PLAYER && tmp->container == this) + if (pl->container == this) /* If a container that the player is currently using somehow gets * removed (most likely destroyed), update the player view * appropriately. */ - tmp->close_container (); + pl->close_container (); + + pl->contr->ns->floorbox_update (); + } + + for (tmp = ms.bot; tmp; tmp = tmp->above) + { + /* No point updating the players look faces if he is the object + * being removed. + */ /* See if object moving off should effect something */ if (check_walk_off @@ -1235,14 +1240,6 @@ op->remove (); -#if 0 - if (!m->active != !op->active) - if (m->active) - op->activate_recursive (); - else - op->deactivate_recursive (); -#endif - if (out_of_map (m, op->x, op->y)) { LOG (llevError, "Trying to insert object outside the map.\n%s\n", op->debug_desc ()); @@ -1418,13 +1415,9 @@ op->map->dirty = true; - /* If we have a floor, we know the player, if any, will be above - * it, so save a few ticks and start from there. - */ if (!(flag & INS_MAP_LOAD)) if (object *pl = ms.player ()) - if (pl->contr->ns) - pl->contr->ns->floorbox_update (); + pl->contr->ns->floorbox_update (); /* If this object glows, it may affect lighting conditions that are * visible to others on this map. But update_all_los is really @@ -1672,8 +1665,6 @@ object * object::insert (object *op) { - object *tmp, *otmp; - if (!QUERY_FLAG (op, FLAG_REMOVED)) op->remove (); @@ -1685,9 +1676,10 @@ CLEAR_FLAG (op, FLAG_OBJ_ORIGINAL); CLEAR_FLAG (op, FLAG_REMOVED); + if (op->nrof) { - for (tmp = inv; tmp != NULL; tmp = tmp->below) + for (object *tmp = inv; tmp; tmp = tmp->below) if (object::can_merge (tmp, op)) { /* return the original object and remove inserted object @@ -1716,19 +1708,19 @@ else add_weight (this, (op->weight + op->carrying)); - otmp = this->in_player (); - if (otmp && otmp->contr) - if (!QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) + if (object *otmp = this->in_player ()) + if (otmp->contr && !QUERY_FLAG (otmp, FLAG_NO_FIX_PLAYER)) otmp->update_stats (); - op->map = 0; - op->env = this; + op->owner = 0; // its his/hers now. period. + op->map = 0; + op->env = this; op->above = 0; op->below = 0; - op->x = 0, op->y = 0; + op->x = op->y = 0; /* reset the light list and los of the players on the map */ - if ((op->glow_radius != 0) && map) + if (op->glow_radius && map) { #ifdef DEBUG_LIGHTS LOG (llevDebug, " insert_ob_in_ob(): got %s to insert in map/op\n", op->name); @@ -2342,7 +2334,6 @@ * * Add a check so we can't pick up invisible objects (0.93.8) */ - int can_pick (const object *who, const object *item) { @@ -2610,7 +2601,7 @@ title ? (const char *)title : "", flag_desc (flagdesc, 512), type); - if (env) + if (!this->flag[FLAG_REMOVED] && env) p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); if (map) @@ -2667,6 +2658,7 @@ esrv_update_item (UPD_FLAGS, this, old_container); new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); + play_sound (sound_find ("chest_close")); } if (new_container) @@ -2692,6 +2684,7 @@ esrv_update_item (UPD_FLAGS, this, new_container); esrv_send_inventory (this, new_container); + play_sound (sound_find ("chest_open")); } } @@ -2727,3 +2720,21 @@ insert (force); } +void +object::play_sound (faceidx sound) const +{ + if (!sound) + return; + + if (flag [FLAG_REMOVED]) + return; + + if (env) + { + if (object *pl = in_player ()) + pl->contr->play_sound (sound); + } + else + map->play_sound (sound, x, y); +} +