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
+1
View File
@@ -897,6 +897,7 @@ E void NDECL(domove);
E boolean NDECL(overexertion); E boolean NDECL(overexertion);
E void NDECL(invocation_message); E void NDECL(invocation_message);
E void NDECL(switch_terrain); E void NDECL(switch_terrain);
E void FDECL(set_uinwater, (int));
E boolean FDECL(pooleffects, (BOOLEAN_P)); E boolean FDECL(pooleffects, (BOOLEAN_P));
E void FDECL(spoteffects, (BOOLEAN_P)); E void FDECL(spoteffects, (BOOLEAN_P));
E char *FDECL(in_rooms, (XCHAR_P, XCHAR_P, int)); E char *FDECL(in_rooms, (XCHAR_P, XCHAR_P, int));
+1 -1
View File
@@ -834,7 +834,7 @@ boolean pre, wiztower;
(void) memset((genericptr_t)&g.updest, 0, sizeof (dest_area)); (void) memset((genericptr_t)&g.updest, 0, sizeof (dest_area));
u.ustuck = (struct monst *) 0; u.ustuck = (struct monst *) 0;
u.uswallow = u.uswldtim = 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 */ u.uundetected = 0; /* not hidden, even if means are available */
dmonsfree(); /* purge dead monsters from 'fmon' */ dmonsfree(); /* purge dead monsters from 'fmon' */
+2 -2
View File
@@ -35,7 +35,7 @@ unconstrain_map()
boolean res = u.uinwater || u.uburied || u.uswallow; boolean res = u.uinwater || u.uburied || u.uswallow;
/* bring Underwater, buried, or swallowed hero to normal map */ /* 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_uburied = u.uburied, u.uburied = 0;
iflags.save_uswallow = u.uswallow, u.uswallow = 0; iflags.save_uswallow = u.uswallow, u.uswallow = 0;
@@ -46,7 +46,7 @@ unconstrain_map()
static void static void
reconstrain_map() 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.uburied = iflags.save_uburied, iflags.save_uburied = 0;
u.uswallow = iflags.save_uswallow, iflags.save_uswallow = 0; u.uswallow = iflags.save_uswallow, iflags.save_uswallow = 0;
} }
+3 -3
View File
@@ -96,7 +96,7 @@ boolean pushing;
} }
if (fills_up && u.uinwater && distu(rx, ry) == 0) { if (fills_up && u.uinwater && distu(rx, ry) == 0) {
u.uinwater = 0; set_uinwater(0); /* u.uinwater = 0 */
docrt(); docrt();
g.vision_full_recalc = 1; g.vision_full_recalc = 1;
You("find yourself on dry land again!"); You("find yourself on dry land again!");
@@ -1377,7 +1377,7 @@ boolean at_stairs, falling, portal;
fill_pit(u.ux, u.uy); fill_pit(u.ux, u.uy);
set_ustuck((struct monst *) 0); /* idem */ set_ustuck((struct monst *) 0); /* idem */
u.uswallow = u.uswldtim = 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 */ u.uundetected = 0; /* not hidden, even if means are available */
keepdogs(FALSE); keepdogs(FALSE);
recalc_mapseen(); /* recalculate map overview before we leave the level */ 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 */ oinit(); /* reassign level dependent obj probabilities */
} }
reglyph_darkroom(); reglyph_darkroom();
u.uinwater = 0; set_uinwater(0); /* u.uinwater = 0 */
/* do this prior to level-change pline messages */ /* do this prior to level-change pline messages */
vision_reset(); /* clear old level's line-of-sight */ vision_reset(); /* clear old level's line-of-sight */
g.vision_full_recalc = 0; /* don't let that reenable vision yet */ g.vision_full_recalc = 0; /* don't let that reenable vision yet */
+9 -1
View File
@@ -2086,6 +2086,14 @@ switch_terrain()
g.context.botl = TRUE; /* update Lev/Fly status condition */ 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 /* 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; leaving a pool of water/lava, and by moveloop to check for staying on one;
returns true to skip rest of spoteffects */ returns true to skip rest of spoteffects */
@@ -2119,7 +2127,7 @@ boolean newspot; /* true if called by spoteffects */
if (!still_inwater) { if (!still_inwater) {
boolean was_underwater = (Underwater && !Is_waterlevel(&u.uz)); 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 */ if (was_underwater) { /* restore vision */
docrt(); docrt();
g.vision_full_recalc = 1; g.vision_full_recalc = 1;
+1 -1
View File
@@ -3119,7 +3119,7 @@ int locked, trapped;
/* hero started at <x,y> but might not be there anymore (create /* hero started at <x,y> but might not be there anymore (create
lava, decline to die, and get teleported away to safety) */ lava, decline to die, and get teleported away to safety) */
if (u.uinwater && !is_pool(u.ux, u.uy)) { 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(); docrt();
/* [block/unblock_point was handled by docrt -> vision_recalc] */ /* [block/unblock_point was handled by docrt -> vision_recalc] */
} else { } else {
+1 -1
View File
@@ -104,7 +104,7 @@ dosave0()
if (iflags.save_uswallow) if (iflags.save_uswallow)
u.uswallow = 1, iflags.save_uswallow = 0; u.uswallow = 1, iflags.save_uswallow = 0;
if (iflags.save_uinwater) 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) if (iflags.save_uburied)
u.uburied = 1, iflags.save_uburied = 0; u.uburied = 1, iflags.save_uburied = 0;
+3 -3
View File
@@ -3805,7 +3805,7 @@ drown()
placebc(); placebc();
} }
vision_recalc(2); /* unsee old position */ vision_recalc(2); /* unsee old position */
u.uinwater = 1; set_uinwater(1); /* u.uinwater = 1 */
under_water(1); under_water(1);
g.vision_full_recalc = 1; g.vision_full_recalc = 1;
return FALSE; return FALSE;
@@ -3871,7 +3871,7 @@ drown()
/* still too much weight */ /* still too much weight */
pline("But in vain."); pline("But in vain.");
} }
u.uinwater = 1; set_uinwater(1); /* u.uinwater = 1 */
You("drown."); You("drown.");
for (i = 0; i < 5; i++) { /* arbitrary number of loops */ for (i = 0; i < 5; i++) { /* arbitrary number of loops */
/* killer format and name are reconstructed every iteration /* killer format and name are reconstructed every iteration
@@ -3890,7 +3890,7 @@ drown()
pline("You're still drowning."); pline("You're still drowning.");
} }
if (u.uinwater) { if (u.uinwater) {
u.uinwater = 0; set_uinwater(0); /* u.uinwater = 0 */
You("find yourself back %s.", You("find yourself back %s.",
Is_waterlevel(&u.uz) ? "in an air bubble" : "on land"); Is_waterlevel(&u.uz) ? "in an air bubble" : "on land");
} }
+1 -1
View File
@@ -4514,7 +4514,7 @@ short exploding_wand_typ;
if (x == u.ux && y == u.uy) { if (x == u.ux && y == u.uy) {
if (u.uinwater) { /* not just `if (Underwater)' */ if (u.uinwater) { /* not just `if (Underwater)' */
/* leave the no longer existent water */ /* leave the no longer existent water */
u.uinwater = 0; set_uinwater(0); /* u.uinwater = 0 */
u.uundetected = 0; u.uundetected = 0;
docrt(); docrt();
g.vision_full_recalc = 1; g.vision_full_recalc = 1;