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

Function makemap_remove_mons

src/wizcmds.c:109–150  ·  view source on GitHub ↗

get rid of the all the monsters on--or intimately involved with--current level; used when #wizmakemap destroys the level before replacing it */

Source from the content-addressed store, hash-verified

107/* get rid of the all the monsters on--or intimately involved with--current
108 level; used when #wizmakemap destroys the level before replacing it */
109void
110makemap_remove_mons(void)
111{
112 struct monst *mtmp, **mprev;
113
114 /* keep steed and other adjacent pets after releasing them
115 from traps, stopping eating, &c as if hero were ascending */
116 keepdogs(TRUE); /* (pets-only; normally we'd be using 'FALSE') */
117 /* get rid of all the monsters that didn't make it to 'mydogs' */
118 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
119 /* if already dead, dmonsfree(below) will get rid of it */
120 if (DEADMONSTER(mtmp))
121 continue;
122 makemap_unmakemon(mtmp, FALSE);
123 }
124 /* some monsters retain details of this level in mon->mextra; that
125 data becomes invalid when the level is replaced by a new one;
126 get rid of them now if migrating or already arrived elsewhere;
127 [when on their 'home' level, the previous loop got rid of them;
128 if they aren't actually migrating but have been placed on some
129 'away' level, such monsters are treated like the Wizard: kept
130 on migrating monsters list, scheduled to migrate back to their
131 present location instead of being saved with whatever level they
132 happen to be on; see keepdogs() and keep_mon_accessible(dog.c)] */
133 for (mprev = &gm.migrating_mons; (mtmp = *mprev) != 0; ) {
134 if (mtmp->mextra
135 && ((mtmp->isshk && on_level(&u.uz, &ESHK(mtmp)->shoplevel))
136 || (mtmp->ispriest && on_level(&u.uz, &EPRI(mtmp)->shrlevel))
137 || (mtmp->isgd && on_level(&u.uz, &EGD(mtmp)->gdlevel)))) {
138 *mprev = mtmp->nmon;
139 makemap_unmakemon(mtmp, TRUE);
140 } else {
141 mprev = &mtmp->nmon;
142 }
143 }
144 /* release dead and 'unmade' monsters */
145 dmonsfree();
146 if (fmon) {
147 impossible("makemap_remove_mons: 'fmon' did not get emptied?");
148 }
149 return;
150}
151
152DISABLE_WARNING_FORMAT_NONLITERAL
153

Callers 1

makemap_prepostFunction · 0.85

Calls 5

keepdogsFunction · 0.85
makemap_unmakemonFunction · 0.85
on_levelFunction · 0.85
dmonsfreeFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected