#define A_COALIGNED 1
#define A_OPALIGNED (-1)
-#define AM_NONE 0
-#define AM_CHAOTIC 1
-#define AM_NEUTRAL 2
-#define AM_LAWFUL 4
-
-#define AM_MASK 7
-/* Some altars are considered as shrines, so we need a flag for that
+/* align masks */
+#define AM_NONE 0x00
+#define AM_CHAOTIC 0x01
+#define AM_NEUTRAL 0x02
+#define AM_LAWFUL 0x04
+#define AM_MASK 0x07 /* mask for "normal" alignment values */
+
+/* Some altars are considered shrines, add a flag for that
for the altarmask field of struct rm. */
-#define AM_SHRINE 8
+#define AM_SHRINE 0x08
/* special level flags, gone by the time the level has been loaded */
-#define AM_SPLEV_CO 3 /* co-aligned: force alignment to match hero's */
-#define AM_SPLEV_NONCO 7 /* non-co-aligned: force alignment to not match */
-#define AM_SPLEV_RANDOM 8
+#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 Amask2align(x) \
((aligntyp) ((((x) & AM_MASK) == 0) ? A_NONE \
static int noncoalignment(aligntyp);
static boolean m_bad_boulder_spot(int, int);
static int pm_to_humidity(struct permonst *);
+static unsigned int sp_amask_to_amask(unsigned int sp_amask);
static void create_monster(monster *, struct mkroom *);
static void create_object(object *, struct mkroom *);
static void create_altar(altar *, struct mkroom *);
return loc;
}
+/*
+ * Convert a special level alignment mask (an alignment mask with possible
+ * extra values/flags) to a "normal" alignment mask (no extra flags).
+ *
+ * When random: there is an 80% chance that the altar will be co-aligned.
+ */
+static unsigned int
+sp_amask_to_amask(unsigned int sp_amask)
+{
+ unsigned int amask;
+
+ if (sp_amask == AM_SPLEV_CO)
+ amask = Align2amask(u.ualignbase[A_ORIGINAL]);
+ else if (sp_amask == AM_SPLEV_NONCO)
+ amask = Align2amask(noncoalignment(u.ualignbase[A_ORIGINAL]));
+ else if (sp_amask == AM_SPLEV_RANDOM)
+ amask = induced_align(80);
+ else
+ amask = sp_amask & AM_MASK;
+
+ return amask;
+}
+
static void
create_monster(monster* m, struct mkroom* croom)
{
struct monst *mtmp;
xchar x, y;
char class;
- aligntyp amask;
+ unsigned int amask;
coord cc;
struct permonst *pm;
unsigned g_mvflags;
if (class == MAXMCLASSES)
panic("create_monster: unknown monster class '%c'", m->class);
- amask = (m->align == AM_SPLEV_CO)
- ? Align2amask(u.ualignbase[A_ORIGINAL])
- : (m->align == AM_SPLEV_NONCO)
- ? Align2amask(noncoalignment(u.ualignbase[A_ORIGINAL]))
- : (m->align == AM_SPLEV_RANDOM)
- ? induced_align(80)
- : m->align;
+ amask = sp_amask_to_amask(m->sp_amask);
if (!class)
pm = (struct permonst *) 0;
if (croom && !inside_room(croom, x, y))
return;
- if (m->align != AM_SPLEV_RANDOM)
+ if (m->sp_amask != AM_SPLEV_RANDOM)
mtmp = mk_roamer(pm, Amask2align(amask), x, y, m->peaceful);
else if (PM_ARCHEOLOGIST <= m->id && m->id <= PM_WIZARD)
mtmp = mk_mplayer(pm, x, y, FALSE);
{
schar sproom;
xchar x = -1, y = -1;
- aligntyp amask;
+ unsigned int amask;
boolean croom_is_temple = TRUE;
int oldtyp;
if (oldtyp == STAIRS || oldtyp == LADDER)
return;
- /* Is the alignment random ?
- * If so, it's an 80% chance that the altar will be co-aligned.
- *
- * The alignment is encoded as amask values instead of alignment
- * values to avoid conflicting with the rest of the encoding,
- * shared by many other parts of the special level code.
- */
- amask = (a->align == AM_SPLEV_CO)
- ? Align2amask(u.ualignbase[A_ORIGINAL])
- : (a->align == AM_SPLEV_NONCO)
- ? Align2amask(noncoalignment(u.ualignbase[A_ORIGINAL]))
- : (a->align == AM_SPLEV_RANDOM)
- ? induced_align(80)
- : a->align;
+ amask = sp_amask_to_amask(a->sp_amask);
levl[x][y].typ = ALTAR;
levl[x][y].altarmask = amask;
tmpmons.name.str = NULL;
tmpmons.appear = 0;
tmpmons.appear_as.str = (char *) 0;
- tmpmons.align = AM_SPLEV_RANDOM;
+ tmpmons.sp_amask = AM_SPLEV_RANDOM;
tmpmons.female = 0;
tmpmons.invis = 0;
tmpmons.cancelled = 0;
tmpmons.name.str = get_table_str_opt(L, "name", NULL);
tmpmons.appear = 0;
tmpmons.appear_as.str = (char *) 0;
- tmpmons.align = get_table_align(L);
+ tmpmons.sp_amask = get_table_align(L);
tmpmons.female = get_table_int_opt(L, "female", 0);
tmpmons.invis = get_table_int_opt(L, "invisible", 0);
tmpmons.cancelled = get_table_int_opt(L, "cancelled", 0);
acoord = SP_COORD_PACK(x, y);
tmpaltar.coord = acoord;
- tmpaltar.align = al;
+ tmpaltar.sp_amask = al;
tmpaltar.shrine = shrine;
create_altar(&tmpaltar, g.coder->croom);