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:
@@ -771,26 +771,6 @@ same_race(struct permonst *pm1, struct permonst *pm2)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DISABLE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
/* return an index into the mons array */
|
||||
int
|
||||
monsndx(struct permonst *ptr)
|
||||
{
|
||||
register int i;
|
||||
|
||||
i = (int) (ptr - &mons[0]);
|
||||
if (i < LOW_PM || i >= NUMMONS) {
|
||||
panic("monsndx - could not index monster (%s)",
|
||||
fmt_ptr((genericptr_t) ptr));
|
||||
/*NOTREACHED*/
|
||||
return NON_PM; /* will not get here */
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
RESTORE_WARNING_UNREACHABLE_CODE
|
||||
|
||||
/* for handling alternate spellings */
|
||||
struct alt_spl {
|
||||
const char *name;
|
||||
|
||||
Reference in New Issue
Block a user