groundwork: u.uinwater manipulation

Toggle u.uinwater on or off in just one place.
This commit is contained in:
PatR
2020-04-03 01:04:27 -07:00
parent 5f9714bf92
commit a2338e92aa
9 changed files with 22 additions and 13 deletions

View File

@@ -897,6 +897,7 @@ E void NDECL(domove);
E boolean NDECL(overexertion);
E void NDECL(invocation_message);
E void NDECL(switch_terrain);
E void FDECL(set_uinwater, (int));
E boolean FDECL(pooleffects, (BOOLEAN_P));
E void FDECL(spoteffects, (BOOLEAN_P));
E char *FDECL(in_rooms, (XCHAR_P, XCHAR_P, int));

View File

@@ -834,7 +834,7 @@ boolean pre, wiztower;
(void) memset((genericptr_t)&g.updest, 0, sizeof (dest_area));
u.ustuck = (struct monst *) 0;
u.uswallow = u.uswldtim = 0;
u.uinwater = 0;
set_uinwater(0); /* u.uinwater = 0 */
u.uundetected = 0; /* not hidden, even if means are available */
dmonsfree(); /* purge dead monsters from 'fmon' */

View File

@@ -35,7 +35,7 @@ unconstrain_map()
boolean res = u.uinwater || u.uburied || u.uswallow;
/* bring Underwater, buried, or swallowed hero to normal map */
iflags.save_uinwater = u.uinwater, u.uinwater = 0;
iflags.save_uinwater = u.uinwater, u.uinwater = 0; /* bypass set_uinwater() */
iflags.save_uburied = u.uburied, u.uburied = 0;
iflags.save_uswallow = u.uswallow, u.uswallow = 0;
@@ -46,7 +46,7 @@ unconstrain_map()
static void
reconstrain_map()
{
u.uinwater = iflags.save_uinwater, iflags.save_uinwater = 0;
u.uinwater = iflags.save_uinwater, iflags.save_uinwater = 0; /* set_uinwater() */
u.uburied = iflags.save_uburied, iflags.save_uburied = 0;
u.uswallow = iflags.save_uswallow, iflags.save_uswallow = 0;
}

View File

@@ -96,7 +96,7 @@ boolean pushing;
}
if (fills_up && u.uinwater && distu(rx, ry) == 0) {
u.uinwater = 0;
set_uinwater(0); /* u.uinwater = 0 */
docrt();
g.vision_full_recalc = 1;
You("find yourself on dry land again!");
@@ -1377,7 +1377,7 @@ boolean at_stairs, falling, portal;
fill_pit(u.ux, u.uy);
set_ustuck((struct monst *) 0); /* idem */
u.uswallow = u.uswldtim = 0;
u.uinwater = 0;
set_uinwater(0); /* u.uinwater = 0 */
u.uundetected = 0; /* not hidden, even if means are available */
keepdogs(FALSE);
recalc_mapseen(); /* recalculate map overview before we leave the level */
@@ -1495,7 +1495,7 @@ boolean at_stairs, falling, portal;
oinit(); /* reassign level dependent obj probabilities */
}
reglyph_darkroom();
u.uinwater = 0;
set_uinwater(0); /* u.uinwater = 0 */
/* do this prior to level-change pline messages */
vision_reset(); /* clear old level's line-of-sight */
g.vision_full_recalc = 0; /* don't let that reenable vision yet */

View File

@@ -2086,6 +2086,14 @@ switch_terrain()
g.context.botl = TRUE; /* update Lev/Fly status condition */
}
/* set or clear u.uinwater */
void
set_uinwater(in_out)
int in_out;
{
u.uinwater = in_out;
}
/* extracted from spoteffects; called by spoteffects to check for entering or
leaving a pool of water/lava, and by moveloop to check for staying on one;
returns true to skip rest of spoteffects */
@@ -2119,7 +2127,7 @@ boolean newspot; /* true if called by spoteffects */
if (!still_inwater) {
boolean was_underwater = (Underwater && !Is_waterlevel(&u.uz));
u.uinwater = 0; /* leave the water */
set_uinwater(0); /* u.uinwater = 0; leave the water */
if (was_underwater) { /* restore vision */
docrt();
g.vision_full_recalc = 1;

View File

@@ -3119,7 +3119,7 @@ int locked, trapped;
/* hero started at <x,y> but might not be there anymore (create
lava, decline to die, and get teleported away to safety) */
if (u.uinwater && !is_pool(u.ux, u.uy)) {
u.uinwater = 0; /* leave the water */
set_uinwater(0); /* u.uinwater = 0; leave the water */
docrt();
/* [block/unblock_point was handled by docrt -> vision_recalc] */
} else {

View File

@@ -104,7 +104,7 @@ dosave0()
if (iflags.save_uswallow)
u.uswallow = 1, iflags.save_uswallow = 0;
if (iflags.save_uinwater)
u.uinwater = 1, iflags.save_uinwater = 0;
u.uinwater = 1, iflags.save_uinwater = 0; /* bypass set_uinwater() */
if (iflags.save_uburied)
u.uburied = 1, iflags.save_uburied = 0;

View File

@@ -3805,7 +3805,7 @@ drown()
placebc();
}
vision_recalc(2); /* unsee old position */
u.uinwater = 1;
set_uinwater(1); /* u.uinwater = 1 */
under_water(1);
g.vision_full_recalc = 1;
return FALSE;
@@ -3871,7 +3871,7 @@ drown()
/* still too much weight */
pline("But in vain.");
}
u.uinwater = 1;
set_uinwater(1); /* u.uinwater = 1 */
You("drown.");
for (i = 0; i < 5; i++) { /* arbitrary number of loops */
/* killer format and name are reconstructed every iteration
@@ -3890,7 +3890,7 @@ drown()
pline("You're still drowning.");
}
if (u.uinwater) {
u.uinwater = 0;
set_uinwater(0); /* u.uinwater = 0 */
You("find yourself back %s.",
Is_waterlevel(&u.uz) ? "in an air bubble" : "on land");
}

View File

@@ -4514,7 +4514,7 @@ short exploding_wand_typ;
if (x == u.ux && y == u.uy) {
if (u.uinwater) { /* not just `if (Underwater)' */
/* leave the no longer existent water */
u.uinwater = 0;
set_uinwater(0); /* u.uinwater = 0 */
u.uundetected = 0;
docrt();
g.vision_full_recalc = 1;