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

Function restmonchn

src/restore.c:375–465  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

373}
374
375staticfn struct monst *
376restmonchn(NHFILE *nhfp)
377{
378 struct monst *mtmp, *mtmp2 = 0;
379 struct monst *first = (struct monst *) 0;
380 int buflen = 0;
381#ifndef SFCTOOL
382 int offset;
383 boolean ghostly = (nhfp->ftype == NHF_BONESFILE);
384#endif
385
386 while (1) {
387 Sfi_int(nhfp, &buflen, "monst-monst_length");
388 if (buflen == -1)
389 break;
390
391 mtmp = newmonst();
392 assert(mtmp != 0);
393 restmon(nhfp, mtmp);
394 if (!first)
395 first = mtmp;
396 else
397 mtmp2->nmon = mtmp;
398
399#ifndef SFCTOOL
400 if (ghostly) {
401 unsigned nid = next_ident();
402
403 add_id_mapping(mtmp->m_id, nid);
404 mtmp->m_id = nid;
405 }
406 offset = mtmp->mnum;
407 mtmp->data = &mons[offset];
408 if (ghostly) {
409 int mndx = (mtmp->cham == NON_PM) ? monsndx(mtmp->data)
410 : mtmp->cham;
411
412 if (propagate(mndx, TRUE, ghostly) == 0) {
413 /* cookie to trigger purge in getbones() */
414 mtmp->mhpmax = DEFUNCT_MONSTER;
415 }
416 }
417#endif /* !SFCTOOL */
418
419 if (mtmp->minvent) {
420 struct obj *obj;
421 mtmp->minvent = restobjchn(nhfp, FALSE);
422#ifndef SFCTOOL
423 /* restore monster back pointer */
424 for (obj = mtmp->minvent; obj; obj = obj->nobj)
425 obj->ocarry = mtmp;
426#else
427 nhUse(obj);
428#endif
429 }
430
431#ifndef SFCTOOL
432 if (mtmp->mw) {

Callers 2

restgamestateFunction · 0.85
getlevFunction · 0.85

Calls 8

restmonFunction · 0.85
next_identFunction · 0.85
add_id_mappingFunction · 0.85
propagateFunction · 0.85
restobjchnFunction · 0.85
restshkFunction · 0.85
restpriestFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected