From 55fdfb920043c7aa0e664851fb7f60ffdbb3ffe0 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 27 Jan 2019 11:55:23 -0500 Subject: [PATCH] domove_core() out of domove(); assess domove_core() results new domove_core() assessment results potentially smudge engravings Proceed to wipe engraving after domove_core() now, but only under all of the following conditions: - you can reach the floor - preceding domove_core() move attempt was marked as having succeeded in domove_core() - there is actually an engraving there to impact at your original spot, or your new spot, or both --- doc/fixes36.2 | 9 +++++++++ include/decl.h | 5 +++++ src/cmd.c | 29 +++++++++++++++-------------- src/decl.c | 4 +++- src/hack.c | 34 ++++++++++++++++++++++++++++++++-- 5 files changed, 64 insertions(+), 17 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index d5ba86533..517cd1a09 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -405,6 +405,15 @@ when engulfed while in a shop, dropping an item into the engulfer and then using ':' to look at current location could cause a crash when items were on the floor just inside a shop's door where the shopkeeper doesn't buy and sell stuff, those items showed a 'for sale' price +separate most of domove() into domove_core() and introduce a pair of global + variables that allow for assessment of domove_core() results in + domove() after one of the many return paths +new domove()-related global variables mentioned above also replace a couple + of booleans in rhack() that were used for similar upcoming action + identification +smudging of an engraving has been relocated and follows domove_core() and is + carried out only after a successful move attempt; your former + location and resulting location are both potentially impacted now tty: turn off an optimization that is the suspected cause of Windows reported partial status lines following level changes tty: ensure that current status fields are always copied to prior status diff --git a/include/decl.h b/include/decl.h index 11d478b68..66bfd74c1 100644 --- a/include/decl.h +++ b/include/decl.h @@ -272,6 +272,11 @@ E NEARDATA struct mvitals { uchar mvflags; } mvitals[NUMMONS]; +E NEARDATA long domove_attempting; +E NEARDATA long domove_succeeded; +#define DOMOVE_WALK 0x00000001 +#define DOMOVE_RUSH 0x00000002 + E NEARDATA struct c_color_names { const char *const c_black, *const c_amber, *const c_golden, *const c_light_blue, *const c_red, *const c_green, *const c_silver, diff --git a/src/cmd.c b/src/cmd.c index be8862d24..75319f5e5 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -4538,7 +4538,7 @@ rhack(cmd) register char *cmd; { int spkey; - boolean do_walk, do_rush, prefix_seen, bad_command, + boolean prefix_seen, bad_command, firsttime = (cmd == 0); iflags.menu_requested = FALSE; @@ -4569,7 +4569,7 @@ register char *cmd; } /* handle most movement commands */ - do_walk = do_rush = prefix_seen = FALSE; + prefix_seen = FALSE; context.travel = context.travel1 = 0; spkey = ch2spkeys(*cmd, NHKF_RUN, NHKF_CLICKLOOK); @@ -4577,7 +4577,7 @@ register char *cmd; case NHKF_RUSH: if (movecmd(cmd[1])) { context.run = 2; - do_rush = TRUE; + domove_attempting |= DOMOVE_RUSH; } else prefix_seen = TRUE; break; @@ -4588,7 +4588,7 @@ register char *cmd; case NHKF_RUN: if (movecmd(lowc(cmd[1]))) { context.run = 3; - do_rush = TRUE; + domove_attempting |= DOMOVE_RUSH; } else prefix_seen = TRUE; break; @@ -4604,7 +4604,7 @@ register char *cmd; case NHKF_FIGHT: if (movecmd(cmd[1])) { context.forcefight = 1; - do_walk = TRUE; + domove_attempting |= DOMOVE_WALK; } else prefix_seen = TRUE; break; @@ -4613,7 +4613,7 @@ register char *cmd; context.run = 0; context.nopick = 1; if (!u.dz) - do_walk = TRUE; + domove_attempting |= DOMOVE_WALK; else cmd[0] = cmd[1]; /* "m<" or "m>" */ } else @@ -4623,7 +4623,7 @@ register char *cmd; if (movecmd(lowc(cmd[1]))) { context.run = 1; context.nopick = 1; - do_rush = TRUE; + domove_attempting |= DOMOVE_RUSH; } else prefix_seen = TRUE; break; @@ -4646,20 +4646,20 @@ register char *cmd; context.travel1 = 1; context.run = 8; context.nopick = 1; - do_rush = TRUE; + domove_attempting |= DOMOVE_RUSH; break; } /*FALLTHRU*/ default: if (movecmd(*cmd)) { /* ordinary movement */ context.run = 0; /* only matters here if it was 8 */ - do_walk = TRUE; + domove_attempting |= DOMOVE_WALK; } else if (movecmd(Cmd.num_pad ? unmeta(*cmd) : lowc(*cmd))) { context.run = 1; - do_rush = TRUE; + domove_attempting |= DOMOVE_RUSH; } else if (movecmd(unctrl(*cmd))) { context.run = 3; - do_rush = TRUE; + domove_attempting |= DOMOVE_RUSH; } break; } @@ -4677,7 +4677,8 @@ register char *cmd; } } - if ((do_walk || do_rush) && !context.travel && !dxdy_moveok()) { + if (((domove_attempting & (DOMOVE_RUSH | DOMOVE_WALK)) != 0L) + && !context.travel && !dxdy_moveok()) { /* trying to move diagonally as a grid bug; this used to be treated by movecmd() as not being a movement attempt, but that didn't provide for any @@ -4691,13 +4692,13 @@ register char *cmd; return; } - if (do_walk) { + if ((domove_attempting & DOMOVE_WALK) != 0L) { if (multi) context.mv = TRUE; domove(); context.forcefight = 0; return; - } else if (do_rush) { + } else if ((domove_attempting & DOMOVE_RUSH) != 0L) { if (firsttime) { if (!multi) multi = max(COLNO, ROWNO); diff --git a/src/decl.c b/src/decl.c index 741703da5..3e9fb82cc 100644 --- a/src/decl.c +++ b/src/decl.c @@ -214,6 +214,8 @@ NEARDATA struct monst *mydogs = (struct monst *) 0; NEARDATA struct monst *migrating_mons = (struct monst *) 0; NEARDATA struct mvitals mvitals[NUMMONS]; +NEARDATA long domove_attempting = 0L; +NEARDATA long domove_succeeded = 0L; NEARDATA struct c_color_names c_color_names = { "black", "amber", "golden", "light blue", "red", "green", @@ -277,7 +279,7 @@ char *fqn_prefix[PREFIX_COUNT] = { (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0, (char *) 0 }; - + #ifdef PREFIXES_IN_USE char *fqn_prefix_names[PREFIX_COUNT] = { "hackdir", "leveldir", "savedir", "bonesdir", "datadir", diff --git a/src/hack.c b/src/hack.c index f8bfb6f5e..25dd23a31 100644 --- a/src/hack.c +++ b/src/hack.c @@ -16,6 +16,8 @@ STATIC_DCL boolean FDECL(trapmove, (int, int, struct trap *)); STATIC_DCL struct monst *FDECL(monstinroom, (struct permonst *, int)); STATIC_DCL boolean FDECL(doorless_door, (int, int)); STATIC_DCL void FDECL(move_update, (BOOLEAN_P)); +STATIC_DCL void FDECL(maybe_smudge_engr, (int, int, int, int)); +STATIC_DCL void NDECL(domove_core); #define IS_SHOP(x) (rooms[x].rtype >= SHOPBASE) @@ -1329,6 +1331,19 @@ u_rooted() void domove() +{ + int ux1 = u.ux, uy1 = u.uy; + + domove_succeeded = 0L; + domove_core(); + /* domove_succeeded is available for making assessments now */ + if ((domove_succeeded & (DOMOVE_RUSH | DOMOVE_WALK)) != 0) + maybe_smudge_engr(ux1, uy1, u.ux, u.uy); + domove_attempting = 0L; +} + +void +domove_core() { register struct monst *mtmp; register struct rm *tmpr; @@ -1341,8 +1356,6 @@ domove() int bc_control = 0; /* control for ball&chain */ boolean cause_delay = FALSE; /* dragging ball will skip a move */ - u_wipe_engr(rnd(5)); - if (context.travel) { if (!findtravelpath(FALSE)) (void) findtravelpath(TRUE); @@ -1860,6 +1873,8 @@ domove() check_leash(u.ux0, u.uy0); if (u.ux0 != u.ux || u.uy0 != u.uy) { + /* let caller know so that an evaluation may take place */ + domove_succeeded |= (domove_attempting & (DOMOVE_RUSH | DOMOVE_WALK)); u.umoved = TRUE; /* Clean old position -- vision_recalc() will print our new one. */ newsym(u.ux0, u.uy0); @@ -1899,6 +1914,21 @@ domove() } } +void +maybe_smudge_engr(x1,y1,x2,y2) +int x1, y1, x2, y2; +{ + struct engr *ep; + + if (can_reach_floor(TRUE)) { + if ((ep = engr_at(x1, y1)) && ep->engr_type != HEADSTONE) + wipe_engr_at(x1, y1, rnd(5), FALSE); + if ((x2 != x1 || y2 != y1) + && (ep = engr_at(x2, y2)) && ep->engr_type != HEADSTONE) + wipe_engr_at(x2, y2, rnd(5), FALSE); + } +} + /* combat increases metabolism */ boolean overexertion() -- 2.40.0