version 1.105 | | version 1.106 |
---|
| | |
/* | | /* |
* static char *rcsid_object_c = | | * static char *rcsid_object_c = |
* "$Id: object.c,v 1.105 2005/10/07 19:41:48 qal21 Exp $"; | | * "$Id: object.c,v 1.106 2005/10/07 23:35:33 akirschbaum Exp $"; |
*/ | | */ |
| | |
/* | | /* |
| | |
* free objects. The IS_FREED() flag is set in the object. | | * free objects. The IS_FREED() flag is set in the object. |
* The object must have been removed by remove_ob() first for | | * The object must have been removed by remove_ob() first for |
* this function to succeed. | | * this function to succeed. |
| | * |
| | * If free_inventory is set, free inventory as well. Else drop items in |
| | * inventory to the ground. |
*/ | | */ |
| | |
void free_object(object *ob) { | | void free_object(object *ob) { |
| | free_object2(ob, 0); |
| | } |
| | void free_object2(object *ob, int free_inventory) { |
object *tmp,*op; | | object *tmp,*op; |
| | |
if (!QUERY_FLAG(ob,FLAG_REMOVED)) { | | if (!QUERY_FLAG(ob,FLAG_REMOVED)) { |
| | |
return; | | return; |
} | | } |
if(ob->more!=NULL) { | | if(ob->more!=NULL) { |
free_object(ob->more); | | free_object2(ob->more, free_inventory); |
ob->more=NULL; | | ob->more=NULL; |
} | | } |
if (ob->inv) { | | if (ob->inv) { |
if (ob->map==NULL || ob->map->in_memory!=MAP_IN_MEMORY || | | if (free_inventory || ob->map==NULL || ob->map->in_memory!=MAP_IN_MEMORY || |
(get_map_flags(ob->map, NULL, ob->x, ob->y, NULL, NULL) & P_NO_PASS)) | | (get_map_flags(ob->map, NULL, ob->x, ob->y, NULL, NULL) & P_NO_PASS)) |
{ | | { |
op=ob->inv; | | op=ob->inv; |
while(op!=NULL) { | | while(op!=NULL) { |
tmp=op->below; | | tmp=op->below; |
remove_ob(op); | | remove_ob(op); |
free_object(op); | | free_object2(op, free_inventory); |
op=tmp; | | op=tmp; |
} | | } |
} | | } |
| | |
if((orig_ob->nrof-=nr)<1) { | | if((orig_ob->nrof-=nr)<1) { |
if ( ! is_removed) | | if ( ! is_removed) |
remove_ob(orig_ob); | | remove_ob(orig_ob); |
free_object(orig_ob); | | free_object2(orig_ob, 1); |
} | | } |
else if ( ! is_removed) { | | else if ( ! is_removed) { |
if(orig_ob->env!=NULL) | | if(orig_ob->env!=NULL) |