trap followup

Make the flags argument to dotrap() and mintrap() and the constants
passed to them all have consistent type: unsigned int.
This commit is contained in:
PatR
2022-02-24 12:17:21 -08:00
parent 6fa4fd46f7
commit ab2bcf4dac
6 changed files with 37 additions and 33 deletions

View File

@@ -2692,7 +2692,7 @@ extern void reset_utrap(boolean);
extern void dotrap(struct trap *, unsigned); extern void dotrap(struct trap *, unsigned);
extern void seetrap(struct trap *); extern void seetrap(struct trap *);
extern void feeltrap(struct trap *); extern void feeltrap(struct trap *);
extern int mintrap(struct monst *, long); extern int mintrap(struct monst *, unsigned);
extern void instapetrify(const char *); extern void instapetrify(const char *);
extern void minstapetrify(struct monst *, boolean); extern void minstapetrify(struct monst *, boolean);
extern void selftouch(const char *); extern void selftouch(const char *);

View File

@@ -382,15 +382,15 @@ typedef struct sortloot_item Loot;
#define PICK_RIGID 1 #define PICK_RIGID 1
/* Flags to control dotrap() and mintrap() in trap.c */ /* Flags to control dotrap() and mintrap() in trap.c */
#define NO_TRAP_FLAGS 0 #define NO_TRAP_FLAGS 0x00U
#define FORCETRAP 0x01 /* triggering not left to chance */ #define FORCETRAP 0x01U /* triggering not left to chance */
#define NOWEBMSG 0x02 /* suppress stumble into web message */ #define NOWEBMSG 0x02U /* suppress stumble into web message */
#define FORCEBUNGLE 0x04 /* adjustments appropriate for bungling */ #define FORCEBUNGLE 0x04U /* adjustments appropriate for bungling */
#define RECURSIVETRAP 0x08 /* trap changed into another type this same turn */ #define RECURSIVETRAP 0x08U /* trap changed into another type this same turn */
#define TOOKPLUNGE 0x10 /* used '>' to enter pit below you */ #define TOOKPLUNGE 0x10U /* used '>' to enter pit below you */
#define VIASITTING 0x20 /* #sit while at trap location (affects message) */ #define VIASITTING 0x20U /* #sit while at trap location (affects message) */
#define FAILEDUNTRAP 0x40 /* trap activated by failed untrap attempt */ #define FAILEDUNTRAP 0x40U /* trap activated by failed untrap attempt */
#define HURTLING 0x80 /* monster is hurtling through air */ #define HURTLING 0x80U /* monster is hurtling through air */
/* Flags to control test_move in hack.c */ /* Flags to control test_move in hack.c */
#define DO_MOVE 0 /* really doing the move */ #define DO_MOVE 0 /* really doing the move */

View File

