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

Function findgd

src/vault.c:203–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201}
202
203struct monst *
204findgd(void)
205{
206 struct monst *mtmp, **mprev;
207
208 /* this might find a guard parked at <0,0> since it'll be on fmon list */
209 for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
210 if (mtmp->isgd && on_level(&EGD(mtmp)->gdlevel, &u.uz)) {
211 if (!mtmp->mx && !EGD(mtmp)->gddone)
212 mtmp->mhp = mtmp->mhpmax;
213 return mtmp;
214 }
215 }
216 /* if not on fmon, look for a guard waiting to migrate to this level */
217 for (mprev = &gm.migrating_mons; (mtmp = *mprev) != 0;
218 mprev = &mtmp->nmon) {
219 if (mtmp->isgd && on_level(&EGD(mtmp)->gdlevel, &u.uz)) {
220 /* take out of migrating_mons and place at <0,0>;
221 simplified mon_arrive(); avoid that because it would
222 send mtmp into limbo if no regular map spot is available */
223 *mprev = mtmp->nmon;
224 mtmp->nmon = fmon;
225 fmon = mtmp;
226 mon_track_clear(mtmp);
227 mtmp->mux = u.ux, mtmp->muy = u.uy;
228 mtmp->mx = mtmp->my = 0; /* not on map (note: mx is already 0) */
229 parkguard(mtmp);
230 return mtmp;
231 }
232 }
233 return (struct monst *) 0;
234}
235
236void
237vault_summon_gd(void)

Callers 6

teledsFunction · 0.85
vault_summon_gdFunction · 0.85
invaultFunction · 0.85
paygdFunction · 0.85
gd_soundFunction · 0.85
vault_gd_watchingFunction · 0.85

Calls 3

on_levelFunction · 0.85
mon_track_clearFunction · 0.85
parkguardFunction · 0.85

Tested by

no test coverage detected