MCPcopy Index your code
hub / github.com/NetHack/NetHack / restmon

Function restmon

src/restore.c:306–373  ·  view source on GitHub ↗

restore one monster */

Source from the content-addressed store, hash-verified

304
305/* restore one monster */
306staticfn void
307restmon(NHFILE *nhfp, struct monst *mtmp)
308{
309 int buflen = 0, mc = 0;
310
311 Sfi_monst(nhfp, mtmp, "monst");
312
313 /* next monster pointer is invalid */
314 mtmp->nmon = (struct monst *) 0;
315 /* non-null mextra needs to be reconstructed */
316 if (mtmp->mextra) {
317 mtmp->mextra = newmextra();
318
319 /* mgivenname - monster's name */
320 Sfi_int(nhfp, &buflen, "monst-mgivenname_length");
321 if (buflen > 0) { /* includes terminating '\0' */
322 new_mgivenname(mtmp, buflen);
323 Sfi_char(nhfp, MGIVENNAME(mtmp), "monst-mgivenname", (int) buflen);
324 }
325 /* egd - vault guard */
326 Sfi_int(nhfp, &buflen, "monst-egd_length");
327 if (buflen > 0) {
328 newegd(mtmp);
329 Sfi_egd(nhfp, EGD(mtmp), "monst-egd");
330 }
331 /* epri - temple priest */
332 Sfi_int(nhfp, &buflen, "monst-epri_length");
333 if (buflen > 0) {
334 newepri(mtmp);
335 Sfi_epri(nhfp, EPRI(mtmp), "monst-epri");
336 }
337 /* eshk - shopkeeper */
338 Sfi_int(nhfp, &buflen, "monst-eshk_length");
339 if (buflen > 0) {
340 neweshk(mtmp);
341 Sfi_eshk(nhfp, ESHK(mtmp), "monst-eshk");
342 }
343 /* emin - minion */
344 Sfi_int(nhfp, &buflen, "monst-emin_length");
345 if (buflen > 0) {
346 newemin(mtmp);
347 Sfi_emin(nhfp, EMIN(mtmp), "monst-emin");
348 }
349 /* edog - pet */
350 Sfi_int(nhfp, &buflen, "monst-edog_length");
351 if (buflen > 0) {
352 newedog(mtmp);
353 Sfi_edog(nhfp, EDOG(mtmp), "monst-edog");
354 /* save or bones held a relative time */
355 relative_time_to_moves(&EDOG(mtmp)->droptime);
356 relative_time_to_moves(&EDOG(mtmp)->hungrytime);
357 /* sanity check to prevent rn2(0) */
358 if (EDOG(mtmp)->apport <= 0) {
359 EDOG(mtmp)->apport = 1;
360 }
361 }
362 /* ebones */
363 Sfi_int(nhfp, &buflen, "monst-ebones_length");

Callers 2

restobjFunction · 0.85
restmonchnFunction · 0.85

Calls 9

relative_time_to_movesFunction · 0.85
newmextraFunction · 0.70
new_mgivennameFunction · 0.70
newegdFunction · 0.70
newepriFunction · 0.70
neweshkFunction · 0.70
neweminFunction · 0.70
newedogFunction · 0.70
newebonesFunction · 0.70

Tested by

no test coverage detected