From 58a9bcf89318d64d977b58300ea5c3b80e2e1ebf Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Fri, 1 Dec 2006 06:42:25 +0000 Subject: [PATCH] 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'' 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. --- doc/fixes34.4 | 1 + include/extern.h | 3 ++- src/allmain.c | 36 ++++++++++-------------------------- src/trap.c | 22 ++++++++++++++++++++++ src/zap.c | 1 + 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/doc/fixes34.4 b/doc/fixes34.4 index 33eb87839..7274e4aad 100644 --- a/doc/fixes34.4 +++ b/doc/fixes34.4 @@ -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 diff --git a/include/extern.h b/include/extern.h index c1f0a2b44..2c1d2f155 100644 --- a/include/extern.h +++ b/include/extern.h @@ -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 ### */ diff --git a/src/allmain.c b/src/allmain.c index fa4f5d33e..899ab7fb3 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -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(); diff --git a/src/trap.c b/src/trap.c index 03fa1968e..2956da31b 100644 --- a/src/trap.c +++ b/src/trap.c @@ -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*/ diff --git a/src/zap.c b/src/zap.c index 27b71c6ea..9de480659 100644 --- a/src/zap.c +++ b/src/zap.c @@ -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);