moveloop() vs lava

Something's wrong with the way lava was being handled in moveloop().
If you were trapped in lava (ie, moved into some but didn't die on the
spot thanks to fire resistance), you could sink and ultimately die without
ever taking another actual turn (typing ``i<space>'' repeatedly is an easy
way to reproduce).  [`didmove' was only being checked for the sinking
deeper case and not for the decrement which ultimately leads to the fully
sunk case.]  On the other hand, if you could manage to start an occupation
and avoid being interrupted, you would never sink while it was in progress.
[Lava handling followed ``if (multi && occupation) { ...; continue; }''.]

     While testing some other code (lava vs slime, coming shortly) I ended
up with the cursor sitting on the status line while the game was waiting
for me to enter my next move.  I don't really understand what's going on
there, and moving the lava handling before bot() might have hidden that
particular problem now by changing the point at which Slime will get taken
off the status line, but this attempts to fix it anyway.
This commit is contained in:
nethack.rankin
2006-12-01 06:42:25 +00:00
parent 17f8482e73
commit 58a9bcf893
5 changed files with 36 additions and 27 deletions

View File

@@ -279,6 +279,7 @@ wielding a potion of blindness or carrying one in alternate weapon or quiver
slot conferred resistance against light-based blindness to any hero
zapping closing or breaking magic up or down from beneath an open drawbridge's
portcullis failed if bridge orientation was north-to-south (Valk quest)
sinking into lava didn't track passage of time properly
Platform- and/or Interface-Specific Fixes

View File

@@ -2233,12 +2233,13 @@ E boolean FDECL(delfloortrap, (struct trap *));
E struct trap *FDECL(t_at, (int,int));
E void FDECL(b_trapped, (const char *,int));
E boolean NDECL(unconscious);
E boolean NDECL(lava_effects);
E void FDECL(blow_up_landmine, (struct trap *));
E int FDECL(launch_obj,(SHORT_P,int,int,int,int,int));
E boolean NDECL(launch_in_progress);
E void NDECL(force_launch_placement);
E boolean FDECL(uteetering_at_seen_pit, (struct trap *));
E boolean NDECL(lava_effects);
E void NDECL(sink_into_lava);
/* ### u_init.c ### */

View File

@@ -23,7 +23,7 @@ boolean resuming;
int abort_lev;
#endif
int moveamt = 0, wtcap = 0, change = 0;
boolean didmove = FALSE, monscanmove = FALSE;
boolean monscanmove = FALSE;
/* Note: these initializers don't do anything except guarantee that
we're linked properly.
@@ -77,8 +77,7 @@ boolean resuming;
do_positionbar();
#endif
didmove = context.move;
if(didmove) {
if (context.move) {
/* actual time passed */
youmonst.movement -= NORMAL_SPEED;
@@ -309,6 +308,10 @@ boolean resuming;
/* once-per-hero-took-time things go here */
/******************************************/
if ((u.uhave.amulet || Clairvoyant) &&
!In_endgame(&u.uz) && !BClairvoyant &&
!(moves % 15) && !rn2(2)) do_vicinity_map();
if (u.utrap && u.utraptype == TT_LAVA) sink_into_lava();
} /* actual time passed */
@@ -331,7 +334,10 @@ boolean resuming;
if (vision_full_recalc) vision_recalc(0); /* vision! */
}
if(context.botl || context.botlx) bot();
if (context.botl || context.botlx) {
bot();
curs_on_u();
}
context.move = 1;
@@ -366,28 +372,6 @@ boolean resuming;
continue;
}
if ((u.uhave.amulet || Clairvoyant) &&
!In_endgame(&u.uz) && !BClairvoyant &&
!(moves % 15) && !rn2(2))
do_vicinity_map();
if(u.utrap && u.utraptype == TT_LAVA) {
if(!is_lava(u.ux,u.uy))
u.utrap = 0;
else if (!u.uinvulnerable) {
u.utrap -= 1<<8;
if(u.utrap < 1<<8) {
killer.format = KILLED_BY;
Strcpy(killer.name, "molten lava");
You("sink below the surface and die.");
done(DISSOLVED);
} else if(didmove && !u.umoved) {
Norep("You sink deeper into the lava.");
u.utrap += rnd(4);
}
}
}
#ifdef WIZARD
if (iflags.sanity_check)
sanity_check();

View File

@@ -4656,4 +4656,26 @@ burn_stuff:
return(FALSE);
}
/* called each turn when trapped in lava */
void
sink_into_lava()
{
if (!u.utrap || u.utraptype != TT_LAVA) {
; /* do nothing; this shouldn't happen */
} else if (!is_lava(u.ux, u.uy)) {
u.utrap = 0; /* this shouldn't happen either */
} else if (!u.uinvulnerable) {
u.utrap -= (1 << 8);
if (u.utrap < (1 << 8)) {
killer.format = KILLED_BY;
Strcpy(killer.name, "molten lava");
You("sink below the surface and die.");
done(DISSOLVED);
} else if (!u.umoved) {
Norep("You sink deeper into the lava.");
u.utrap += rnd(4);
}
}
}
/*trap.c*/

View File

@@ -3939,6 +3939,7 @@ short exploding_wand_typ;
vision_full_recalc = 1;
} else if (u.utrap && u.utraptype == TT_LAVA) {
if (Passes_walls) {
u.utrap = 0;
You("pass through the now-solid rock.");
} else {
u.utrap = rn1(50,20);