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

Function savemonchn

src/save.c:883–916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

881}
882
883staticfn void
884savemonchn(NHFILE *nhfp, struct monst *mtmp)
885{
886 struct monst *mtmp2;
887 int minusone = -1;
888
889 while (mtmp) {
890 mtmp2 = mtmp->nmon;
891 if (update_file(nhfp)) {
892 mtmp->mnum = monsndx(mtmp->data);
893 if (mtmp->ispriest)
894 forget_temple_entry(mtmp); /* EPRI() */
895 savemon(nhfp, mtmp);
896 }
897 if (mtmp->minvent)
898 saveobjchn(nhfp, &mtmp->minvent);
899 if (release_data(nhfp)) {
900 if (mtmp == svc.context.polearm.hitmon) {
901 svc.context.polearm.m_id = mtmp->m_id;
902 svc.context.polearm.hitmon = NULL;
903 }
904 if (mtmp == u.ustuck)
905 u.ustuck_mid = u.ustuck->m_id;
906 if (mtmp == u.usteed)
907 u.usteed_mid = u.usteed->m_id;
908 mtmp->nmon = NULL; /* nmon saved into mtmp2 */
909 dealloc_monst(mtmp);
910 }
911 mtmp = mtmp2;
912 }
913 if (update_file(nhfp)) {
914 Sfo_int(nhfp, &minusone, "monst-monst_length");
915 }
916}
917
918/* save traps; gf.ftrap is the only trap chain so 2nd arg is superfluous */
919staticfn void

Callers 2

savegamestateFunction · 0.85
savelev_coreFunction · 0.85

Calls 5

update_fileFunction · 0.85
forget_temple_entryFunction · 0.85
savemonFunction · 0.85
saveobjchnFunction · 0.85
dealloc_monstFunction · 0.70

Tested by

no test coverage detected