@@ -766,7 +766,8 @@ hurtle_step(genericptr_t arg, int x, int y)
} }
if ((u.ux - x) && (u.uy - y) && bad_rock(g.youmonst.data, u.ux, y) if ((u.ux - x) && (u.uy - y) && bad_rock(g.youmonst.data, u.ux, y)
&& bad_rock(g.youmonst.data, x, u.uy)) { && bad_rock(g.youmonst.data, x, u.uy)) {
boolean too_much = (g.invent && (inv_weight() + weight_cap() > 600)); boolean too_much = (g.invent
&& (inv_weight() + weight_cap() > 600));
/* Move at a diagonal. */ /* Move at a diagonal. */
if (bigmonst(g.youmonst.data) || too_much) { if (bigmonst(g.youmonst.data) || too_much) {
@@ -791,17 +792,18 @@ hurtle_step(genericptr_t arg, int x, int y)
&& (Flying || Levitation || Wwalking)) && (Flying || Levitation || Wwalking))
#endif #endif
) { ) {
const char *mnam, *pronoun; const char *mnam;
int glyph = glyph_at(x, y); int glyph = glyph_at(x, y);
mon->mundetected = 0; /* wakeup() will handle mimic */ mon->mundetected = 0; /* wakeup() will handle mimic */
mnam = a_monnam(mon); /* after unhiding */ /* after unhiding; combination of a_monnam() and some_mon_nam();
pronoun = noit_mhim(mon); yields "someone" or "something" instead of "it" for unseen mon */
if (!strcmp(mnam, "it")) { mnam = x_monnam(mon, ARTICLE_A, (char *) 0,
mnam = !strcmp(pronoun, "it") ? "something" : "someone"; ((has_mgivenname(mon) ? SUPPRESS_SADDLE : 0)
} | AUGMENT_IT),
FALSE);
if (!glyph_is_monster(glyph) && !glyph_is_invisible(glyph)) if (!glyph_is_monster(glyph) && !glyph_is_invisible(glyph))
You("find %s by bumping into %s.", mnam, pronoun); You("find %s by bumping into %s.", mnam, noit_mhim(mon));
else else
You("bump into %s.", mnam); You("bump into %s.", mnam);
wakeup(mon, FALSE); wakeup(mon, FALSE);
@@ -849,12 +851,14 @@ hurtle_step(genericptr_t arg, int x, int y)
if (is_pool(x, y) && !u.uinwater) { if (is_pool(x, y) && !u.uinwater) {
if ((Is_waterlevel(&u.uz) && is_waterwall(x,y)) if ((Is_waterlevel(&u.uz) && is_waterwall(x,y))
|| !(Levitation || Flying || Wwalking)) { || !(Levitation || Flying || Wwalking)) {
g.multi = 0; /* can move, so drown() allows crawling out of water */ /* couldn't move while hurtling; allow movement now so that
drown() will give a chance to crawl out of pool and survive */
g.multi = 0;
(void) drown(); (void) drown();
return FALSE; return FALSE;
} else if (!Is_waterlevel(&u.uz) && !stopping_short) { } else if (!Is_waterlevel(&u.uz) && !stopping_short) {
Norep("You move over %s.", an(is_moat(x, y) ? "moat" : "pool")); Norep("You move over %s.", an(is_moat(x, y) ? "moat" : "pool"));
} }
} else if (is_lava(x, y) && !stopping_short) { } else if (is_lava(x, y) && !stopping_short) {
Norep("You move over some lava."); Norep("You move over some lava.");
} }
@@ -870,19 +874,19 @@ hurtle_step(genericptr_t arg, int x, int y)
if (stopping_short) { if (stopping_short) {
; /* see the comment above hurtle_jump() */ ; /* see the comment above hurtle_jump() */
} else if (ttmp->ttyp == MAGIC_PORTAL) { } else if (ttmp->ttyp == MAGIC_PORTAL) {
dotrap(ttmp, 0); dotrap(ttmp, NO_TRAP_FLAGS);
return FALSE; return FALSE;
} else if (ttmp->ttyp == VIBRATING_SQUARE) { } else if (ttmp->ttyp == VIBRATING_SQUARE) {
pline("The ground vibrates as you pass it."); pline("The ground vibrates as you pass it.");
dotrap(ttmp, 0); /* doesn't print messages */ dotrap(ttmp, NO_TRAP_FLAGS); /* doesn't print messages */
} else if (ttmp->ttyp == FIRE_TRAP) { } else if (ttmp->ttyp == FIRE_TRAP) {
dotrap(ttmp, 0); dotrap(ttmp, NO_TRAP_FLAGS);
} else if ((is_pit(ttmp->ttyp) || is_hole(ttmp->ttyp)) } else if ((is_pit(ttmp->ttyp) || is_hole(ttmp->ttyp))
&& 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 */
if (!via_jumping) if (!via_jumping)
dotrap(ttmp, 0); dotrap(ttmp, NO_TRAP_FLAGS);
*range = 0; *range = 0;
return TRUE; return TRUE;
} else { } else {

View File

@@ -1392,7 +1392,7 @@ dospinweb(void)
case ANTI_MAGIC: case ANTI_MAGIC:
case POLY_TRAP: case POLY_TRAP:
You("have triggered a trap!"); You("have triggered a trap!");
dotrap(ttmp, 0); dotrap(ttmp, NO_TRAP_FLAGS);
return ECMD_TIME; return ECMD_TIME;
default: default:
impossible("Webbing over trap type %d?", ttmp->ttyp); impossible("Webbing over trap type %d?", ttmp->ttyp);

View File

@@ -2287,7 +2287,7 @@ trapeffect_landmine(
trapkilled = TRUE; trapkilled = TRUE;
} else { } else {
/* monsters recursively fall into new pit */ /* monsters recursively fall into new pit */
if (mintrap(mtmp, trflags|FORCETRAP) == Trap_Killed_Mon) if (mintrap(mtmp, trflags | FORCETRAP) == Trap_Killed_Mon)
trapkilled = TRUE; trapkilled = TRUE;
} }
/* a boulder may fill the new pit, crushing monster */ /* a boulder may fill the new pit, crushing monster */
@@ -2472,9 +2472,9 @@ trapeffect_selector(
} }
void void
dotrap(register struct trap* trap, unsigned int trflags) dotrap(struct trap *trap, unsigned trflags)
{ {
register int ttype = trap->ttyp; int ttype = trap->ttyp;
boolean already_seen = trap->tseen, boolean already_seen = trap->tseen,
forcetrap = ((trflags & FORCETRAP) != 0 forcetrap = ((trflags & FORCETRAP) != 0
|| (trflags & FAILEDUNTRAP) != 0), || (trflags & FAILEDUNTRAP) != 0),
@@ -3115,9 +3115,9 @@ isclearpath(
} }
int int
mintrap(register struct monst *mtmp, long mintrapflags) mintrap(struct monst *mtmp, unsigned mintrapflags)
{ {
register struct trap *trap = t_at(mtmp->mx, mtmp->my); struct trap *trap = t_at(mtmp->mx, mtmp->my);
struct permonst *mptr = mtmp->data; struct permonst *mptr = mtmp->data;
int trap_result = Trap_Effect_Finished; int trap_result = Trap_Effect_Finished;
@@ -3526,7 +3526,7 @@ float_down(
/*FALLTHRU*/ /*FALLTHRU*/
default: default:
if (!u.utrap) /* not already in the trap */ if (!u.utrap) /* not already in the trap */
dotrap(trap, 0); dotrap(trap, NO_TRAP_FLAGS);
} }
} }
if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !u.uswallow if (!Is_airlevel(&u.uz) && !Is_waterlevel(&u.uz) && !u.uswallow
@@ -5272,7 +5272,7 @@ closeholdingtrap(
/* dotrap calls mintrap when mounted hero encounters a web */ /* dotrap calls mintrap when mounted hero encounters a web */
if (u.usteed) if (u.usteed)
dotrapflags |= NOWEBMSG; dotrapflags |= NOWEBMSG;
dotrap(t, dotrapflags|FORCETRAP); dotrap(t, dotrapflags | FORCETRAP);
result = (u.utrap != 0); result = (u.utrap != 0);
} else { } else {
if (mon->mtrapped) if (mon->mtrapped)

View File

@@ -3058,7 +3058,7 @@ zap_updown(struct obj *obj) /* wand or spell */
ttmp->tseen = 1; ttmp->tseen = 1;
newsym(x, y); newsym(x, y);
/* might fall down hole */ /* might fall down hole */
dotrap(ttmp, 0); dotrap(ttmp, NO_TRAP_FLAGS);
} else if (!striking && ttmp->ttyp == HOLE) { } else if (!striking && ttmp->ttyp == HOLE) {
/* locking transforms hole into trapdoor */ /* locking transforms hole into trapdoor */
ttmp->ttyp = TRAPDOOR; ttmp->ttyp = TRAPDOOR;