include the PM_ index in mons (permonst)
This is useful for debugging and it allows the index
to be used directly instead of calculated in a
monsndx() function, which has been removed.
I left monsndx() in as a simple short-hand macro for the value
and didn't change the use cases, the reasoning being that this:
monsndx(mon->data)
is arguably a little easier on the eyes than:
mon->data->pmidx
LOW_PM, NON_PM, SPECIAL_PM have been included in the 'enum monnums'
now, instead of as individual macro definitions.
I chose to add the pmidx field as an instance of the enum declaration,
because that has very advantageous results in some debuggers, where it is
then shown as:
pmidx PM_GRAND_MASTER (349) monnums
instead of the less-informative:
pmidx 349 int
Adding the element count to the extern declaration for mons from:
'extern struct permonst *mons[];'
to the more specific declaration to that in src/monst.c:
'extern struct permonst *mons[NUMMONS + 1];'
then allows navigation through the mons array in one of the debuggers.
This commit is contained in:
@@ -18,6 +18,18 @@
|
||||
* for a blinding attack, they determine the amount of time blinded.
|
||||
*/
|
||||
|
||||
enum monnums {
|
||||
#define MONS_ENUM
|
||||
#include "monsters.h"
|
||||
#undef MONS_ENUM
|
||||
NUMMONS,
|
||||
NON_PM = -1, /* "not a monster */
|
||||
LOW_PM = NON_PM + 1, /* first monster in mons */
|
||||
SPECIAL_PM = PM_LONG_WORM_TAIL /* [normal] < ~ < [special] */
|
||||
/* mons[SPECIAL_PM] through mons[NUMMONS-1], inclusive, are
|
||||
never generated randomly and cannot be polymorphed into */
|
||||
};
|
||||
|
||||
struct attack {
|
||||
uchar aatyp;
|
||||
uchar adtyp, damn, damd;
|
||||
@@ -42,6 +54,7 @@ struct attack {
|
||||
|
||||
struct permonst {
|
||||
const char *pmnames[NUM_MGENDERS];
|
||||
const enum monnums pmidx; /* mons array index aka PM_ identifier */
|
||||
char mlet; /* symbol */
|
||||
schar mlevel, /* base monster level */
|
||||
mmove, /* move speed */
|
||||
@@ -60,17 +73,10 @@ struct permonst {
|
||||
mflags2; /* more boolean bitflags */
|
||||
unsigned short mflags3; /* yet more boolean bitflags */
|
||||
uchar difficulty; /* toughness (formerly from makedefs -m) */
|
||||
uchar mcolor; /* color to use */
|
||||
uchar mcolor; /* color to use */
|
||||
};
|
||||
|
||||
extern NEARDATA struct permonst mons[]; /* the master list of monster types */
|
||||
|
||||
enum monnums {
|
||||
#define MONS_ENUM
|
||||
#include "monsters.h"
|
||||
#undef MONS_ENUM
|
||||
NUMMONS
|
||||
};
|
||||
extern NEARDATA struct permonst mons[NUMMONS + 1]; /* the master list of monster types */
|
||||
|
||||
#define VERY_SLOW 3
|
||||
#define SLOW_SPEED 9
|
||||
@@ -78,12 +84,6 @@ enum monnums {
|
||||
#define FAST_SPEED 15
|
||||
#define VERY_FAST 24
|
||||
|
||||
#define NON_PM (-1) /* "not a monster" */
|
||||
#define LOW_PM (NON_PM + 1) /* first monster in mons[] */
|
||||
#define SPECIAL_PM PM_LONG_WORM_TAIL /* [normal] < ~ < [special] */
|
||||
/* mons[SPECIAL_PM] through mons[NUMMONS-1], inclusive, are
|
||||
never generated randomly and cannot be polymorphed into */
|
||||
|
||||
#ifdef PMNAME_MACROS
|
||||
#define pmname(pm,g) ((((g) == MALE || (g) == FEMALE) && (pm)->pmnames[g]) \
|
||||
? (pm)->pmnames[g] : (pm)->pmnames[NEUTRAL])
|
||||
|
||||
Reference in New Issue
Block a user