diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 926eed8ad..3f2c76fd5 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -686,7 +686,8 @@ $(O)install.tag: $(DAT)\data $(DAT)\rumors $(DAT)\dungeon \ if exist $(DOC)\nethack.txt copy $(DOC)\nethack.txt $(GAMEDIR)\NetHack.txt @if exist $(GAMEDIR)\NetHack.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHack.PDB to conserve space @if exist $(GAMEDIR)\NetHackW.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHackW.PDB to conserve space - -if not exist $(GAMEDIR)\defaults.nh copy $(MSWSYS)\defaults.nh $(GAMEDIR)\defaults.nh + $(U)makedefs -c + -if not exist $(GAMEDIR)\defaults.nh copy fixed_defaults.nh $(GAMEDIR)\defaults.nh -if not exist $(GAMEDIR)\record. goto>$(GAMEDIR)\record. echo install done > $@ @@ -1359,6 +1360,7 @@ clean: if exist $(U)dgncomp.exe del $(U)dgncomp.exe if exist $(SRC)\*.lnk del $(SRC)\*.lnk if exist $(SRC)\*.map del $(SRC)\*.map + if exist $(SRC)\fixed_defaults.nh del $(SRC)\fixed_defaults.nh if exist $(O)install.tag del $(O)install.tag if exist $(O)console.res del $(O)console.res if exist $(O)dgncomp.MAP del $(O)dgncomp.MAP diff --git a/util/makedefs.c b/util/makedefs.c index 0b97a8bcb..29a528f01 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -111,6 +111,15 @@ static const char SCCS_Id[] UNUSED = "@(#)makedefs.c\t3.6\t2018/03/02"; #endif /* else !MAC */ #endif /* else !AMIGA */ +#if !defined(STATUS_HILITES) && defined(WIN32) +#define FIX_SAMPLECONFIG +#endif + +#ifdef WIN32 +#define SAMPLE_CONFIGFILE "../sys/winnt/defaults.nh" +#define FIXED_CONFIGFILE "./fixed_defaults.nh" +#endif + static const char *Dont_Edit_Code = "/* This source file is generated by 'makedefs'. Do not edit. */\n", @@ -162,6 +171,9 @@ void NDECL(do_questtxt); void NDECL(do_rumors); void NDECL(do_oracles); void NDECL(do_vision); +#ifdef WIN32 +void NDECL(do_fix_sampleconfig); +#endif extern void NDECL(monst_init); /* monst.c */ extern void NDECL(objects_init); /* objects.c */ @@ -364,7 +376,12 @@ char *options; case 'Z': do_vision(); break; - +#ifdef WIN32 + case 'c': + case 'C': + do_fix_sampleconfig(); + break; +#endif default: Fprintf(stderr, "Unknown option '%c'.\n", *options); (void) fflush(stderr); @@ -1457,6 +1474,45 @@ char *githash, *gitbranch; return FALSE; } +#ifdef WIN32 +void +do_fix_sampleconfig() +{ + FILE *scfp, *ofcfp; + char fixedline[600]; + char *line; + + if (!(scfp = fopen(SAMPLE_CONFIGFILE, RDTMODE))) { + return; + } + if (!(ofcfp = fopen(FIXED_CONFIGFILE, WRTMODE))) { + return; + } + + /* read the sample config file */ + while ((line = fgetline(scfp)) != 0) { + /* comment out the STATUS_HILITES related lines */ + if (strlen(line) < (600 - 1)) { + if (strstr(line, "statushilites") || strstr(line, "hilite_status:")) { +#ifdef FIX_SAMPLECONFIG + fixedline[0] = '#'; + Strcpy(&fixedline[1], line); +#else + Strcpy(fixedline, line); +#endif + fputs(fixedline, ofcfp); + } else { + fputs(line, ofcfp); + } + } + free(line); + } + Fclose(scfp); + Fclose(ofcfp); + return; +} +#endif /* WIN32 */ + static int case_insensitive_comp(s1, s2) const char *s1;