| 48 | } |
| 49 | |
| 50 | staticfn void |
| 51 | resetobjs(struct obj *ochain, boolean restore) |
| 52 | { |
| 53 | struct obj *otmp, *nobj; |
| 54 | |
| 55 | for (otmp = ochain; otmp; otmp = nobj) { |
| 56 | nobj = otmp->nobj; |
| 57 | if (otmp->cobj) |
| 58 | resetobjs(otmp->cobj, restore); |
| 59 | if (otmp->in_use) { |
| 60 | obj_extract_self(otmp); |
| 61 | dealloc_obj(otmp); |
| 62 | continue; |
| 63 | } |
| 64 | |
| 65 | if (restore) { |
| 66 | /* artifact bookkeeping needs to be done during |
| 67 | restore; other fixups are done while saving */ |
| 68 | if (otmp->oartifact) { |
| 69 | if (exist_artifact(otmp->otyp, safe_oname(otmp)) |
| 70 | || is_quest_artifact(otmp)) { |
| 71 | /* prevent duplicate--revert to ordinary obj */ |
| 72 | otmp->oartifact = 0; |
| 73 | if (has_oname(otmp)) |
| 74 | free_oname(otmp); |
| 75 | } else { |
| 76 | artifact_exists(otmp, safe_oname(otmp), TRUE, |
| 77 | ONAME_BONES); |
| 78 | } |
| 79 | } else if (has_oname(otmp)) { |
| 80 | sanitize_name(ONAME(otmp)); |
| 81 | } |
| 82 | /* 3.6.3: set no_charge for partly eaten food in shop; |
| 83 | all other items become goods for sale if in a shop */ |
| 84 | if (otmp->oclass == FOOD_CLASS && otmp->oeaten) { |
| 85 | struct obj *top; |
| 86 | char *p; |
| 87 | coordxy ox, oy; |
| 88 | |
| 89 | for (top = otmp; top->where == OBJ_CONTAINED; |
| 90 | top = top->ocontainer) |
| 91 | continue; |
| 92 | otmp->no_charge = (top->where == OBJ_FLOOR |
| 93 | && get_obj_location(top, &ox, &oy, 0) |
| 94 | /* can't use costly_spot() since its |
| 95 | result depends upon hero's location */ |
| 96 | && inside_shop(ox, oy) |
| 97 | && *(p = in_rooms(ox, oy, SHOPBASE)) |
| 98 | && tended_shop(&svr.rooms[*p - ROOMOFFSET])); |
| 99 | } |
| 100 | } else { /* saving */ |
| 101 | /* do not zero out o_ids for ghost levels anymore */ |
| 102 | |
| 103 | if (objects[otmp->otyp].oc_uses_known) |
| 104 | otmp->known = 0; |
| 105 | otmp->dknown = otmp->bknown = 0; |
| 106 | otmp->rknown = 0; |
| 107 | otmp->lknown = 0; |
no test coverage detected