diff --git a/include/trap.h b/include/trap.h index 16d096812..3b8e036bf 100644 --- a/include/trap.h +++ b/include/trap.h @@ -83,4 +83,6 @@ enum trap_types { TRAPNUM }; +#define is_pit(ttyp) ((ttyp) == PIT || (ttyp) == SPIKED_PIT) + #endif /* TRAP_H */ diff --git a/src/ball.c b/src/ball.c index be5b7815f..cd631eee5 100644 --- a/src/ball.c +++ b/src/ball.c @@ -599,7 +599,7 @@ drag: || !is_pool(uball->ox, uball->oy) || levl[uball->ox][uball->oy].typ == POOL)) || ((t = t_at(uchain->ox, uchain->oy)) - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT || t->ttyp == HOLE + && (is_pit(t->ttyp) || t->ttyp == HOLE || t->ttyp == TRAPDOOR))) { if (Levitation) { You_feel("a tug from the iron ball."); @@ -745,7 +745,7 @@ xchar x, y; if (!Levitation && !MON_AT(x, y) && !u.utrap && (is_pool(x, y) || ((t = t_at(x, y)) - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT + && (is_pit(t->ttyp) || t->ttyp == TRAPDOOR || t->ttyp == HOLE)))) { u.ux = x; u.uy = y; diff --git a/src/dig.c b/src/dig.c index 488673b22..0a1669813 100644 --- a/src/dig.c +++ b/src/dig.c @@ -312,8 +312,7 @@ dig(VOID_ARGS) } if (context.digging.effort <= 50 - || (ttmp && (ttmp->ttyp == TRAPDOOR || ttmp->ttyp == PIT - || ttmp->ttyp == SPIKED_PIT))) { + || (ttmp && (ttmp->ttyp == TRAPDOOR || is_pit(ttmp->ttyp)))) { return 1; } else if (ttmp && (ttmp->ttyp == LANDMINE || (ttmp->ttyp == BEAR_TRAP && !u.utrap))) { @@ -803,7 +802,7 @@ coord *cc; } } else if ((boulder_here = sobj_at(BOULDER, dig_x, dig_y)) != 0) { - if (ttmp && (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT) + if (ttmp && is_pit(ttmp->ttyp) && rn2(2)) { pline_The("boulder settles into the %spit.", (dig_x != u.ux || dig_y != u.uy) ? "adjacent " : ""); @@ -1087,7 +1086,7 @@ struct obj *obj; KILLED_BY); } else if (u.utrap && u.utraptype == TT_PIT && trap && (trap_with_u = t_at(u.ux, u.uy)) - && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT) + && is_pit(trap->ttyp) && !conjoined_pits(trap, trap_with_u, FALSE)) { int idx; @@ -1462,8 +1461,7 @@ zap_dig() struct trap *adjpit = t_at(zx, zy); if ((diridx < 8) && !conjoined_pits(adjpit, trap_with_u, FALSE)) { digdepth = 0; /* limited to the adjacent location only */ - if (!(adjpit && (adjpit->ttyp == PIT - || adjpit->ttyp == SPIKED_PIT))) { + if (!(adjpit && is_pit(adjpit->ttyp))) { char buf[BUFSZ]; cc.x = zx; cc.y = zy; @@ -1477,7 +1475,7 @@ zap_dig() } } if (adjpit - && (adjpit->ttyp == PIT || adjpit->ttyp == SPIKED_PIT)) { + && is_pit(adjpit->ttyp)) { int adjidx = (diridx + 4) % 8; trap_with_u->conjoined |= (1 << diridx); adjpit->conjoined |= (1 << adjidx); @@ -1566,7 +1564,7 @@ zap_dig() if (pitflow && isok(flow_x, flow_y)) { struct trap *ttmp = t_at(flow_x, flow_y); - if (ttmp && (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT)) { + if (ttmp && is_pit(ttmp->ttyp)) { schar filltyp = fillholetyp(ttmp->tx, ttmp->ty, TRUE); if (filltyp != ROOM) pit_flow(ttmp, filltyp); @@ -1681,7 +1679,7 @@ struct trap *trap; schar filltyp; { if (trap && (filltyp != ROOM) - && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) { + && is_pit(trap->ttyp)) { struct trap t; int idx; diff --git a/src/display.c b/src/display.c index 5b8eba8a7..a142eab91 100644 --- a/src/display.c +++ b/src/display.c @@ -783,7 +783,7 @@ register int x, y; /* if monster is in a physical trap, you see the trap too */ - if (tt == BEAR_TRAP || tt == PIT || tt == SPIKED_PIT + if (tt == BEAR_TRAP || is_pit(tt) || tt == WEB) { trap->tseen = TRUE; } diff --git a/src/do.c b/src/do.c index 8f878af79..d8ba1a725 100644 --- a/src/do.c +++ b/src/do.c @@ -149,7 +149,7 @@ const char *verb; if (obj->otyp == BOULDER && boulder_hits_pool(obj, x, y, FALSE)) { return TRUE; } else if (obj->otyp == BOULDER && (t = t_at(x, y)) != 0 - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT + && (is_pit(t->ttyp) || t->ttyp == TRAPDOOR || t->ttyp == HOLE)) { if (((mtmp = m_at(x, y)) && mtmp->mtrapped) || (u.utrap && u.ux == x && u.uy == y)) { diff --git a/src/dokick.c b/src/dokick.c index 950d03553..09fb44c36 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -495,7 +495,7 @@ xchar x, y; return 0; if ((trap = t_at(x, y)) != 0) { - if (((trap->ttyp == PIT || trap->ttyp == SPIKED_PIT) && !Passes_walls) + if ((is_pit(trap->ttyp) && !Passes_walls) || trap->ttyp == WEB) { if (!trap->tseen) find_trap(trap); diff --git a/src/dothrow.c b/src/dothrow.c index b9d122a7d..38f8d9923 100644 --- a/src/dothrow.c +++ b/src/dothrow.c @@ -744,7 +744,7 @@ int x, y; dotrap(ttmp, 0); /* doesn't print messages */ } else if (ttmp->ttyp == FIRE_TRAP) { dotrap(ttmp, 0); - } else if ((ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT + } else if ((is_pit(ttmp->ttyp) || ttmp->ttyp == HOLE || ttmp->ttyp == TRAPDOOR) && Sokoban) { /* air currents overcome the recoil in Sokoban; diff --git a/src/hack.c b/src/hack.c index cb92b93ad..70671b45f 100644 --- a/src/hack.c +++ b/src/hack.c @@ -151,8 +151,7 @@ moverock() if (mtmp && !noncorporeal(mtmp->data) && (!mtmp->mtrapped - || !(ttmp && ((ttmp->ttyp == PIT) - || (ttmp->ttyp == SPIKED_PIT))))) { + || !(ttmp && is_pit(ttmp->ttyp)))) { if (Blind) feel_location(sx, sy); if (canspotmon(mtmp)) { @@ -1205,7 +1204,7 @@ struct trap *desttrap; /* nonnull if another trap at */ break; case TT_PIT: if (desttrap && desttrap->tseen - && (desttrap->ttyp == PIT || desttrap->ttyp == SPIKED_PIT)) + && is_pit(desttrap->ttyp)) return TRUE; /* move into adjacent pit */ /* try to escape; position stays same regardless of success */ climb_pit(); @@ -1736,7 +1735,7 @@ domove() u.ux = mtmp->mx, u.uy = mtmp->my; /* resume swapping positions */ if (mtmp->mtrapped && (trap = t_at(mtmp->mx, mtmp->my)) != 0 - && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT) + && is_pit(trap->ttyp) && sobj_at(BOULDER, trap->tx, trap->ty)) { /* can't swap places with pet pinned in a pit by a boulder */ u.ux = u.ux0, u.uy = u.uy0; /* didn't move after all */ @@ -2100,7 +2099,7 @@ boolean pick; * If not a pit, pickup before triggering trap. * If pit, trigger trap before pickup. */ - pit = (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)); + pit = (trap && is_pit(trap->ttyp)); if (pick && !pit) (void) pickup(1); diff --git a/src/mhitu.c b/src/mhitu.c index c429a0241..97229ba60 100644 --- a/src/mhitu.c +++ b/src/mhitu.c @@ -1744,7 +1744,7 @@ struct attack *mattk; if (!engulf_target(mtmp, &youmonst)) return 0; - if ((t && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT))) + if ((t && is_pit(t->ttyp)) && sobj_at(BOULDER, u.ux, u.uy)) return 0; diff --git a/src/mklev.c b/src/mklev.c index f704db27d..acbf5b76d 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -1349,7 +1349,7 @@ coord *tm; m = *tm; } else { register int tryct = 0; - boolean avoid_boulder = (kind == PIT || kind == SPIKED_PIT + boolean avoid_boulder = (is_pit(kind) || kind == TRAPDOOR || kind == HOLE); do { @@ -1390,7 +1390,7 @@ coord *tm; in a pit and yet not be able to identify that the pit is there. */ if (lvl <= (unsigned) rnd(4) && kind != SQKY_BOARD && kind != RUST_TRAP - && kind != PIT && kind != SPIKED_PIT && kind < HOLE) { + && !is_pit(kind) && kind < HOLE) { /* Object generated by the trap; initially NULL, stays NULL if we fail to generate an object or if the trap doesn't generate objects. */ diff --git a/src/mon.c b/src/mon.c index 335e5b6b8..d199c2ae5 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1446,7 +1446,7 @@ nexttry: /* eels prefer the water, but if there is no water nearby, if ((ttmp->ttyp != RUST_TRAP || mdat == &mons[PM_IRON_GOLEM]) && ttmp->ttyp != STATUE_TRAP - && ((ttmp->ttyp != PIT && ttmp->ttyp != SPIKED_PIT + && ((!is_pit(ttmp->ttyp) && ttmp->ttyp != TRAPDOOR && ttmp->ttyp != HOLE) || (!is_flyer(mdat) && !is_floater(mdat) && !is_clinger(mdat)) || Sokoban) @@ -2256,7 +2256,7 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */ } if (mtmp->mtrapped && (t = t_at(x, y)) != 0 - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) { + && is_pit(t->ttyp)) { if (sobj_at(BOULDER, x, y)) nocorpse = TRUE; /* Prevent corpses/treasure being created "on top" of boulder that is about to fall in. @@ -2943,7 +2943,7 @@ register struct monst *mtmp; || rn2(3) || mtmp == u.ustuck /* can't hide while trapped except in pits */ || (mtmp->mtrapped && (t = t_at(mtmp->mx, mtmp->my)) != 0 - && !(t->ttyp == PIT || t->ttyp == SPIKED_PIT)) + && !is_pit(t->ttyp)) || (sensemon(mtmp) && distu(mtmp->mx, mtmp->my) <= 2)) return FALSE; @@ -2971,7 +2971,7 @@ struct monst *mtmp; ; /* can't hide if holding you or held by you */ } else if (is_u ? (u.utrap && u.utraptype != TT_PIT) : (mtmp->mtrapped && (t = t_at(x, y)) != 0 - && !(t->ttyp == PIT || t->ttyp == SPIKED_PIT))) { + && !is_pit(t->ttyp))) { ; /* can't hide while stuck in a non-pit trap */ } else if (mtmp->data->mlet == S_EEL) { undetected = (is_pool(x, y) && !Is_waterlevel(&u.uz)); diff --git a/src/mthrowu.c b/src/mthrowu.c index e2ec346aa..28a979940 100644 --- a/src/mthrowu.c +++ b/src/mthrowu.c @@ -126,7 +126,7 @@ int x, y; if (create && !((mtmp = m_at(x, y)) != 0 && mtmp->mtrapped && (t = t_at(x, y)) != 0 - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT))) { + && is_pit(t->ttyp))) { int objgone = 0; if (down_gate(x, y) != -1) diff --git a/src/muse.c b/src/muse.c index e0403003b..ac462cea2 100644 --- a/src/muse.c +++ b/src/muse.c @@ -489,7 +489,7 @@ struct monst *mtmp; /* kludge to cut down on trap destruction (particularly portals) */ t = t_at(x, y); - if (t && (t->ttyp == PIT || t->ttyp == SPIKED_PIT || t->ttyp == WEB + if (t && (is_pit(t->ttyp) || t->ttyp == WEB || t->ttyp == BEAR_TRAP)) t = 0; /* ok for monster to dig here */ diff --git a/src/music.c b/src/music.c index 24e1c559e..71253f6e1 100644 --- a/src/music.c +++ b/src/music.c @@ -249,7 +249,7 @@ int force; unsigned tu_pit = 0; if (trap_at_u) - tu_pit = (trap_at_u->ttyp == PIT || trap_at_u->ttyp == SPIKED_PIT); + tu_pit = is_pit(trap_at_u->ttyp); start_x = u.ux - (force * 2); start_y = u.uy - (force * 2); end_x = u.ux + (force * 2); diff --git a/src/pager.c b/src/pager.c index d44efb795..a82431aa0 100644 --- a/src/pager.c +++ b/src/pager.c @@ -279,7 +279,7 @@ int x, y; int tt = t ? t->ttyp : NO_TRAP; /* newsym lets you know of the trap, so mention it here */ - if (tt == BEAR_TRAP || tt == PIT || tt == SPIKED_PIT || tt == WEB) + if (tt == BEAR_TRAP || is_pit(tt) || tt == WEB) Sprintf(eos(buf), ", trapped in %s", an(defsyms[trap_to_defsym(tt)].explanation)); } diff --git a/src/sp_lev.c b/src/sp_lev.c index af1cdc678..c1a0c70aa 100644 --- a/src/sp_lev.c +++ b/src/sp_lev.c @@ -2660,7 +2660,7 @@ fill_empty_maze() maze1xy(&mm, DRY); trytrap = rndtrap(); if (sobj_at(BOULDER, mm.x, mm.y)) - while (trytrap == PIT || trytrap == SPIKED_PIT + while (is_pit(trytrap) || trytrap == TRAPDOOR || trytrap == HOLE) trytrap = rndtrap(); (void) maketrap(mm.x, mm.y, trytrap); diff --git a/src/trap.c b/src/trap.c index 6e7e3ed78..c4a96c99c 100644 --- a/src/trap.c +++ b/src/trap.c @@ -328,8 +328,7 @@ int x, y, typ; if (u.utrap && x == u.ux && y == u.uy && ((u.utraptype == TT_BEARTRAP && typ != BEAR_TRAP) || (u.utraptype == TT_WEB && typ != WEB) - || (u.utraptype == TT_PIT && typ != PIT - && typ != SPIKED_PIT))) + || (u.utraptype == TT_PIT && !is_pit(typ)))) u.utrap = 0; /* old remain valid */ } else if (IS_FURNITURE(lev->typ) @@ -862,7 +861,7 @@ unsigned trflags; nomul(0); /* KMH -- You can't escape the Sokoban level traps */ - if (Sokoban && (ttype == PIT || ttype == SPIKED_PIT + if (Sokoban && (is_pit(ttype) || ttype == HOLE || ttype == TRAPDOOR)) { /* The "air currents" message is still appropriate -- even when * the hero isn't flying or levitating -- because it conveys the @@ -875,7 +874,7 @@ unsigned trflags; /* then proceed to normal trap effect */ } else if (already_seen && !forcetrap) { if ((Levitation || (Flying && !plunged)) - && (ttype == PIT || ttype == SPIKED_PIT || ttype == HOLE + && (is_pit(ttype) || ttype == HOLE || ttype == BEAR_TRAP)) { You("%s over %s %s.", Levitation ? "float" : "fly", a_your[trap->madeby_u], @@ -885,7 +884,7 @@ unsigned trflags; if (!Fumbling && ttype != MAGIC_PORTAL && ttype != VIBRATING_SQUARE && ttype != ANTI_MAGIC && !forcebungle && !plunged && !conj_pit && !adj_pit - && (!rn2(5) || ((ttype == PIT || ttype == SPIKED_PIT) + && (!rn2(5) || (is_pit(ttype) && is_clinger(youmonst.data)))) { You("escape %s %s.", (ttype == ARROW_TRAP && !trap->madeby_u) ? "an" @@ -2075,8 +2074,8 @@ register struct monst *mtmp; mtmp->mtrapped = 0; /* perhaps teleported? */ } else if (mtmp->mtrapped) { /* is currently in the trap */ if (!trap->tseen && cansee(mtmp->mx, mtmp->my) && canseemon(mtmp) - && (trap->ttyp == SPIKED_PIT || trap->ttyp == BEAR_TRAP - || trap->ttyp == HOLE || trap->ttyp == PIT + && (is_pit(trap->ttyp) || trap->ttyp == BEAR_TRAP + || trap->ttyp == HOLE || trap->ttyp == WEB)) { /* If you come upon an obviously trapped monster, then * you must be able to see the trap it's in too. @@ -2086,7 +2085,7 @@ register struct monst *mtmp; if (!rn2(40)) { if (sobj_at(BOULDER, mtmp->mx, mtmp->my) - && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) { + && is_pit(trap->ttyp)) { if (!rn2(2)) { mtmp->mtrapped = 0; if (canseemon(mtmp)) @@ -2818,7 +2817,7 @@ int x, y; struct obj *otmp; struct trap *t; - if ((t = t_at(x, y)) && ((t->ttyp == PIT) || (t->ttyp == SPIKED_PIT)) + if ((t = t_at(x, y)) && is_pit(t->ttyp) && (otmp = sobj_at(BOULDER, x, y))) { obj_extract_self(otmp); (void) flooreffects(otmp, x, y, "settle"); @@ -2865,7 +2864,7 @@ long hmask, emask; /* might cancel timeout */ if (Punished && !carried(uball) && (is_pool(uball->ox, uball->oy) || ((trap = t_at(uball->ox, uball->oy)) - && ((trap->ttyp == PIT) || (trap->ttyp == SPIKED_PIT) + && (is_pit(trap->ttyp) || (trap->ttyp == TRAPDOOR) || (trap->ttyp == HOLE))))) { u.ux0 = u.ux; u.uy0 = u.uy; @@ -4313,7 +4312,7 @@ boolean force; if (ttmp) { Strcpy(the_trap, the(trapdescr)); if (boxcnt) { - if (ttmp->ttyp == PIT || ttmp->ttyp == SPIKED_PIT) { + if (is_pit(ttmp->ttyp)) { You_cant("do much about %s%s.", the_trap, u.utrap ? " that you're stuck in" : " while standing on the edge of it"); @@ -4615,8 +4614,7 @@ boolean *noticed; /* set to true iff hero notices the effect; */ /* if no trap here or it's not a falling trap, we're done (note: falling rock traps have a trapdoor in the ceiling) */ if (!t || ((t->ttyp != TRAPDOOR && t->ttyp != ROCKTRAP) - && (trapdoor_only || (t->ttyp != HOLE && t->ttyp != PIT - && t->ttyp != SPIKED_PIT)))) + && (trapdoor_only || (t->ttyp != HOLE && !is_pit(t->ttyp))))) return FALSE; if (ishero) { @@ -4875,8 +4873,8 @@ boolean u_entering_trap2; if (!trap1 || !trap2) return FALSE; if (!isok(trap2->tx, trap2->ty) || !isok(trap1->tx, trap1->ty) - || !(trap2->ttyp == PIT || trap2->ttyp == SPIKED_PIT) - || !(trap1->ttyp == PIT || trap1->ttyp == SPIKED_PIT) + || !is_pit(trap2->ttyp) + || !is_pit(trap1->ttyp) || (u_entering_trap2 && !(u.utrap && u.utraptype == TT_PIT))) return FALSE; dx = sgn(trap2->tx - trap1->tx); @@ -4901,14 +4899,14 @@ struct trap *trap; int diridx, adjidx, x, y; struct trap *t; - if (trap && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) { + if (trap && is_pit(trap->ttyp)) { for (diridx = 0; diridx < 8; ++diridx) { if (trap->conjoined & (1 << diridx)) { x = trap->tx + xdir[diridx]; y = trap->ty + ydir[diridx]; if (isok(x, y) && (t = t_at(x, y)) != 0 - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) { + && is_pit(t->ttyp)) { adjidx = (diridx + 4) % 8; t->conjoined &= ~(1 << adjidx); } @@ -4925,8 +4923,8 @@ struct trap *adjtrap; struct trap *trap_with_u = t_at(u.ux0, u.uy0); if (trap_with_u && adjtrap && u.utrap && u.utraptype == TT_PIT && - (trap_with_u->ttyp == PIT || trap_with_u->ttyp == SPIKED_PIT) && - (adjtrap->ttyp == PIT || adjtrap->ttyp == SPIKED_PIT)) { + is_pit(trap_with_u->ttyp) && + is_pit(adjtrap->ttyp)) { int idx; for (idx = 0; idx < 8; idx++) { if (xdir[idx] == u.dx && ydir[idx] == u.dy) @@ -4955,7 +4953,7 @@ struct trap *trap; y = trap->ty + ydir[diridx]; if (isok(x, y)) { if ((t = t_at(x, y)) != 0 - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT)) { + && is_pit(t->ttyp)) { trap->conjoined |= (1 << diridx); join_adjacent_pits(t); } else @@ -4973,7 +4971,7 @@ uteetering_at_seen_pit(trap) struct trap *trap; { if (trap && trap->tseen && (!u.utrap || u.utraptype != TT_PIT) - && (trap->ttyp == PIT || trap->ttyp == SPIKED_PIT)) + && is_pit(trap->ttyp)) return TRUE; else return FALSE; @@ -4987,7 +4985,7 @@ register struct trap *ttmp; /* some of these are arbitrary -dlc */ if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP) || (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP) - || (ttmp->ttyp == PIT) || (ttmp->ttyp == SPIKED_PIT) + || is_pit(ttmp->ttyp) || (ttmp->ttyp == HOLE) || (ttmp->ttyp == TRAPDOOR) || (ttmp->ttyp == TELEP_TRAP) || (ttmp->ttyp == LEVEL_TELEP) || (ttmp->ttyp == WEB) || (ttmp->ttyp == MAGIC_TRAP) diff --git a/src/zap.c b/src/zap.c index 8c4458347..35ce7a9e3 100644 --- a/src/zap.c +++ b/src/zap.c @@ -3373,7 +3373,7 @@ struct obj **pobj; /* object tossed/used, set to NULL The(distant_name(obj, xname))); /* lame */ range = 0; } else if (Sokoban && (t = t_at(x, y)) != 0 - && (t->ttyp == PIT || t->ttyp == SPIKED_PIT + && (is_pit(t->ttyp) || t->ttyp == HOLE || t->ttyp == TRAPDOOR)) { /* hero falls into the trap, so ball stops */ range = 0;