adjust sample config file when STATUS_HILITES isn't defined
On Windows, if you build without STATUS_HILITES defined, you'll be greeted by the following barrage of errors when you start the game. On Windows, use makedefs to detect that STATUS_HILITES isn't defined, and comment out the offending lines in the sample config file. Errors received before this change: OPTIONS=statushilites * Line 197: 'statushilites' is not supported. OPTIONS=hilite_status:hitpoints/100%/gray&normal * Line 200: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<100%/green&normal * Line 201: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<66%/yellow&normal * Line 202: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<50%/orange&normal * Line 203: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<33%/red&bold * Line 204: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<15%/red&inverse * Line 205: 'hilite_status' is not supported. OPTIONS=hilite_status:power/100%/gray&normal * Line 208: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<100%/green&normal * Line 209: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<66%/yellow&normal * Line 210: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<50%/orange&normal * Line 211: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<33%/red&bold * Line 212: 'hilite_status' is not supported. OPTIONS=hilite_status:cap/burdened/yellow/stressed/orange/strained/red&bold/ove rtaxed/red&inverse/overloaded/red&inverse&blink * Line 215: 'hilite_status' is not supported. OPTIONS=hilite_status:hunger/satiated/yellow/hungry/orange/weak/red&bold/fainti ng/red&inverse/fainted/red&inverse&blink * Line 218: 'hilite_status' is not supported. Hit <Enter> to continue.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user