From 346cd9e35b13c8bc257a9eca42331df9505d009a Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 6 Nov 2023 16:32:32 -0500 Subject: [PATCH 1/4] Revert part of "Fix: hurtling into wall of water" Turns out this change to more accurately describe the wall of water in a situation that shouldn't come up in-game messed up some uses of dfeature_at which do a string comparison between the result and "pool of water" to determine how to behave. --- src/invent.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/invent.c b/src/invent.c index 14f86cea2..35af3bd5c 100644 --- a/src/invent.c +++ b/src/invent.c @@ -4216,8 +4216,6 @@ dfeature_at(coordxy x, coordxy y, char *buf) cmap = S_lava; /* "molten lava" */ else if (is_ice(x, y)) dfeature = ice_descr(x, y, altbuf), cmap = -1; /* "ice" */ - else if (IS_WATERWALL(ltyp)) - dfeature = "wall of water"; else if (is_pool(x, y)) dfeature = "pool of water"; else if (IS_SINK(ltyp)) From 702f9143064091cd0286c8540d2f9748e1b9a56f Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 6 Nov 2023 16:44:37 -0500 Subject: [PATCH 2/4] pooleffects messaging vs mention_decor With mention_decor enabled, exiting the water on the Plane of Water would produce the series of messages "You pop into an air bubble. You are back on air bubble." Suppress the second message. The lack of article there seems like a problem too... Also, acknowledge flight/levitation and use ice_descr in the pooleffects "solid land" message. This should make it more consistent with how mention_decor does a similar message, especially changes to how it describes ice based on its melt timer. --- src/hack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/hack.c b/src/hack.c index 29076de11..47dc27afb 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2822,11 +2822,15 @@ pooleffects( if (!is_pool(u.ux, u.uy)) { if (Is_waterlevel(&u.uz)) { You("pop into an air bubble."); + iflags.last_msg = PLNMSG_BACK_ON_GROUND; } else if (is_lava(u.ux, u.uy)) { You("leave the %s...", hliquid("water")); /* oops! */ } else { - You("are on solid %s again.", - is_ice(u.ux, u.uy) ? "ice" : "land"); + char icebuf[BUFSZ]; + You("are %s %s again.", + (Levitation || Flying) ? "over" : "on", + is_ice(u.ux, u.uy) ? ice_descr(u.ux, u.uy, icebuf) + : "solid land"); iflags.last_msg = PLNMSG_BACK_ON_GROUND; } } else if (Is_waterlevel(&u.uz)) { From 53be8be3e9a6dd6e550139ae7445a2f77032bdd9 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 6 Nov 2023 17:14:41 -0500 Subject: [PATCH 3/4] Fix: mention_decor preposition vs unusual terrain When moving off a body of water with mention_decor on, describe_decor() would produce messages like "You are back on cloud", "You are back on wall", and "You are back on air bubble." For those types of terrain that were producing odd sentences like this, change the format to "You are back in a cloud", "You are back in a wall", "You are back in an air bubble", and "You are back in the air." --- src/pickup.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pickup.c b/src/pickup.c index df524e476..f258d437c 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -384,17 +384,22 @@ describe_decor(void) || IS_LAVA(iflags.prev_decor) || iflags.prev_decor == ICE) { if (iflags.last_msg != PLNMSG_BACK_ON_GROUND) { - const char *surf = is_ice(u.ux, u.uy) - ? ice_descr(u.ux, u.uy, fbuf) - : surface(u.ux, u.uy); + const char *preposit = (Levitation || Flying) ? "over" : "on", + *surf = surface(u.ux, u.uy); - if (!strcmpi(surf, "floor") || !strcmpi(surf, "ground")) + if (is_ice(u.ux, u.uy)) { + surf = ice_descr(u.ux, u.uy, fbuf); + } else if (!strcmpi(surf, "floor") + || !strcmpi(surf, "ground")) { surf = "solid ground"; + } else { /* "cloud", "air", "air bubble", "wall" */ + surf = !strcmp(surf, "air") ? the(surf) : an(surf); + preposit = "in"; + } pline("%s %s %s.", flags.verbose ? "You are back" : "Back", - (Levitation || Flying) ? "over" : "on", surf); + preposit, surf); } - } } iflags.prev_decor = ltyp; From a1b1f3b250beaac9395158794dc06d76ed174b3b Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Mon, 6 Nov 2023 17:50:25 -0500 Subject: [PATCH 4/4] Try to unify "back on solid ground" messaging Put everything through a single function that can handle all the complicated parts of using the correct proposition for different terrain types, and will not just call things "solid ground" indiscriminately. This got complicated but I'm not sure if it's possible to do it much simpler while still using the distinct names for each type of terrain (unless you are OK with the sentences sounding sort of wonky). --- include/extern.h | 3 ++- src/hack.c | 6 +----- src/pickup.c | 16 +--------------- src/pray.c | 4 ++-- src/trap.c | 43 +++++++++++++++++++++++++++++++++++++++---- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/include/extern.h b/include/extern.h index 604b341c9..65c4ba256 100644 --- a/include/extern.h +++ b/include/extern.h @@ -2949,7 +2949,8 @@ extern void acid_damage(struct obj *); extern int water_damage(struct obj *, const char *, boolean); extern void water_damage_chain(struct obj *, boolean); extern boolean rnd_nextto_goodpos(coordxy *, coordxy *, struct monst *); -extern void back_on_ground(int); +extern void back_on_ground(boolean); +extern void rescued_from_terrain(int); extern boolean drown(void); extern void drain_en(int, boolean); extern int dountrap(void); diff --git a/src/hack.c b/src/hack.c index 47dc27afb..5e44d2867 100644 --- a/src/hack.c +++ b/src/hack.c @@ -2826,11 +2826,7 @@ pooleffects( } else if (is_lava(u.ux, u.uy)) { You("leave the %s...", hliquid("water")); /* oops! */ } else { - char icebuf[BUFSZ]; - You("are %s %s again.", - (Levitation || Flying) ? "over" : "on", - is_ice(u.ux, u.uy) ? ice_descr(u.ux, u.uy, icebuf) - : "solid land"); + back_on_ground(FALSE); iflags.last_msg = PLNMSG_BACK_ON_GROUND; } } else if (Is_waterlevel(&u.uz)) { diff --git a/src/pickup.c b/src/pickup.c index f258d437c..a145b8fe0 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -384,21 +384,7 @@ describe_decor(void) || IS_LAVA(iflags.prev_decor) || iflags.prev_decor == ICE) { if (iflags.last_msg != PLNMSG_BACK_ON_GROUND) { - const char *preposit = (Levitation || Flying) ? "over" : "on", - *surf = surface(u.ux, u.uy); - - if (is_ice(u.ux, u.uy)) { - surf = ice_descr(u.ux, u.uy, fbuf); - } else if (!strcmpi(surf, "floor") - || !strcmpi(surf, "ground")) { - surf = "solid ground"; - } else { /* "cloud", "air", "air bubble", "wall" */ - surf = !strcmp(surf, "air") ? the(surf) : an(surf); - preposit = "in"; - } - pline("%s %s %s.", - flags.verbose ? "You are back" : "Back", - preposit, surf); + back_on_ground(FALSE); } } } diff --git a/src/pray.c b/src/pray.c index 8e9f6efa6..5e3d9ed17 100644 --- a/src/pray.c +++ b/src/pray.c @@ -389,8 +389,8 @@ fix_worst_trouble(int trouble) /* teleport should always succeed, but if not, just untrap them */ if (!safe_teleds(TELEDS_NO_FLAGS)) reset_utrap(TRUE); - back_on_ground(DISSOLVED); /* DISSOLVED: pending cause of death - * if trouble didn't get cured */ + rescued_from_terrain(DISSOLVED); /* DISSOLVED: pending cause of death + * if trouble didn't get cured */ break; case TROUBLE_STARVING: /* temporarily lost strength recovery now handled by init_uhunger() */ diff --git a/src/trap.c b/src/trap.c index 7a3ae7ee2..dfaea88c8 100644 --- a/src/trap.c +++ b/src/trap.c @@ -4699,11 +4699,46 @@ rnd_nextto_goodpos(coordxy *x, coordxy *y, struct monst *mtmp) return FALSE; } +/* print a message about being back on the ground after leaving a pool */ +void +back_on_ground(boolean rescued) +{ + const char *preposit = (Levitation || Flying) ? "over" : "on", + *surf = surface(u.ux, u.uy), *you_are_back; + char icebuf[QBUFSZ]; + + if (is_ice(u.ux, u.uy)) { + /* "on ice" */ + surf = ice_descr(u.ux, u.uy, icebuf); + } else if (!strcmpi(surf, "floor") || !strcmpi(surf, "ground")) { + /* "on solid ground" */ + surf = "solid ground"; + } else if (!strcmpi(surf, "bridge") || !strcmpi(surf, "altar") + || !strcmpi(surf, "headstone")) { + /* "on a bridge" */ + surf = an(surf); + } else if (!strcmpi(surf, "stairs") || !strcmpi(surf, "lava") + || !strcmpi(surf, "bottom")) { + /* "on the stairs" */ + surf = the(surf); + } else { /* "cloud", "air", "air bubble", "wall", "fountain", "doorway" */ + /* "in a cloud", "in the air" */ + surf = !strcmp(surf, "air") ? the(surf) : an(surf); + preposit = "in"; + } + if (rescued) { + you_are_back = "You find yourself"; + } else { + you_are_back = flags.verbose ? "You are back" : "Back"; + } + pline("%s %s %s.", you_are_back, preposit, surf); +} + /* life-saving or divine rescue has attempted to get the hero out of hostile terrain and put hero in an unexpected spot or failed due to overfull level and just prevented death so "back on solid ground" may be inappropriate */ void -back_on_ground(int how) +rescued_from_terrain(int how) { static const char find_yourself[] = "find yourself"; struct rm *lev = &levl[u.ux][u.uy]; @@ -4738,7 +4773,7 @@ back_on_ground(int how) break; } if (!mesggiven) - You("%s back on solid %s.", find_yourself, surface(u.ux, u.uy)); + back_on_ground(TRUE); iflags.last_msg = PLNMSG_BACK_ON_GROUND; /* for describe_decor() */ /* feedback just disclosed this */ @@ -4882,7 +4917,7 @@ drown(void) if (u.uinwater) set_uinwater(0); /* u.uinwater = 0 */ - back_on_ground(DROWNING); + rescued_from_terrain(DROWNING); return TRUE; } @@ -6505,7 +6540,7 @@ lava_effects(void) set_itimeout(&HWwalking, 5L); goto burn_stuff; } - back_on_ground(BURNING); + rescued_from_terrain(BURNING); /* normally done via safe_teleds() -> teleds() -> spoteffects() but spoteffects() was no-op when called with nonzero in_lava_effects */