… | |
… | |
911 | * object will have no environment. If the object previously had an |
911 | * object will have no environment. If the object previously had an |
912 | * environment, the x and y coordinates will be updated to |
912 | * environment, the x and y coordinates will be updated to |
913 | * the previous environment. |
913 | * the previous environment. |
914 | */ |
914 | */ |
915 | void |
915 | void |
916 | object::remove_slow () |
916 | object::do_remove () |
917 | { |
917 | { |
918 | object *tmp, *last = 0; |
918 | object *tmp, *last = 0; |
919 | object *otmp; |
919 | object *otmp; |
920 | |
920 | |
921 | if (QUERY_FLAG (this, FLAG_REMOVED)) |
921 | if (QUERY_FLAG (this, FLAG_REMOVED)) |
… | |
… | |
964 | } |
964 | } |
965 | else if (map) |
965 | else if (map) |
966 | { |
966 | { |
967 | if (type == PLAYER) |
967 | if (type == PLAYER) |
968 | { |
968 | { |
|
|
969 | // leaving a spot always closes any open container on the ground |
|
|
970 | if (container && !container->env) |
|
|
971 | // this causes spurious floorbox updates, but it ensures |
|
|
972 | // that the CLOSE event is being sent. |
|
|
973 | close_container (); |
|
|
974 | |
969 | --map->players; |
975 | --map->players; |
970 | map->touch (); |
976 | map->touch (); |
971 | } |
977 | } |
972 | |
978 | |
973 | map->dirty = true; |
979 | map->dirty = true; |
… | |
… | |
2578 | { |
2584 | { |
2579 | char flagdesc[512]; |
2585 | char flagdesc[512]; |
2580 | char info2[256 * 4]; |
2586 | char info2[256 * 4]; |
2581 | char *p = info; |
2587 | char *p = info; |
2582 | |
2588 | |
2583 | p += snprintf (p, 512, "{cnt:%d,uuid:<1,%" PRIx64 ">,name:\"%s\"%s%s,flags:[%s],type:%d}", |
2589 | p += snprintf (p, 512, "{cnt:%d,uuid:<1.%" PRIx64 ">,name:\"%s\"%s%s,flags:[%s],type:%d}", |
2584 | count, uuid.seq, |
2590 | count, uuid.seq, |
2585 | &name, |
2591 | &name, |
2586 | title ? "\",title:\"" : "", |
2592 | title ? "\",title:\"" : "", |
2587 | title ? (const char *)title : "", |
2593 | title ? (const char *)title : "", |
2588 | flag_desc (flagdesc, 512), type); |
2594 | flag_desc (flagdesc, 512), type); |
… | |
… | |
2615 | { |
2621 | { |
2616 | return map ? map->region (x, y) |
2622 | return map ? map->region (x, y) |
2617 | : region::default_region (); |
2623 | : region::default_region (); |
2618 | } |
2624 | } |
2619 | |
2625 | |
|
|
2626 | const materialtype_t * |
|
|
2627 | object::dominant_material () const |
|
|
2628 | { |
|
|
2629 | if (materialtype_t *mat = name_to_material (materialname)) |
|
|
2630 | return mat; |
|
|
2631 | |
|
|
2632 | // omfg this is slow, this has to be temporary :) |
|
|
2633 | shstr unknown ("unknown"); |
|
|
2634 | |
|
|
2635 | return name_to_material (unknown); |
|
|
2636 | } |
|
|
2637 | |
|
|
2638 | void |
|
|
2639 | object::open_container (object *new_container) |
|
|
2640 | { |
|
|
2641 | if (container == new_container) |
|
|
2642 | return; |
|
|
2643 | |
|
|
2644 | if (object *old_container = container) |
|
|
2645 | { |
|
|
2646 | if (INVOKE_OBJECT (CLOSE, old_container, ARG_OBJECT (this))) |
|
|
2647 | return; |
|
|
2648 | |
|
|
2649 | #if 0 |
|
|
2650 | // remove the "Close old_container" object. |
|
|
2651 | if (object *closer = old_container->inv) |
|
|
2652 | if (closer->type == CLOSE_CON) |
|
|
2653 | closer->destroy (); |
|
|
2654 | #endif |
|
|
2655 | |
|
|
2656 | old_container->flag [FLAG_APPLIED] = 0; |
|
|
2657 | container = 0; |
|
|
2658 | |
|
|
2659 | esrv_update_item (UPD_FLAGS, this, old_container); |
|
|
2660 | new_draw_info_format (NDI_UNIQUE, 0, this, "You close %s.", query_name (old_container)); |
|
|
2661 | } |
|
|
2662 | |
|
|
2663 | if (new_container) |
|
|
2664 | { |
|
|
2665 | if (INVOKE_OBJECT (OPEN, new_container, ARG_OBJECT (this))) |
|
|
2666 | return; |
|
|
2667 | |
|
|
2668 | // TODO: this does not seem to serve any purpose anymore? |
|
|
2669 | #if 0 |
|
|
2670 | // insert the "Close Container" object. |
|
|
2671 | if (archetype *closer = new_container->other_arch) |
|
|
2672 | { |
|
|
2673 | object *closer = arch_to_object (new_container->other_arch); |
|
|
2674 | closer->flag [FLAG_NO_MAP_SAVE] = 1; |
|
|
2675 | new_container->insert (closer); |
|
|
2676 | } |
|
|
2677 | #endif |
|
|
2678 | |
|
|
2679 | new_draw_info_format (NDI_UNIQUE, 0, this, "You open %s.", query_name (new_container)); |
|
|
2680 | |
|
|
2681 | new_container->flag [FLAG_APPLIED] = 1; |
|
|
2682 | container = new_container; |
|
|
2683 | |
|
|
2684 | esrv_update_item (UPD_FLAGS, this, new_container); |
|
|
2685 | esrv_send_inventory (this, new_container); |
|
|
2686 | } |
|
|
2687 | } |
|
|
2688 | |
|
|
2689 | |