]> granicus.if.org Git - nethack/commitdiff
Remove obsolete code allowing 1-indexing the monster list
authorAlex Smith <ais523@nethack4.org>
Sat, 15 Jul 2017 00:34:41 +0000 (01:34 +0100)
committerAlex Smith <ais523@nethack4.org>
Sat, 15 Jul 2017 00:34:41 +0000 (01:34 +0100)
Having selectable base indexes for the monster list doesn't seem
likely to be needed in the future any more, now that the code for
the monster list is stable. Additionally, the functionality in
question has bitrotted heavily (e.g. many "loops over all
permonsts" start at a hardcoded 0, which wouldn't work with a
1-indexed monster list). As a result, removing the relevant code
in makedefs makes it clearer what can and can't be assumed about
the code, reducing the risk of bugs in the future.

Thanks to FIQ for mentioning that this could be an issue.

include/permonst.h
util/makedefs.c

index a5c4555c0ae3e05118af29890a76d6a7488c9de1..f70db03f0d7e83e270d475e21cb4749fc22b351d 100644 (file)
@@ -70,7 +70,7 @@ extern NEARDATA struct permonst mons[]; /* the master list of monster types */
 #define FAST_SPEED 15
 #define VERY_FAST 24
 
-#define NON_PM PM_PLAYERMON          /* "not a monster" */
+#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
index 7ebd5136bf55c62d7d1104830c2e26f72b5d7f62..92d1feb897e2a3cce1be0f9ba251066fbcea1847 100644 (file)
@@ -2224,9 +2224,6 @@ do_permonst()
     Fprintf(ofp, "%s", Dont_Edit_Code);
     Fprintf(ofp, "#ifndef PM_H\n#define PM_H\n");
 
-    if (strcmp(mons[0].mname, "playermon") != 0)
-        Fprintf(ofp, "\n#define\tPM_PLAYERMON\t(-1)");
-
     for (i = 0; mons[i].mlet; i++) {
         SpinCursor(3);