… | |
… | |
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 |
… | |
… | |
2344 | * Cf 0.91.3 - don't let WIZ's pick up anything - will likely cause |
2333 | * Cf 0.91.3 - don't let WIZ's pick up anything - will likely cause |
2345 | * core dumps if they do. |
2334 | * core dumps if they do. |
2346 | * |
2335 | * |
2347 | * Add a check so we can't pick up invisible objects (0.93.8) |
2336 | * Add a check so we can't pick up invisible objects (0.93.8) |
2348 | */ |
2337 | */ |
2349 | |
|
|
2350 | int |
2338 | int |
2351 | can_pick (const object *who, const object *item) |
2339 | can_pick (const object *who, const object *item) |
2352 | { |
2340 | { |
2353 | return /*QUERY_FLAG(who,FLAG_WIZ)|| */ |
2341 | return /*QUERY_FLAG(who,FLAG_WIZ)|| */ |
2354 | (item->weight > 0 && !QUERY_FLAG (item, FLAG_NO_PICK) && |
2342 | (item->weight > 0 && !QUERY_FLAG (item, FLAG_NO_PICK) && |
… | |
… | |
2612 | &name, |
2600 | &name, |
2613 | title ? "\",title:\"" : "", |
2601 | title ? "\",title:\"" : "", |
2614 | title ? (const char *)title : "", |
2602 | title ? (const char *)title : "", |
2615 | flag_desc (flagdesc, 512), type); |
2603 | flag_desc (flagdesc, 512), type); |
2616 | |
2604 | |
2617 | if (env) |
2605 | if (!this->flag[FLAG_REMOVED] && env) |
2618 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2606 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
2619 | |
2607 | |
2620 | if (map) |
2608 | if (map) |
2621 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2609 | p += snprintf (p, 256, "(on %s@%d+%d)", &map->path, x, y); |
2622 | |
2610 | |
… | |
… | |
2669 | old_container->flag [FLAG_APPLIED] = 0; |
2657 | old_container->flag [FLAG_APPLIED] = 0; |
2670 | container = 0; |
2658 | container = 0; |
2671 | |
2659 | |
2672 | esrv_update_item (UPD_FLAGS, this, old_container); |
2660 | esrv_update_item (UPD_FLAGS, this, old_container); |
2673 | new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); |
2661 | new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); |
|
|
2662 | play_sound (sound_find ("chest_close")); |
2674 | } |
2663 | } |
2675 | |
2664 | |
2676 | if (new_container) |
2665 | if (new_container) |
2677 | { |
2666 | { |
2678 | if (INVOKE_OBJECT (OPEN, new_container, ARG_OBJECT (this))) |
2667 | if (INVOKE_OBJECT (OPEN, new_container, ARG_OBJECT (this))) |
… | |
… | |
2694 | new_container->flag [FLAG_APPLIED] = 1; |
2683 | new_container->flag [FLAG_APPLIED] = 1; |
2695 | container = new_container; |
2684 | container = new_container; |
2696 | |
2685 | |
2697 | esrv_update_item (UPD_FLAGS, this, new_container); |
2686 | esrv_update_item (UPD_FLAGS, this, new_container); |
2698 | esrv_send_inventory (this, new_container); |
2687 | esrv_send_inventory (this, new_container); |
|
|
2688 | play_sound (sound_find ("chest_open")); |
2699 | } |
2689 | } |
2700 | } |
2690 | } |
2701 | |
2691 | |
2702 | object * |
2692 | object * |
2703 | object::force_find (const shstr name) |
2693 | object::force_find (const shstr name) |
… | |
… | |
2729 | force->flag [FLAG_APPLIED] = true; |
2719 | force->flag [FLAG_APPLIED] = true; |
2730 | |
2720 | |
2731 | insert (force); |
2721 | insert (force); |
2732 | } |
2722 | } |
2733 | |
2723 | |
|
|
2724 | void |
|
|
2725 | object::play_sound (faceidx sound) const |
|
|
2726 | { |
|
|
2727 | if (!sound) |
|
|
2728 | return; |
|
|
2729 | |
|
|
2730 | if (flag [FLAG_REMOVED]) |
|
|
2731 | return; |
|
|
2732 | |
|
|
2733 | if (env) |
|
|
2734 | { |
|
|
2735 | if (object *pl = in_player ()) |
|
|
2736 | pl->contr->play_sound (sound); |
|
|
2737 | } |
|
|
2738 | else |
|
|
2739 | map->play_sound (sound, x, y); |
|
|
2740 | } |
|
|
2741 | |