Use is_hole macro to check for trapdoors and holes

This commit is contained in:
Pasi Kallinen
2018-09-15 17:57:57 +03:00
parent adf070eb04
commit e031800880
14 changed files with 23 additions and 34 deletions
+1
View File
@@ -84,5 +84,6 @@ enum trap_types {
}; };
#define is_pit(ttyp) ((ttyp) == PIT || (ttyp) == SPIKED_PIT) #define is_pit(ttyp) ((ttyp) == PIT || (ttyp) == SPIKED_PIT)
#define is_hole(ttyp) ((ttyp) == HOLE || (ttyp) == TRAPDOOR)
#endif /* TRAP_H */ #endif /* TRAP_H */
+2 -3
View File
@@ -599,8 +599,7 @@ drag:
|| !is_pool(uball->ox, uball->oy) || !is_pool(uball->ox, uball->oy)
|| levl[uball->ox][uball->oy].typ == POOL)) || levl[uball->ox][uball->oy].typ == POOL))
|| ((t = t_at(uchain->ox, uchain->oy)) || ((t = t_at(uchain->ox, uchain->oy))
&& (is_pit(t->ttyp) || t->ttyp == HOLE && (is_pit(t->ttyp) || is_hole(t->ttyp)))) {
|| t->ttyp == TRAPDOOR))) {
if (Levitation) { if (Levitation) {
You_feel("a tug from the iron ball."); You_feel("a tug from the iron ball.");
if (t) if (t)
@@ -746,7 +745,7 @@ xchar x, y;
&& (is_pool(x, y) && (is_pool(x, y)
|| ((t = t_at(x, y)) || ((t = t_at(x, y))
&& (is_pit(t->ttyp) && (is_pit(t->ttyp)
|| t->ttyp == TRAPDOOR || t->ttyp == HOLE)))) { || is_hole(t->ttyp))))) {
u.ux = x; u.ux = x;
u.uy = y; u.uy = y;
} else { } else {
+2 -3
View File
@@ -149,8 +149,7 @@ const char *verb;
if (obj->otyp == BOULDER && boulder_hits_pool(obj, x, y, FALSE)) { if (obj->otyp == BOULDER && boulder_hits_pool(obj, x, y, FALSE)) {
return TRUE; return TRUE;
} else if (obj->otyp == BOULDER && (t = t_at(x, y)) != 0 } else if (obj->otyp == BOULDER && (t = t_at(x, y)) != 0
&& (is_pit(t->ttyp) && (is_pit(t->ttyp) || is_hole(t->ttyp))) {
|| t->ttyp == TRAPDOOR || t->ttyp == HOLE)) {
if (((mtmp = m_at(x, y)) && mtmp->mtrapped) if (((mtmp = m_at(x, y)) && mtmp->mtrapped)
|| (u.utrap && u.ux == x && u.uy == y)) { || (u.utrap && u.ux == x && u.uy == y)) {
if (*verb) if (*verb)
@@ -956,7 +955,7 @@ dodown()
if (trap && uteetering_at_seen_pit(trap)) { if (trap && uteetering_at_seen_pit(trap)) {
dotrap(trap, TOOKPLUNGE); dotrap(trap, TOOKPLUNGE);
return 1; return 1;
} else if (!trap || (trap->ttyp != TRAPDOOR && trap->ttyp != HOLE) } else if (!trap || !is_hole(trap->ttyp)
|| !Can_fall_thru(&u.uz) || !trap->tseen) { || !Can_fall_thru(&u.uz) || !trap->tseen) {
if (flags.autodig && !context.nopick && uwep && is_pick(uwep)) { if (flags.autodig && !context.nopick && uwep && is_pick(uwep)) {
return use_pick_axe2(uwep); return use_pick_axe2(uwep);
+2 -2
View File
@@ -1515,7 +1515,7 @@ boolean shop_floor_obj;
/* boulders never fall through trap doors, but they might knock /* boulders never fall through trap doors, but they might knock
other things down before plugging the hole */ other things down before plugging the hole */
if (otmp->otyp == BOULDER && ((t = t_at(x, y)) != 0) if (otmp->otyp == BOULDER && ((t = t_at(x, y)) != 0)
&& (t->ttyp == TRAPDOOR || t->ttyp == HOLE)) { && is_hole(t->ttyp)) {
if (impact) if (impact)
impact_drop(otmp, x, y, 0); impact_drop(otmp, x, y, 0);
return FALSE; /* let caller finish the drop */ return FALSE; /* let caller finish the drop */
@@ -1717,7 +1717,7 @@ xchar x, y;
} }
if (((ttmp = t_at(x, y)) != 0 && ttmp->tseen) if (((ttmp = t_at(x, y)) != 0 && ttmp->tseen)
&& (ttmp->ttyp == TRAPDOOR || ttmp->ttyp == HOLE)) { && is_hole(ttmp->ttyp)) {
gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door" gate_str = (ttmp->ttyp == TRAPDOOR) ? "through the trap door"
: "through the hole"; : "through the hole";
return MIGR_RANDOM; return MIGR_RANDOM;
+1 -2
View File
@@ -744,8 +744,7 @@ int x, y;
dotrap(ttmp, 0); /* doesn't print messages */ dotrap(ttmp, 0); /* doesn't print messages */
} else if (ttmp->ttyp == FIRE_TRAP) { } else if (ttmp->ttyp == FIRE_TRAP) {
dotrap(ttmp, 0); dotrap(ttmp, 0);
} else if ((is_pit(ttmp->ttyp) } else if ((is_pit(ttmp->ttyp) || is_hole(ttmp->ttyp))
|| ttmp->ttyp == HOLE || ttmp->ttyp == TRAPDOOR)
&& Sokoban) { && Sokoban) {
/* air currents overcome the recoil in Sokoban; /* air currents overcome the recoil in Sokoban;
when jumping, caller performs last step and enters trap */ when jumping, caller performs last step and enters trap */
+3 -5
View File
@@ -503,8 +503,7 @@ int trap_type;
if (trap_type || !rn2(4)) { if (trap_type || !rn2(4)) {
rm->typ = SCORR; rm->typ = SCORR;
if (trap_type) { if (trap_type) {
if ((trap_type == HOLE || trap_type == TRAPDOOR) if (is_hole(trap_type) && !Can_fall_thru(&u.uz))
&& !Can_fall_thru(&u.uz))
trap_type = ROCKTRAP; trap_type = ROCKTRAP;
ttmp = maketrap(xx, yy + dy, trap_type); ttmp = maketrap(xx, yy + dy, trap_type);
if (ttmp) { if (ttmp) {
@@ -1342,15 +1341,14 @@ coord *tm;
} while (kind == NO_TRAP); } while (kind == NO_TRAP);
} }
if ((kind == TRAPDOOR || kind == HOLE) && !Can_fall_thru(&u.uz)) if (is_hole(kind) && !Can_fall_thru(&u.uz))
kind = ROCKTRAP; kind = ROCKTRAP;
if (tm) { if (tm) {
m = *tm; m = *tm;
} else { } else {
register int tryct = 0; register int tryct = 0;
boolean avoid_boulder = (is_pit(kind) boolean avoid_boulder = (is_pit(kind) || is_hole(kind));
|| kind == TRAPDOOR || kind == HOLE);
do { do {
if (++tryct > 200) if (++tryct > 200)
+1 -2
View File
@@ -1446,8 +1446,7 @@ nexttry: /* eels prefer the water, but if there is no water nearby,
if ((ttmp->ttyp != RUST_TRAP if ((ttmp->ttyp != RUST_TRAP
|| mdat == &mons[PM_IRON_GOLEM]) || mdat == &mons[PM_IRON_GOLEM])
&& ttmp->ttyp != STATUE_TRAP && ttmp->ttyp != STATUE_TRAP
&& ((!is_pit(ttmp->ttyp) && ((!is_pit(ttmp->ttyp) && !is_hole(ttmp->ttyp))
&& ttmp->ttyp != TRAPDOOR && ttmp->ttyp != HOLE)
|| (!is_flyer(mdat) && !is_floater(mdat) || (!is_flyer(mdat) && !is_floater(mdat)
&& !is_clinger(mdat)) || Sokoban) && !is_clinger(mdat)) || Sokoban)
&& (ttmp->ttyp != SLP_GAS_TRAP || !resists_sleep(mon)) && (ttmp->ttyp != SLP_GAS_TRAP || !resists_sleep(mon))
+1 -1
View File
@@ -439,7 +439,7 @@ struct monst *mtmp;
|| onscary(xx, yy, mtmp)) || onscary(xx, yy, mtmp))
continue; continue;
/* use trap if it's the correct type */ /* use trap if it's the correct type */
if ((t->ttyp == TRAPDOOR || t->ttyp == HOLE) if (is_hole(t->ttyp)
&& !is_floater(mtmp->data) && !is_floater(mtmp->data)
&& !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest && !mtmp->isshk && !mtmp->isgd && !mtmp->ispriest
&& Can_fall_thru(&u.uz)) { && Can_fall_thru(&u.uz)) {
+1 -1
View File
@@ -3508,7 +3508,7 @@ wiztrap:
if (strncmpi(tname, bp, strlen(tname))) if (strncmpi(tname, bp, strlen(tname)))
continue; continue;
/* found it; avoid stupid mistakes */ /* found it; avoid stupid mistakes */
if ((trap == TRAPDOOR || trap == HOLE) && !Can_fall_thru(&u.uz)) if (is_hole(trap) && !Can_fall_thru(&u.uz))
trap = ROCKTRAP; trap = ROCKTRAP;
if ((t = maketrap(x, y, trap)) != 0) { if ((t = maketrap(x, y, trap)) != 0) {
trap = t->ttyp; trap = t->ttyp;
+1 -2
View File
@@ -1362,8 +1362,7 @@ doidtrap()
break; break;
tt = trap->ttyp; tt = trap->ttyp;
if (u.dz) { if (u.dz) {
if (u.dz < 0 ? (tt == TRAPDOOR || tt == HOLE) if (u.dz < 0 ? is_hole(tt) : tt == ROCKTRAP)
: tt == ROCKTRAP)
break; break;
} }
tt = what_trap(tt); tt = what_trap(tt);
+2 -3
View File
@@ -2660,8 +2660,7 @@ fill_empty_maze()
maze1xy(&mm, DRY); maze1xy(&mm, DRY);
trytrap = rndtrap(); trytrap = rndtrap();
if (sobj_at(BOULDER, mm.x, mm.y)) if (sobj_at(BOULDER, mm.x, mm.y))
while (is_pit(trytrap) while (is_pit(trytrap) || is_hole(trytrap))
|| trytrap == TRAPDOOR || trytrap == HOLE)
trytrap = rndtrap(); trytrap = rndtrap();
(void) maketrap(mm.x, mm.y, trytrap); (void) maketrap(mm.x, mm.y, trytrap);
} }
@@ -4495,7 +4494,7 @@ ensure_way_out()
while (ttmp) { while (ttmp) {
if ((ttmp->ttyp == MAGIC_PORTAL || ttmp->ttyp == VIBRATING_SQUARE if ((ttmp->ttyp == MAGIC_PORTAL || ttmp->ttyp == VIBRATING_SQUARE
|| ttmp->ttyp == HOLE || ttmp->ttyp == TRAPDOOR) || is_hole(ttmp->ttyp))
&& !selection_getpoint(ttmp->tx, ttmp->ty, ov)) && !selection_getpoint(ttmp->tx, ttmp->ty, ov))
selection_floodfill(ov, ttmp->tx, ttmp->ty, TRUE); selection_floodfill(ov, ttmp->tx, ttmp->ty, TRUE);
ttmp = ttmp->ntrap; ttmp = ttmp->ntrap;
+1 -1
View File
@@ -1159,7 +1159,7 @@ int in_sight;
d_level tolevel; d_level tolevel;
int migrate_typ = MIGR_RANDOM; int migrate_typ = MIGR_RANDOM;
if ((tt == HOLE || tt == TRAPDOOR)) { if (is_hole(tt)) {
if (Is_stronghold(&u.uz)) { if (Is_stronghold(&u.uz)) {
assign_level(&tolevel, &valley_level); assign_level(&tolevel, &valley_level);
} else if (Is_botlevel(&u.uz)) { } else if (Is_botlevel(&u.uz)) {
+4 -7
View File
@@ -406,8 +406,7 @@ int x, y, typ;
case HOLE: case HOLE:
case TRAPDOOR: case TRAPDOOR:
if (*in_rooms(x, y, SHOPBASE) if (*in_rooms(x, y, SHOPBASE)
&& (typ == HOLE || typ == TRAPDOOR && (is_hole(typ) || IS_DOOR(lev->typ) || IS_WALL(lev->typ)))
|| IS_DOOR(lev->typ) || IS_WALL(lev->typ)))
add_damage(x, y, /* schedule repair */ add_damage(x, y, /* schedule repair */
((IS_DOOR(lev->typ) || IS_WALL(lev->typ)) ((IS_DOOR(lev->typ) || IS_WALL(lev->typ))
&& !context.mon_moving) && !context.mon_moving)
@@ -861,8 +860,7 @@ unsigned trflags;
nomul(0); nomul(0);
/* KMH -- You can't escape the Sokoban level traps */ /* KMH -- You can't escape the Sokoban level traps */
if (Sokoban && (is_pit(ttype) if (Sokoban && (is_pit(ttype) || is_hole(ttype))) {
|| ttype == HOLE || ttype == TRAPDOOR)) {
/* The "air currents" message is still appropriate -- even when /* The "air currents" message is still appropriate -- even when
* the hero isn't flying or levitating -- because it conveys the * the hero isn't flying or levitating -- because it conveys the
* reason why the player cannot escape the trap with a dexterity * reason why the player cannot escape the trap with a dexterity
@@ -2864,8 +2862,7 @@ long hmask, emask; /* might cancel timeout */
if (Punished && !carried(uball) if (Punished && !carried(uball)
&& (is_pool(uball->ox, uball->oy) && (is_pool(uball->ox, uball->oy)
|| ((trap = t_at(uball->ox, uball->oy)) || ((trap = t_at(uball->ox, uball->oy))
&& (is_pit(trap->ttyp) && (is_pit(trap->ttyp) || is_hole(trap->ttyp))))) {
|| (trap->ttyp == TRAPDOOR) || (trap->ttyp == HOLE))))) {
u.ux0 = u.ux; u.ux0 = u.ux;
u.uy0 = u.uy; u.uy0 = u.uy;
u.ux = uball->ox; u.ux = uball->ox;
@@ -4986,7 +4983,7 @@ register struct trap *ttmp;
if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP) if (ttmp && ((ttmp->ttyp == SQKY_BOARD) || (ttmp->ttyp == BEAR_TRAP)
|| (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP) || (ttmp->ttyp == LANDMINE) || (ttmp->ttyp == FIRE_TRAP)
|| is_pit(ttmp->ttyp) || is_pit(ttmp->ttyp)
|| (ttmp->ttyp == HOLE) || (ttmp->ttyp == TRAPDOOR) || is_hole(ttmp->ttyp)
|| (ttmp->ttyp == TELEP_TRAP) || (ttmp->ttyp == LEVEL_TELEP) || (ttmp->ttyp == TELEP_TRAP) || (ttmp->ttyp == LEVEL_TELEP)
|| (ttmp->ttyp == WEB) || (ttmp->ttyp == MAGIC_TRAP) || (ttmp->ttyp == WEB) || (ttmp->ttyp == MAGIC_TRAP)
|| (ttmp->ttyp == ANTI_MAGIC))) { || (ttmp->ttyp == ANTI_MAGIC))) {
+1 -2
View File
@@ -3373,8 +3373,7 @@ struct obj **pobj; /* object tossed/used, set to NULL
The(distant_name(obj, xname))); /* lame */ The(distant_name(obj, xname))); /* lame */
range = 0; range = 0;
} else if (Sokoban && (t = t_at(x, y)) != 0 } else if (Sokoban && (t = t_at(x, y)) != 0
&& (is_pit(t->ttyp) && (is_pit(t->ttyp) || is_hole(t->ttyp))) {
|| t->ttyp == HOLE || t->ttyp == TRAPDOOR)) {
/* hero falls into the trap, so ball stops */ /* hero falls into the trap, so ball stops */
range = 0; range = 0;
} }