makedefs: add enum support when generating pm.h
Only changes pm.h content if ENUM_PM is defined when compiling util/makedefs.c While NON_PM and LOW_PM could be included, it would require for the makedefs.c compile, as well as an around their macro definitions in permonst.h so for now those particular lines are commented out in makedefs.c
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(IncDir);$(SysWinntDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32CON;DLB;MSWIN_GRAPHICS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32CON;DLB;MSWIN_GRAPHICS;ENUM_PM;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
@@ -59,4 +59,4 @@
|
||||
<Target Name="AfterRebuild">
|
||||
<MSBuild Projects="aftermakedefs.proj" Targets="Build" Properties="Configuration=$(Configuration)" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user