mons[NUMMONS] tweak
Add a couple of non-zero permonst flags to the terminator at the end of mons[] in case some code using a pointer to mons[NUMMONS] for "not a monster" unexpectedly references them. Also, eliminate some obsolete handling for conditional color support from monst.c.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 monsters.h $NHDT-Date: 1703845746 2023/12/29 10:29:06 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.117 $ */
|
||||
/* NetHack 3.7 monsters.h $NHDT-Date: 1705092146 2024/01/12 20:42:26 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.119 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2006. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -3351,6 +3351,12 @@
|
||||
| M2_STRONG | M2_COLLECT | M2_MAGIC,
|
||||
M3_INFRAVISIBLE, 8, HI_DOMESTIC, APPRENTICE),
|
||||
|
||||
/*
|
||||
* mons_init() in monst.c adds a terminator here, mons[NUMMONS].
|
||||
* It is part of the mons[] array without introducing another type
|
||||
* of monster.
|
||||
*/
|
||||
|
||||
#if defined(MONS_ENUM) || defined(DUMP_ENUMS)
|
||||
#undef MON
|
||||
#undef MON3
|
||||
|
||||
49
src/monst.c
49
src/monst.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.7 monst.c $NHDT-Date: 1682205027 2023/04/22 23:10:27 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.97 $ */
|
||||
/* NetHack 3.7 monst.c $NHDT-Date: 1705092160 2024/01/12 20:42:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Michael Allison, 2006. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -8,63 +8,60 @@
|
||||
#include "wintype.h"
|
||||
#include "sym.h"
|
||||
|
||||
#ifdef C
|
||||
#undef C
|
||||
#endif
|
||||
#include "color.h"
|
||||
#define C(color) color
|
||||
|
||||
#define NO_ATTK \
|
||||
{ \
|
||||
0, 0, 0, 0 \
|
||||
}
|
||||
#define NO_ATTK { 0, 0, 0, 0 }
|
||||
|
||||
/* monster type with single name */
|
||||
#define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \
|
||||
flg1, flg2, flg3, d, col, bn) \
|
||||
{ \
|
||||
{ (const char *) 0, (const char *) 0, nam }, \
|
||||
PM_##bn, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, C(col) \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
||||
}
|
||||
|
||||
/* monster type with distinct male, female, neuter names */
|
||||
#define MON3(namm, namf, namn, sym, lvl, gen, atk, siz, mr1, mr2, \
|
||||
flg1, flg2, flg3, d, col, bn) \
|
||||
{ \
|
||||
{ namm, namf, namn }, \
|
||||
PM_##bn, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, C(col) \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
||||
}
|
||||
|
||||
/* LVL() and SIZ() collect several fields to cut down on number of args
|
||||
* for MON()
|
||||
* for MON()/MON3().
|
||||
*/
|
||||
#define LVL(lvl, mov, ac, mr, aln) lvl, mov, ac, mr, aln
|
||||
#define SIZ(wt, nut, snd, siz) wt, nut, snd, siz
|
||||
/* ATTK() and A() are to avoid braces and commas within args to MON() */
|
||||
#define ATTK(at, ad, n, d) \
|
||||
{ \
|
||||
at, ad, n, d \
|
||||
}
|
||||
#define A(a1, a2, a3, a4, a5, a6) \
|
||||
{ \
|
||||
a1, a2, a3, a4, a5, a6 \
|
||||
}
|
||||
#define ATTK(at, ad, n, d) { at, ad, n, d }
|
||||
#define A(a1, a2, a3, a4, a5, a6) { a1, a2, a3, a4, a5, a6 }
|
||||
|
||||
struct permonst mons_init[NUMMONS + 1] = {
|
||||
#include "monsters.h"
|
||||
/*
|
||||
* array terminator
|
||||
* Array terminator, added to the end of the entries in monsters.h.
|
||||
*
|
||||
* mons[NUMMONS] used to be all zero except "" instead of Null for
|
||||
* the name field. Then the index field was added and the terminator
|
||||
* uses NON_PM for that. Now, a few monster flags also get set.
|
||||
*/
|
||||
#undef MON
|
||||
#define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \
|
||||
flg1, flg2, flg3, d, col, bn) \
|
||||
{ \
|
||||
{ (const char *) 0, (const char *) 0, nam }, \
|
||||
NON_PM, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, C(col) \
|
||||
NON_PM, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
||||
}
|
||||
MON("", 0, LVL(0, 0, 0, 0, 0), (0),
|
||||
MON("", 0, LVL(0, 0, 0, 0, 0),
|
||||
G_NOGEN | G_NOCORPSE,
|
||||
A(NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK),
|
||||
SIZ(0, 0, 0, 0), 0, 0, 0L, 0L, 0, 0, 0, 0),
|
||||
SIZ(0, 0, 0, 0), 0, 0,
|
||||
0L, M2_NOPOLY, 0,
|
||||
0, 0, 0),
|
||||
};
|
||||
|
||||
#undef MON
|
||||
@@ -86,8 +83,6 @@ const struct attack c_sa_no[NATTK] = SEDUCTION_ATTACKS_NO;
|
||||
|
||||
/* for 'onefile' processing where end of this file isn't necessarily the
|
||||
end of the source code seen by the compiler */
|
||||
#undef C
|
||||
#define C(c) (0x1f & (c)) /* global.h */
|
||||
#undef NO_ATTK
|
||||
#undef LVL
|
||||
#undef SIZ
|
||||
|
||||
Reference in New Issue
Block a user