--- deliantra/server/common/object.C 2007/08/01 20:44:11 1.172 +++ deliantra/server/common/object.C 2007/08/15 04:57:48 1.179 @@ -962,10 +962,11 @@ if (destroy_inventory) destroy_inv (false); - if (sound_destroy) - play_sound (sound_destroy); - else if (flag [FLAG_MONSTER]) - play_sound (sound_find ("monster_destroy")); // quick hack, too lazy to create a generic mechanism + if (is_head ()) + if (sound_destroy) + play_sound (sound_destroy); + else if (flag [FLAG_MONSTER]) + play_sound (sound_find ("monster_destroy")); // quick hack, too lazy to create a generic mechanism attachable::destroy (); } @@ -1090,28 +1091,24 @@ int check_walk_off = !flag [FLAG_NO_APPLY]; + if (object *pl = ms.player ()) + { + if (pl->container == this) + /* If a container that the player is currently using somehow gets + * removed (most likely destroyed), update the player view + * appropriately. + */ + 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. */ - if (tmp->type == PLAYER && tmp != this) - { - /* If a container that the player is currently using somehow gets - * removed (most likely destroyed), update the player view - * appropriately. - */ - if (tmp->container == this) - { - flag [FLAG_APPLIED] = 0; - tmp->container = 0; - } - - if (tmp->contr->ns) - tmp->contr->ns->floorbox_update (); - } - /* See if object moving off should effect something */ if (check_walk_off && ((move_type & tmp->move_off) @@ -1243,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 ()); @@ -1431,8 +1420,7 @@ */ 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 @@ -2350,7 +2338,6 @@ * * Add a check so we can't pick up invisible objects (0.93.8) */ - int can_pick (const object *who, const object *item) { @@ -2675,6 +2662,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) @@ -2700,6 +2688,7 @@ esrv_update_item (UPD_FLAGS, this, new_container); esrv_send_inventory (this, new_container); + play_sound (sound_find ("chest_open")); } } @@ -2735,3 +2724,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); +} +