From: PatR Date: Tue, 31 Mar 2020 09:38:12 +0000 (-0700) Subject: 'submerged' status condition X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aff1f4c37997e1fe43db3ab94e167f4f8a70a641;p=nethack 'submerged' status condition Setting up the flag for the submerged condition was unnecessarily complicated. The display code distinguishes between being inside water on Plane of Water and being underwater elsewhere (I'm not sure why...) but as far as hero and player are concerned, being submerged in water is the same on the Water level as anywhere else. It actually is different; levitation and flying can't take the hero above the surface because there isn't one, but that doesn't mean that 'submerged' should be suppressed from status there. --- diff --git a/src/botl.c b/src/botl.c index 5fcfca6d8..13647581e 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 botl.c $NHDT-Date: 1584350350 2020/03/16 09:19:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.186 $ */ +/* NetHack 3.6 botl.c $NHDT-Date: 1585647484 2020/03/31 09:38:04 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.187 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -618,8 +618,6 @@ int cond_idx[CONDITION_COUNT] = { 0 }; static boolean cache_avail[3] = { FALSE, FALSE, FALSE }; static boolean cache_reslt[3] = { FALSE, FALSE, FALSE }; static const char *cache_nomovemsg = NULL, *cache_multi_reason = NULL; -static d_level cache_uz = { 0 }; -static boolean cache_underwater = FALSE; #define cond_cache_prepA() \ do { \ @@ -651,18 +649,6 @@ do { \ } \ } while (0) -#define cond_cache_prepB() \ -do { \ - if (((cache_uz.dnum != u.uz.dnum) \ - || (cache_uz.dlevel != u.uz.dlevel)) \ - || (cache_underwater != Underwater)) { \ - cache_uz.dnum = 0; \ - cache_uz.dlevel = 0; \ - cache_underwater = 0; \ - cache_reslt[2] = cache_avail[2] = FALSE; \ - } \ -} while (0) - /* we don't put this next declaration in #ifdef STATUS_HILITES. * In the absence of STATUS_HILITES, each array * element will be 0 however, and quite meaningless, @@ -830,8 +816,7 @@ bot_via_windowport() for that cache lifetime. There is caching of that nature done for unconsc (1) and parlyz (2) because the suggested way of being able to distinguish unconsc, parlyz, sleeping, and busy involves multiple - string comparisons. There is also caching done for submerged (3) to - avoid repeatedly calling the on_level() function unnecessarily. */ + string comparisons. */ #define test_if_enabled(c) if (condtests[(c)].enabled) condtests[(c)].test @@ -882,9 +867,10 @@ bot_via_windowport() condtests[bl_stone].test = (Stoned) ? TRUE : FALSE; condtests[bl_strngl].test = (Strangled) ? TRUE : FALSE; condtests[bl_stun].test = (Stunned) ? TRUE : FALSE; + condtests[bl_submerged].test = (Underwater) ? TRUE : FALSE; test_if_enabled(bl_elf_iron) = (FALSE); test_if_enabled(bl_bareh) = (!uarmg && !uwep); - test_if_enabled(bl_icy) = levl[u.ux][u.uy].typ == ICE; + test_if_enabled(bl_icy) = (levl[u.ux][u.uy].typ == ICE); test_if_enabled(bl_slippery) = (Glib) ? TRUE : FALSE; test_if_enabled(bl_woundedl) = (Wounded_legs); @@ -915,25 +901,6 @@ bot_via_windowport() condtests[bl_sleeping].test = condtests[bl_busy].test = FALSE; } - /* submerged */ - if (condtests[bl_submerged].enabled) { - cond_cache_prepB(); - if (!cache_avail[2] && cache_underwater == 0 - && (cache_uz.dlevel == 0 && cache_uz.dnum == 0)) { - cache_uz = u.uz; - cache_underwater = (Underwater) ? TRUE : FALSE; - cache_reslt[2] = (Underwater && !Is_waterlevel(&u.uz)); - cache_avail[2] = TRUE; - } - if (cache_avail[2]) { - condtests[bl_submerged].test = cache_reslt[2]; - } else { - condtests[bl_submerged].test = FALSE; - } - } else { - condtests[bl_submerged].test = FALSE; - } - #define cond_bitset(c) \ g.blstats[idx][BL_CONDITION].a.a_ulong |= conditions[(c)].mask;