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:
nhmall
2023-11-23 12:22:47 -05:00
parent 99141b3242
commit 2a48859de2
6 changed files with 37 additions and 41 deletions

View File

@@ -1695,7 +1695,6 @@ extern struct attack *dmgtype_fromattack(struct permonst *, int, int);
extern boolean dmgtype(struct permonst *, int);
extern int max_passive_dmg(struct monst *, struct monst *);
extern boolean same_race(struct permonst *, struct permonst *);
extern int monsndx(struct permonst *);
extern int name_to_mon(const char *, int *);
extern int name_to_monplus(const char *, const char **, int *);
extern int name_to_monclass(const char *, int *);