From 5bb4adace02b516bf14a12bb1144a71dba4f5353 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 14 Sep 2024 12:53:48 -0700 Subject: [PATCH] 'tips' fix and enhancement When 'tips' are enabled, the farlook tip displays some text at the start of getpos(). But it clobbered the initial prompt, leaving the screen in an ambiguous state (seemingly a normal map display, but it is actually waiting for player to move the cursor) after removing the tip's popup window. Reissue the prompt. farlook's short but misleading prompt of "Pick an object" is changed to "Pick a monster, object or location". I would normally include a comma before "or" but omitting it makes the longer text seem slightly less cluttered. The other tips are all one-line, delivered via pline(). Prefix all of their messages with "Tip:" (which the farlook one already uses) as a hint for using OPTIONS=!tips to shut them off. --- doc/fixes3-7-0.txt | 15 +++++++++------ include/extern.h | 2 +- src/getpos.c | 7 ++++--- src/hack.c | 24 ++++++++++++++++-------- src/pager.c | 8 ++++---- src/weapon.c | 2 +- 6 files changed, 35 insertions(+), 23 deletions(-) diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 5db50ecec..c4c43a420 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -2024,10 +2024,13 @@ when a monster within a gas cloud was displayed on the map because the hero was next to it, it remained displayed if hero moved away eating a pyrolisk egg on the floor triggered an "object lost" panic core object creation and the curses interface's window handling both became - confused by the 'pauper' option/conduct because they assumed that invent - being Null meant that the game hadn't started yet -wizards were discovering unread spellbooks whenever any skill was advanced; do so - only when a spell skill is advanced + confused by the 'pauper' option/conduct because they assumed that + invent being Null meant that the game hadn't started yet +wizards were discovering unread spellbooks whenever any skill was advanced; + do so only when a spell skill is advanced +if tips were enabled, the getpos/farlook tip clobbered the initial prompt (at + least for tty's one line message window), so reissue the prompt after + the tip has been displayed Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository @@ -2189,8 +2192,8 @@ curses: if messages have been issued during start-up (for instance, warnings documentation: when building plain text Guidebook.txt from Guidebook.mn, avoid attempting to use CR font; change doesn't affect building Guidebook.ps which utilizes CR to get various instances of fixed-width text -documentation: improve Guidebook *roff formatting and prepare for use of future release - of groff 1.24.0 (pr #1280 by g-branden-robinson) +documentation: improve Guidebook *roff formatting and prepare for use of + future release of groff 1.24.0 (pr #1280 by g-branden-robinson) macOS: Xcode project was failing to build if the path to the NetHack source tree contained a space; the issue was within some shell script code contained within the project diff --git a/include/extern.h b/include/extern.h index 152dfaee6..2b675eb3b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1152,7 +1152,7 @@ extern void impact_disturbs_zombies(struct obj *, boolean) NONNULLARG1; extern void disturb_buried_zombies(coordxy, coordxy); extern boolean u_maybe_impaired(void); extern const char *u_locomotion(const char *) NONNULLARG1; -extern void handle_tip(int); +extern boolean handle_tip(int); extern void domove(void); extern void runmode_delay_output(void); extern void overexert_hp(void); diff --git a/src/getpos.c b/src/getpos.c index 1e0c813d2..0152fba53 100644 --- a/src/getpos.c +++ b/src/getpos.c @@ -4,7 +4,7 @@ #include "hack.h" -extern const char what_is_an_unknown_object[]; /* from pager.c */ +extern const char what_is_a_location[]; /* from pager.c */ staticfn void getpos_toggle_hilite_state(void); staticfn void getpos_getvalids_selection(struct selectionvar *, @@ -265,7 +265,7 @@ getpos_help(boolean force, const char *goal) /* disgusting hack; the alternate selection characters work for any getpos call, but only matter for dowhatis (and doquickwhatis, also for dotherecmdmenu's simulated mouse) */ - doing_what_is = (goal == what_is_an_unknown_object); + doing_what_is = (goal == what_is_a_location); if (doing_what_is) { Sprintf(kbuf, "'%s' or '%s' or '%s' or '%s'", visctrl(gc.Cmd.spkeys[NHKF_GETPOS_PICK]), @@ -816,7 +816,8 @@ getpos(coord *ccp, boolean force, const char *goal) mMoOdDxX[i] = gc.Cmd.spkeys[mMoOdDxX_def[i]]; mMoOdDxX[SIZE(mMoOdDxX_def)] = '\0'; - handle_tip(TIP_GETPOS); + if (handle_tip(TIP_GETPOS)) + show_goal_msg = TRUE; /* tip has overwritten prompt in mesg window */ if (!goal) goal = "desired location"; diff --git a/src/hack.c b/src/hack.c index e1c576f94..b1838f2ef 100644 --- a/src/hack.c +++ b/src/hack.c @@ -1760,25 +1760,26 @@ u_simple_floortyp(coordxy x, coordxy y) return ROOM; } -/* maybe show a helpful gameplay tip? */ -void +/* maybe show a helpful gameplay tip? returns True if tip gets shown */ +boolean handle_tip(int tip) { if (!flags.tips) - return; + return FALSE; if (tip >= 0 && tip < NUM_TIPS && !svc.context.tips[tip]) { svc.context.tips[tip] = TRUE; + /* the "Tip:" prefix is a hint to use of OPTIONS=!tips to suppress */ switch (tip) { case TIP_ENHANCE: - pline("(Use the #enhance command to advance them.)"); + pline("(Tip: use the #enhance command to advance them.)"); break; case TIP_SWIM: - pline("(Use '%s' prefix to step in if you really want to.)", + pline("(Tip: use '%s' prefix to step in if you really want to.)", visctrl(cmd_from_func(do_reqmenu))); break; case TIP_UNTRAP_MON: - pline("(Perhaps #untrap would help?)"); + pline("(Tip: perhaps #untrap would help?)"); break; case TIP_GETPOS: l_nhcore_call(NHCORE_GETPOS_TIP); @@ -1787,7 +1788,9 @@ handle_tip(int tip) impossible("Unknown tip in handle_tip(%i)", tip); break; } + return TRUE; } + return FALSE; } /* Is it dangerous for hero to move to x,y due to water or lava? */ @@ -1823,7 +1826,7 @@ swim_move_danger(coordxy x, coordxy y) You("avoid %s into the %s.", ing_suffix(u_locomotion("step")), waterbody_name(x, y)); - handle_tip(TIP_SWIM); + (void) handle_tip(TIP_SWIM); return TRUE; } } @@ -2056,7 +2059,7 @@ domove_swap_with_pet(struct monst *mtmp, coordxy x, coordxy y) which = just_an(anbuf, what); /* "a " or "an " */ } You("stop. %s can't move out of %s%s.", YMonnam(mtmp), which, what); - handle_tip(TIP_UNTRAP_MON); + (void) handle_tip(TIP_UNTRAP_MON); didnt_move = TRUE; } else if (mtmp->mpeaceful && (!goodpos(u.ux0, u.uy0, mtmp, 0) @@ -2687,6 +2690,11 @@ domove_core(void) /* check for discovered trap */ && (trap = t_at(x, y)) != 0 && trap->tseen /* check whether attempted move will be viable */ + /* + * FIXME: + * this will result in "Really step into trap?" if there is a + * peaceful or tame monster already there. + */ && test_move(u.ux, u.uy, u.dx, u.dy, TEST_MOVE) /* override confirmation if the trap is harmless to the hero */ && (immune_to_trap(&gy.youmonst, trap->ttyp) != TRAP_CLEARLY_IMMUNE diff --git a/src/pager.c b/src/pager.c index eff6bfd6b..ee69943b4 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1627,7 +1627,7 @@ add_quoted_engraving(coordxy x, coordxy y, char *buf) } /* also used by getpos hack in getpos.c */ -const char what_is_an_unknown_object[] = "an unknown object"; +const char what_is_a_location[] = "a monster, object or location"; int do_look(int mode, coord *click_cc) @@ -1833,11 +1833,11 @@ do_look(int mode, coord *click_cc) if (from_screen) { if (flags.verbose) pline("Please move the cursor to %s.", - what_is_an_unknown_object); + what_is_a_location); else - pline("Pick an object."); + pline("Pick %s.", what_is_a_location); - ans = getpos(&cc, quick, what_is_an_unknown_object); + ans = getpos(&cc, quick, what_is_a_location); if (ans < 0 || cc.x < 0) break; /* done */ flags.verbose = FALSE; /* only print long question once */ diff --git a/src/weapon.c b/src/weapon.c index e10c456fa..d65c64945 100644 --- a/src/weapon.c +++ b/src/weapon.c @@ -79,7 +79,7 @@ give_may_advance_msg(int skill) : (skill <= P_LAST_WEAPON) ? "weapon " : (skill <= P_LAST_SPELL) ? "spell casting " : "fighting "); - handle_tip(TIP_ENHANCE); + (void) handle_tip(TIP_ENHANCE); } /* weapon's skill category name for use as generalized description of weapon;