version 1.137 | | version 1.138 |
---|
| | |
/* | | /* |
* static char *rcsid_object_c = | | * static char *rcsid_object_c = |
* "$Id: object.c,v 1.137 2006/07/29 09:29:15 ryo_saeba Exp $"; | | * "$Id: object.c,v 1.138 2006/08/19 20:22:21 ryo_saeba Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
for (tmp=op->inv; tmp; tmp=tmp->below) | | for (tmp=op->inv; tmp; tmp=tmp->below) |
dump_object2(tmp); | | dump_object2(tmp); |
#endif | | #endif |
| | if (op->more) { |
| | strcat(errmsg, "more "); |
| | strcat(errmsg, ltostr10(op->more->count)); |
| | strcat(errmsg, "\n"); |
| | } |
| | if (op->head) { |
| | strcat(errmsg, "head "); |
| | strcat(errmsg, ltostr10(op->head->count)); |
| | strcat(errmsg, "\n"); |
| | } |
| | if (op->env) { |
| | strcat(errmsg, "env "); |
| | strcat(errmsg, ltostr10(op->env->count)); |
| | strcat(errmsg, "\n"); |
| | } |
strcat(errmsg,"end\n"); | | strcat(errmsg,"end\n"); |
} else { | | } else { |
strcat(errmsg,"Object "); | | strcat(errmsg,"Object "); |
| | |
} | | } |
return 0; | | return 0; |
} | | } |
| | |
| | /** |
| | * This just ensures specified object has its more parts correctly inserted in map. |
| | * The object *must* be on a map. |
| | * |
| | * Extracted from common/map.c:link_multipart_objects |
| | **/ |
| | void fix_multipart_object(object* tmp) |
| | { |
| | archetype *at; |
| | object *op, *last; |
| | |
| | if (!tmp->map) |
| | { |
| | LOG(llevError, "fix_multipart_object: not on a map!"); |
| | return; |
| | } |
| | |
| | /* already multipart - don't do anything more */ |
| | if (tmp->head || tmp->more) |
| | return; |
| | |
| | /* If there is nothing more to this object, this for loop |
| | * won't do anything. |
| | */ |
| | for (at = tmp->arch->more, last=tmp; at != NULL; at=at->more, last=op) { |
| | op = arch_to_object(at); |
| | |
| | /* update x,y coordinates */ |
| | op->x += tmp->x; |
| | op->y += tmp->y; |
| | op->head = tmp; |
| | op->map = tmp->map; |
| | last->more = op; |
| | if (tmp->name != op->name) { |
| | if (op->name) free_string(op->name); |
| | op->name = add_string(tmp->name); |
| | } |
| | if (tmp->title != op->title) { |
| | if (op->title) free_string(op->title); |
| | op->title = add_string(tmp->title); |
| | } |
| | /* we could link all the parts onto tmp, and then just |
| | * call insert_ob_in_map once, but the effect is the same, |
| | * as insert_ob_in_map will call itself with each part, and |
| | * the coding is simpler to just to it here with each part. |
| | */ |
| | insert_ob_in_map(op, op->map, tmp,INS_NO_MERGE|INS_ABOVE_FLOOR_ONLY|INS_NO_WALK_ON); |
| | } /* for at = tmp->arch->more */ |
| | } |