… | |
… | |
254 | { |
254 | { |
255 | if (inv->inv) |
255 | if (inv->inv) |
256 | sum_weight (inv); |
256 | sum_weight (inv); |
257 | sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); |
257 | sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); |
258 | } |
258 | } |
|
|
259 | |
259 | if (op->type == CONTAINER && op->stats.Str) |
260 | if (op->type == CONTAINER && op->stats.Str) |
260 | sum = (sum * (100 - op->stats.Str)) / 100; |
261 | sum = (sum * (100 - op->stats.Str)) / 100; |
|
|
262 | |
261 | if (op->carrying != sum) |
263 | if (op->carrying != sum) |
262 | op->carrying = sum; |
264 | op->carrying = sum; |
|
|
265 | |
263 | return sum; |
266 | return sum; |
264 | } |
267 | } |
265 | |
268 | |
266 | /** |
269 | /** |
267 | * Return the outermost environment object for a given object. |
270 | * Return the outermost environment object for a given object. |
… | |
… | |
836 | if (op->more != NULL) |
839 | if (op->more != NULL) |
837 | update_object (op->more, action); |
840 | update_object (op->more, action); |
838 | } |
841 | } |
839 | |
842 | |
840 | static unordered_vector<object *> mortals; |
843 | static unordered_vector<object *> mortals; |
841 | static std::vector<object *> freed; |
844 | static std::vector<object *, slice_allocator <object *> > freed; |
842 | |
845 | |
843 | void object::free_mortals () |
846 | void object::free_mortals () |
844 | { |
847 | { |
845 | for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();) |
848 | for (unordered_vector<object *>::iterator i = mortals.begin (); i != mortals.end ();) |
846 | if ((*i)->refcnt) |
849 | if ((*i)->refcnt) |
… | |
… | |
1222 | * This function goes through all objects below and including top, and |
1225 | * This function goes through all objects below and including top, and |
1223 | * merges op to the first matching object. |
1226 | * merges op to the first matching object. |
1224 | * If top is NULL, it is calculated. |
1227 | * If top is NULL, it is calculated. |
1225 | * Returns pointer to object if it succeded in the merge, otherwise NULL |
1228 | * Returns pointer to object if it succeded in the merge, otherwise NULL |
1226 | */ |
1229 | */ |
1227 | |
|
|
1228 | object * |
1230 | object * |
1229 | merge_ob (object *op, object *top) |
1231 | merge_ob (object *op, object *top) |
1230 | { |
1232 | { |
1231 | if (!op->nrof) |
1233 | if (!op->nrof) |
1232 | return 0; |
1234 | return 0; |
… | |
… | |
2857 | } |
2859 | } |
2858 | else |
2860 | else |
2859 | item = item->env; |
2861 | item = item->env; |
2860 | } |
2862 | } |
2861 | |
2863 | |
|
|
2864 | // return a suitable string describing an objetc in enough detail to find it |
|
|
2865 | const char * |
|
|
2866 | object::debug_desc (char *info) const |
|
|
2867 | { |
|
|
2868 | char info2[256 * 3]; |
|
|
2869 | char *p = info; |
|
|
2870 | |
|
|
2871 | p += snprintf (p, 256, "%d=\"%s%s%s\"", |
|
|
2872 | count, |
|
|
2873 | &name, |
|
|
2874 | title ? " " : "", |
|
|
2875 | title ? (const char *)title : ""); |
|
|
2876 | |
|
|
2877 | if (env) |
|
|
2878 | p += snprintf (p, 256, "(in %s)", env->debug_desc (info2)); |
|
|
2879 | |
|
|
2880 | if (map) |
|
|
2881 | p += snprintf (p, 256, "(on %s@%d+%d)", map->path, x, y); |
|
|
2882 | |
|
|
2883 | return info; |
|
|
2884 | } |
|
|
2885 | |
|
|
2886 | const char * |
|
|
2887 | object::debug_desc () const |
|
|
2888 | { |
|
|
2889 | static char info[256 * 3]; |
|
|
2890 | return debug_desc (info); |
|
|
2891 | } |
|
|
2892 | |