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

Function put_lregion_here

src/mkmaze.c:412–469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

410}
411
412staticfn boolean
413put_lregion_here(
414 coordxy x, coordxy y,
415 coordxy nlx, coordxy nly, coordxy nhx, coordxy nhy,
416 xint16 rtype,
417 boolean oneshot,
418 d_level *lev)
419{
420 struct monst *mtmp;
421
422 if (bad_location(x, y, nlx, nly, nhx, nhy)
423 || is_exclusion_zone(rtype, x, y)) {
424 if (!oneshot) {
425 return FALSE; /* caller should try again */
426 } else {
427 /* Must make do with the only location possible;
428 avoid failure due to a misplaced trap.
429 It might still fail if there's a dungeon feature here. */
430 struct trap *t = t_at(x, y);
431
432 if (t && !undestroyable_trap(t->ttyp)) {
433 if (((mtmp = m_at(x, y)) != 0) && mtmp->mtrapped)
434 mtmp->mtrapped = 0;
435 deltrap(t);
436 }
437 if (bad_location(x, y, nlx, nly, nhx, nhy)
438 || is_exclusion_zone(rtype, x, y))
439 return FALSE;
440 }
441 }
442 switch (rtype) {
443 case LR_TELE:
444 case LR_UPTELE:
445 case LR_DOWNTELE:
446 /* "something" means the player in this case */
447 if ((mtmp = m_at(x, y)) != 0) {
448 /* move the monster if no choice, or just try again */
449 if (oneshot) {
450 if (!rloc(mtmp, RLOC_NOMSG))
451 m_into_limbo(mtmp);
452 } else
453 return FALSE;
454 }
455 u_on_newpos(x, y);
456 break;
457 case LR_PORTAL:
458 mkportal(x, y, lev->dnum, lev->dlevel);
459 break;
460 case LR_DOWNSTAIR:
461 case LR_UPSTAIR:
462 mkstairs(x, y, (char) rtype, (struct mkroom *) 0, FALSE);
463 break;
464 case LR_BRANCH:
465 place_branch(Is_branchlev(&u.uz), x, y);
466 break;
467 }
468 return TRUE;
469}

Callers 1

place_lregionFunction · 0.85

Calls 11

bad_locationFunction · 0.85
is_exclusion_zoneFunction · 0.85
t_atFunction · 0.85
deltrapFunction · 0.85
rlocFunction · 0.85
m_into_limboFunction · 0.85
u_on_newposFunction · 0.85
mkportalFunction · 0.85
mkstairsFunction · 0.85
place_branchFunction · 0.85
Is_branchlevFunction · 0.85

Tested by

no test coverage detected