… | |
… | |
416 | */ |
416 | */ |
417 | |
417 | |
418 | object * |
418 | object * |
419 | find_object_name (const char *str) |
419 | find_object_name (const char *str) |
420 | { |
420 | { |
421 | const char *name = shstr::find (str); |
421 | shstr_cmp str_ (str); |
422 | object *op; |
422 | object *op; |
423 | |
423 | |
424 | for (op = objects; op != NULL; op = op->next) |
424 | for (op = objects; op != NULL; op = op->next) |
425 | if (&op->name == name) |
425 | if (op->name == str_) |
426 | break; |
426 | break; |
427 | |
427 | |
428 | return op; |
428 | return op; |
429 | } |
429 | } |
430 | |
430 | |
… | |
… | |
850 | freed.push_back (*i);//D |
850 | freed.push_back (*i);//D |
851 | //delete *i; |
851 | //delete *i; |
852 | mortals.erase (i); |
852 | mortals.erase (i); |
853 | } |
853 | } |
854 | |
854 | |
855 | if (mortals.size())//D |
855 | if (mortals.size() && 0)//D |
856 | LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D |
856 | LOG (llevDebug, "%d objects in mortal queue\n", mortals.size());//D |
857 | } |
857 | } |
858 | |
858 | |
859 | object::object () |
859 | object::object () |
860 | { |
860 | { |
… | |
… | |
2720 | * The returned string is shared. |
2720 | * The returned string is shared. |
2721 | */ |
2721 | */ |
2722 | const char * |
2722 | const char * |
2723 | get_ob_key_value (const object *op, const char *const key) |
2723 | get_ob_key_value (const object *op, const char *const key) |
2724 | { |
2724 | { |
2725 | key_value * |
2725 | key_value *link; |
2726 | link; |
2726 | shstr_cmp canonical_key (key); |
2727 | const char * |
|
|
2728 | canonical_key; |
|
|
2729 | |
2727 | |
2730 | canonical_key = shstr::find (key); |
|
|
2731 | |
|
|
2732 | if (canonical_key == NULL) |
2728 | if (!canonical_key) |
2733 | { |
2729 | { |
2734 | /* 1. There being a field named key on any object |
2730 | /* 1. There being a field named key on any object |
2735 | * implies there'd be a shared string to find. |
2731 | * implies there'd be a shared string to find. |
2736 | * 2. Since there isn't, no object has this field. |
2732 | * 2. Since there isn't, no object has this field. |
2737 | * 3. Therefore, *this* object doesn't have this field. |
2733 | * 3. Therefore, *this* object doesn't have this field. |
2738 | */ |
2734 | */ |
2739 | return NULL; |
2735 | return 0; |
2740 | } |
2736 | } |
2741 | |
2737 | |
2742 | /* This is copied from get_ob_key_link() above - |
2738 | /* This is copied from get_ob_key_link() above - |
2743 | * only 4 lines, and saves the function call overhead. |
2739 | * only 4 lines, and saves the function call overhead. |
2744 | */ |
2740 | */ |
2745 | for (link = op->key_values; link != NULL; link = link->next) |
2741 | for (link = op->key_values; link; link = link->next) |
2746 | { |
|
|
2747 | if (link->key == canonical_key) |
2742 | if (link->key == canonical_key) |
2748 | { |
|
|
2749 | return link->value; |
2743 | return link->value; |
2750 | } |
2744 | |
2751 | } |
|
|
2752 | return NULL; |
2745 | return 0; |
2753 | } |
2746 | } |
2754 | |
2747 | |
2755 | |
2748 | |
2756 | /* |
2749 | /* |
2757 | * Updates the canonical_key in op to value. |
2750 | * Updates the canonical_key in op to value. |
… | |
… | |
2864 | } |
2857 | } |
2865 | else |
2858 | else |
2866 | item = item->env; |
2859 | item = item->env; |
2867 | } |
2860 | } |
2868 | |
2861 | |
|
|
2862 | // return a suitable string describing an objetc in enough detail to find it |
|
|
2863 | const char * |
|
|
2864 | object::debug_desc (char *info) const |
|
|
2865 | { |
|
|
2866 | char info2[256 * 3]; |
|
|
2867 | char *p = info; |
|
|
2868 | |
|
|
2869 | p += snprintf (p, 256, "%d=\"%s%s%s\"", |
|
|
2870 | count, |
|
|
2871 | &name, |
|
|
2872 | title ? " " : "", |
|
|
2873 | title ? (const char *)title : ""); |
|
|
2874 | |
|
|
2875 | if (env) |
|
|
2876 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
|
|
2877 | |
|
|
2878 | if (map) |
|
|
2879 | p += snprintf (p, 256, "(on %s@%d+%d)", map->path, x, y); |
|
|
2880 | |
|
|
2881 | return info; |
|
|
2882 | } |
|
|
2883 | |
|
|
2884 | const char * |
|
|
2885 | object::debug_desc () const |
|
|
2886 | { |
|
|
2887 | static char info[256 * 3]; |
|
|
2888 | return debug_desc (info); |
|
|
2889 | } |
|
|
2890 | |