MCPcopy Create free account
hub / github.com/NetHack/NetHack / restobjchn

Function restobjchn

src/restore.c:230–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

228}
229
230staticfn struct obj *
231restobjchn(NHFILE *nhfp, boolean frozen)
232{
233 struct obj *otmp, *otmp2 = 0;
234 struct obj *first = (struct obj *) 0;
235 int buflen = 0;
236#ifndef SFCTOOL
237 boolean ghostly = (nhfp->ftype == NHF_BONESFILE);
238#endif
239
240 while (1) {
241 Sfi_int(nhfp, &buflen, "obj-obj_length");
242 if (buflen == -1)
243 break;
244
245 otmp = newobj();
246 assert(otmp != 0);
247 restobj(nhfp, otmp);
248 if (!first)
249 first = otmp;
250 else
251 otmp2->nobj = otmp;
252
253#ifndef SFCTOOL
254 if (ghostly) {
255 unsigned nid = next_ident();
256
257 add_id_mapping(otmp->o_id, nid);
258 otmp->o_id = nid;
259 }
260 if (ghostly && otmp->otyp == SLIME_MOLD)
261 ghostfruit(otmp);
262 /* Ghost levels get object age shifted from old player's clock
263 * to new player's clock. Assumption: new player arrived
264 * immediately after old player died.
265 */
266 if (ghostly && !frozen && !age_is_relative(otmp))
267 otmp->age = svm.moves - svo.omoves + otmp->age;
268#endif /* !SFCTOOL */
269
270 /* get contents of a container or statue */
271 if (Has_contents(otmp)) {
272 struct obj *otmp3;
273
274 otmp->cobj = restobjchn(nhfp, Is_IceBox(otmp));
275 /* restore container back pointers */
276 for (otmp3 = otmp->cobj; otmp3; otmp3 = otmp3->nobj)
277 otmp3->ocontainer = otmp;
278 }
279
280#ifndef SFCTOOL
281 if (otmp->bypass)
282 otmp->bypass = 0;
283 if (!ghostly) {
284 /* fix the pointers */
285 if (otmp->o_id == svc.context.victual.o_id)
286 svc.context.victual.piece = otmp;
287 if (otmp->o_id == svc.context.tin.o_id)

Callers 3

restmonchnFunction · 0.85
restgamestateFunction · 0.85
getlevFunction · 0.85

Calls 5

restobjFunction · 0.85
next_identFunction · 0.85
add_id_mappingFunction · 0.85
ghostfruitFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected