]> granicus.if.org Git - nethack/commitdiff
Designate high altars with dedicated altarmask bit
authorMichael Meyer <me@entrez.cc>
Wed, 22 Sep 2021 20:57:29 +0000 (16:57 -0400)
committerMichael Meyer <me@entrez.cc>
Thu, 5 May 2022 14:26:58 +0000 (10:26 -0400)
High altars and normal temple altars had identical altarmasks, so
there was no way to distinguish between the two based on the altarmask
alone.  Instead, anywhere it was necessary to determine whether an altar
was a high altar included a check whether the hero was currently the
Astral Plane or Moloch's Sanctum, and assumed any temple altar was the
high altar.

Since there's an extra, unused bit in altarmask anyway, use it to
explicitly mark high altars -- the lua level files already distinguish
between normal temple altars and so-called 'sanctum' altars anyway, so
rather than throwing away this distinction when generating the level,
keep it in the altarmask and use it in place of various u.uz checks.

I think this would require incrementing EDITLEVEL again...

include/align.h
include/display.h
src/invent.c
src/music.c
src/pager.c
src/pray.c
src/sp_lev.c

index bb00f2c6e2e12500bd2314cdcf1c859756b8b255..6a2b70a11f17c0301518f49cfe6e37f3651c5e10 100644 (file)
@@ -34,11 +34,13 @@ typedef struct align { /* alignment & record */
 /* Some altars are considered shrines, add a flag for that
    for the altarmask field of struct rm. */
 #define AM_SHRINE       0x08
+/* High altar on Astral plane or Moloch's sanctum */
+#define AM_SANCTUM      0x10
 
 /* special level flags, gone by the time the level has been loaded */
-#define AM_SPLEV_CO     0x10 /* co-aligned: force alignment to match hero's  */
-#define AM_SPLEV_NONCO  0x20 /* non-co-aligned: force alignment to not match */
-#define AM_SPLEV_RANDOM 0x40
+#define AM_SPLEV_CO     0x20 /* co-aligned: force alignment to match hero's  */
+#define AM_SPLEV_NONCO  0x40 /* non-co-aligned: force alignment to not match */
+#define AM_SPLEV_RANDOM 0x80
 
 #define Amask2align(x) \
     ((aligntyp) ((((x) & AM_MASK) == 0) ? A_NONE                \
index b28a31c8e5c08dff4e3ecdc199def8257278c786..1b39414763209ca4c18ce9ecb3e2c7e075c8b143 100644 (file)
@@ -544,10 +544,9 @@ enum glyph_offsets {
             (((mon)->female == 0) ? GLYPH_PET_MALE_OFF : GLYPH_PET_FEM_OFF))
 
 #define altar_to_glyph(amsk) \
-    (((amsk & (AM_MASK | AM_SHRINE)) == AM_NONE)               \
+    (((amsk & (AM_MASK | AM_SHRINE | AM_SANCTUM)) == AM_NONE)  \
        ? (GLYPH_ALTAR_OFF + altar_unaligned)                   \
-       : (((amsk & AM_SHRINE) == AM_SHRINE)                    \
-          && (Is_astralevel(&u.uz) || Is_sanctum(&u.uz)))      \
+       : ((amsk & AM_SANCTUM) == AM_SANCTUM)                   \
           ? (GLYPH_ALTAR_OFF + altar_other)                    \
           : ((amsk & AM_MASK) == AM_CHAOTIC)                   \
             ? (GLYPH_ALTAR_OFF + altar_chaotic)                \
index 4eec12d0413ef4c6ca582c9eb1cc7cbde1d05856..af4ee042001fc503d4f9f28616a5685130dc9843 100644 (file)
@@ -3989,10 +3989,7 @@ dfeature_at(int x, int y, char *buf)
         cmap = S_sink; /* "sink" */
     else if (IS_ALTAR(ltyp)) {
         Sprintf(altbuf, "%saltar to %s (%s)",
-                ((lev->altarmask & AM_SHRINE)
-                 && (Is_astralevel(&u.uz) || Is_sanctum(&u.uz)))
-                    ? "high "
-                    : "",
+                (lev->altarmask & AM_SANCTUM) ? "high " : "",
                 a_gname(),
                 align_str(Amask2align(lev->altarmask & ~AM_SHRINE)));
         dfeature = altbuf;
index 7bb46aa621a8b6ab12e1e401a4438c43d6d1c060..978b8a0f0c51b0cf2f897619dce610f610927734 100644 (file)
@@ -292,12 +292,10 @@ do_earthquake(int force)
                     pline_The("kitchen sink falls%s.", into_a_chasm);
                 goto do_pit;
             case ALTAR:
+                amsk = altarmask_at(x, y);
                 /* always preserve the high altars */
-                if (Is_astralevel(&u.uz) || Is_sanctum(&u.uz))
+                if ((amsk & AM_SANCTUM) != 0)
                     break;
-                /* no need to check for high altar here; we've just
-                   excluded those */
-                amsk = altarmask_at(x, y);
                 algn = Amask2align(amsk & AM_MASK);
                 if (cansee(x, y))
                     pline_The("%s altar falls%s.",
index 06ed6e6f3908dab0aa8277e4fd1c417d21dbd5e5..b7126e578e5ff83624d6feed7b30839894757f73 100644 (file)
@@ -619,13 +619,11 @@ lookat(int x, int y, char *buf, char *monbuf)
             Sprintf(buf, "%s %saltar",
                     /* like endgame high priests, endgame high altars
                        are only recognizable when immediately adjacent */
-                    (Is_astralevel(&u.uz) && !next2u(x, y))
+                    (Is_astralevel(&u.uz) && !next2u(x, y)
+                     && (amsk & AM_SANCTUM))
                         ? "aligned"
                         : align_str(algn),
-                    ((amsk & AM_SHRINE) != 0
-                     && (Is_astralevel(&u.uz) || Is_sanctum(&u.uz)))
-                        ? "high "
-                        : "");
+                    (amsk & AM_SANCTUM) ? "high " : "");
             break;
         case S_ndoor:
             if (is_drawbridge_wall(x, y) >= 0)
index df86537c745ff36602804ea40ac3c804f450859f..d8a3cc97c0886ec4c9309c8ae2b2bbb504705b36 100644 (file)
@@ -1468,8 +1468,7 @@ dosacrifice(void)
         You("are not standing on an altar.");
         return ECMD_OK;
     }
-    highaltar = ((Is_astralevel(&u.uz) || Is_sanctum(&u.uz))
-                 && (levl[u.ux][u.uy].altarmask & AM_SHRINE));
+    highaltar = (levl[u.ux][u.uy].altarmask & AM_SANCTUM);
 
     otmp = floorfood("sacrifice", 1);
     if (!otmp)
index 1a60b4519d9780d78d0d8a2421f137196d7acbf3..3964515748f33c7b9385e512f48262a19ae00363 100644 (file)
@@ -2330,6 +2330,8 @@ create_altar(altar* a, struct mkroom* croom)
     if (a->shrine) { /* Is it a shrine  or sanctum? */
         priestini(&u.uz, croom, x, y, (a->shrine > 1));
         levl[x][y].altarmask |= AM_SHRINE;
+        if (a->shrine == 2) /* high altar or sanctum */
+            levl[x][y].altarmask |= AM_SANCTUM;
         g.level.flags.has_temple = TRUE;
     }
 }