diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 355fe9791..d2dd88414 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -924,7 +924,7 @@ $(O)makedefs.o: $(CONFIG_H) $(INCL)\monattk.h $(INCL)\monflag.h $(INCL)\objcla $(U)makedefs.c @if not exist $(OBJ)\*.* echo creating directory $(OBJ:\=/) @if not exist $(OBJ)\*.* mkdir $(OBJ) - @$(cc) $(cflagsBuild) -Fo$@ $(U)makedefs.c + @$(cc) -DENUM_PM $(cflagsBuild) -Fo$@ $(U)makedefs.c # # date.h should be remade every time any of the source or include diff --git a/util/makedefs.c b/util/makedefs.c index 744ace151..813b649e7 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -218,6 +218,13 @@ static int FDECL(case_insensitive_comp, (const char *, const char *)); /* input, output, tmp */ static FILE *ifp, *ofp, *tfp; +static boolean use_enum = +#ifdef ENUM_PM + TRUE; +#else + FALSE; +#endif + #if defined(__BORLANDC__) && !defined(_WIN32) extern unsigned _stklen = STKSIZ; #endif @@ -2337,10 +2344,20 @@ do_permonst() Fprintf(ofp, "%s", Dont_Edit_Code); Fprintf(ofp, "#ifndef PM_H\n#define PM_H\n"); + if (use_enum) { + Fprintf(ofp, "\nenum monnums {"); +#if 0 + /* need #define ENUM_PM for the full NetHack build to include these */ + Fprintf(ofp, "\n NON_PM = -1,"); + Fprintf(ofp, "\n LOW_PM = 0,"); +#endif + } for (i = 0; mons[i].mlet; i++) { SpinCursor(3); - - Fprintf(ofp, "\n#define\tPM_"); + if (use_enum) + Fprintf(ofp, "\n PM_"); + else + Fprintf(ofp, "\n#define\tPM_"); if (mons[i].mlet == S_HUMAN && !strncmp(mons[i].mname, "were", 4)) Fprintf(ofp, "HUMAN_"); for (nam = c = tmpdup(mons[i].mname); *c; c++) @@ -2348,9 +2365,17 @@ do_permonst() *c -= (char) ('a' - 'A'); else if (*c < 'A' || *c > 'Z') *c = '_'; - Fprintf(ofp, "%s\t%d", nam, i); + if (use_enum) + Fprintf(ofp, "%s = %d,", nam, i); + else + Fprintf(ofp, "%s\t%d", nam, i); + } + if (use_enum) { + Fprintf(ofp, "\n\n NUMMONS = %d", i); + Fprintf(ofp, "\n};\n"); + } else { + Fprintf(ofp, "\n\n#define\tNUMMONS\t%d\n", i); } - Fprintf(ofp, "\n\n#define\tNUMMONS\t%d\n", i); Fprintf(ofp, "\n#endif /* PM_H */\n"); Fclose(ofp); return; diff --git a/win/win32/vs2017/makedefs.vcxproj b/win/win32/vs2017/makedefs.vcxproj index 708802ec9..1f6c1c49f 100644 --- a/win/win32/vs2017/makedefs.vcxproj +++ b/win/win32/vs2017/makedefs.vcxproj @@ -26,7 +26,7 @@ $(IncDir);$(SysWinntDir);%(AdditionalIncludeDirectories) - WIN32CON;DLB;MSWIN_GRAPHICS;%(PreprocessorDefinitions) + WIN32CON;DLB;MSWIN_GRAPHICS;ENUM_PM;%(PreprocessorDefinitions) @@ -59,4 +59,4 @@ - \ No newline at end of file +