Skip to content

Commit

Permalink
moveloop() vs lava
Browse files Browse the repository at this point in the history
     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.
  • Loading branch information
nethack.rankin committed Dec 1, 2006
1 parent 17f8482 commit 58a9bcf
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 27 deletions.
1 change: 1 addition & 0 deletions doc/fixes34.4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion include/extern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 ### */

Expand Down
36 changes: 10 additions & 26 deletions src/allmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -77,8 +77,7 @@ boolean resuming;
do_positionbar();
#endif

didmove = context.move;
if(didmove) {
if (context.move) {
/* actual time passed */
youmonst.movement -= NORMAL_SPEED;

Expand Down Expand Up @@ -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 */

Expand All @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
22 changes: 22 additions & 0 deletions src/trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4656,4 +4656,26 @@ lava_effects()
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*/
1 change: 1 addition & 0 deletions src/zap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 58a9bcf

Please sign in to comment.