Windows options dynamically
There are two executables int the windows binary, each of which have different options and capabilities. Sharing of one dat/options file hasn't really been an accurate approach. Produce that information dynamically for the Windows exe files. This impacts alt-v results.
This commit is contained in:
@@ -35,6 +35,8 @@
|
||||
|
||||
#define QWERTZ_SUPPORT /* when swap_yz is True, numpad 7 is 'z' not 'y' */
|
||||
|
||||
#define OPTIONS_AT_RUNTIME /* build info done at runtime not text file */
|
||||
|
||||
/*
|
||||
* -----------------------------------------------------------------
|
||||
* The remaining code shouldn't need modification.
|
||||
|
||||
@@ -25,9 +25,6 @@ early_init()
|
||||
decl_globals_init();
|
||||
objects_globals_init();
|
||||
monst_globals_init();
|
||||
#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET)
|
||||
runtime_info_init();
|
||||
#endif
|
||||
sys_early_init();
|
||||
}
|
||||
|
||||
|
||||
141
src/mdlib.c
141
src/mdlib.c
@@ -47,7 +47,12 @@
|
||||
#endif
|
||||
#endif /* !MAKEDEFS_C */
|
||||
|
||||
#if defined(MAKEDEFS_C) || defined(CROSSCOMPILE_TARGET)
|
||||
/* shorten up some lines */
|
||||
#if defined(CROSSCOMPILE_TARGET) || defined(OPTIONS_AT_RUNTIME)
|
||||
#define FOR_RUNTIME
|
||||
#endif
|
||||
|
||||
#if defined(MAKEDEFS_C) || defined(FOR_RUNTIME)
|
||||
/* REPRODUCIBLE_BUILD will change this to TRUE */
|
||||
static boolean date_via_env = FALSE;
|
||||
|
||||
@@ -58,9 +63,14 @@ static char *FDECL(bannerc_string, (char *, const char *));
|
||||
static int FDECL(case_insensitive_comp, (const char *, const char *));
|
||||
static void NDECL(make_version);
|
||||
static char *FDECL(eos, (char *));
|
||||
#endif /* MAKEDEFS_C || CROSSCOMPILE_TARGET */
|
||||
static char *FDECL(mdlib_strsubst, (char *, const char *, const char *));
|
||||
#endif /* MAKEDEFS_C || FOR_RUNTIME */
|
||||
#if !defined(MAKEDEFS_C) && defined(WIN32)
|
||||
extern int GUILaunched;
|
||||
#endif
|
||||
|
||||
void NDECL(build_options);
|
||||
static int NDECL(count_and_validate_winopts);
|
||||
static void FDECL(opt_out_words, (char *, int *));
|
||||
static void NDECL(build_savebones_compat_string);
|
||||
static int idxopttext, done_runtime_opt_init_once = 0;
|
||||
@@ -74,6 +84,7 @@ static const char opt_indent[] = " ";
|
||||
struct win_info {
|
||||
const char *id, /* DEFAULT_WINDOW_SYS string */
|
||||
*name; /* description, often same as id */
|
||||
boolean valid;
|
||||
};
|
||||
|
||||
static struct win_info window_opts[] = {
|
||||
@@ -85,42 +96,43 @@ static struct win_info window_opts[] = {
|
||||
confusing to most users (and it will already be listed separately
|
||||
in the compiled options section so users aware of it can find it) */
|
||||
#ifdef MSDOS
|
||||
"traditional text with optional 'tiles' graphics"
|
||||
"traditional text with optional 'tiles' graphics",
|
||||
#else
|
||||
/* assume that one or more of IBMgraphics, DECgraphics, or MACgraphics
|
||||
can be enabled; we can't tell from here whether that is accurate */
|
||||
"traditional text with optional line-drawing"
|
||||
"traditional text with optional line-drawing",
|
||||
#endif
|
||||
TRUE
|
||||
},
|
||||
#endif /*TTY_GRAPHICS */
|
||||
#ifdef CURSES_GRAPHICS
|
||||
{ "curses", "terminal-based graphics" },
|
||||
{ "curses", "terminal-based graphics", TRUE },
|
||||
#endif
|
||||
#ifdef X11_GRAPHICS
|
||||
{ "X11", "X11" },
|
||||
{ "X11", "X11", TRUE },
|
||||
#endif
|
||||
#ifdef QT_GRAPHICS /* too vague; there are multiple incompatible versions */
|
||||
{ "Qt", "Qt" },
|
||||
{ "Qt", "Qt", TRUE },
|
||||
#endif
|
||||
#ifdef GNOME_GRAPHICS /* unmaintained/defunct */
|
||||
{ "Gnome", "Gnome" },
|
||||
{ "Gnome", "Gnome", TRUE },
|
||||
#endif
|
||||
#ifdef MAC /* defunct OS 9 interface */
|
||||
{ "mac", "Mac" },
|
||||
{ "mac", "Mac", TRUE },
|
||||
#endif
|
||||
#ifdef AMIGA_INTUITION /* unmaintained/defunct */
|
||||
{ "amii", "Amiga Intuition" },
|
||||
{ "amii", "Amiga Intuition", TRUE },
|
||||
#endif
|
||||
#ifdef GEM_GRAPHICS /* defunct Atari interface */
|
||||
{ "Gem", "Gem" },
|
||||
{ "Gem", "Gem", TRUE },
|
||||
#endif
|
||||
#ifdef MSWIN_GRAPHICS /* win32 */
|
||||
{ "mswin", "mswin" },
|
||||
{ "mswin", "mswin", TRUE },
|
||||
#endif
|
||||
#ifdef BEOS_GRAPHICS /* unmaintained/defunct */
|
||||
{ "BeOS", "BeOS InterfaceKit" },
|
||||
{ "BeOS", "BeOS InterfaceKit", TRUE },
|
||||
#endif
|
||||
{ 0, 0 }
|
||||
{ 0, 0, FALSE }
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -222,7 +234,7 @@ make_version()
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(MAKEDEFS_C) || defined(CROSSCOMPILE_TARGET)
|
||||
#if defined(MAKEDEFS_C) || defined(FOR_RUNTIME)
|
||||
|
||||
static char *
|
||||
version_string(outbuf, delim)
|
||||
@@ -270,7 +282,7 @@ const char *build_date;
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
/* still within #if MAKDEFS_C || CROSSCOMPILE_TARGET */
|
||||
/* still within #if MAKDEFS_C || FOR_RUNTIME */
|
||||
|
||||
static char *
|
||||
bannerc_string(outbuf, build_date)
|
||||
@@ -303,7 +315,7 @@ const char *build_date;
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
#endif /* MAKEDEFS_C || CROSSCOMPILE_TARGET */
|
||||
#endif /* MAKEDEFS_C || FOR_RUNTIME */
|
||||
|
||||
static int
|
||||
case_insensitive_comp(s1, s2)
|
||||
@@ -334,6 +346,25 @@ char *str;
|
||||
return str;
|
||||
}
|
||||
|
||||
static char *
|
||||
mdlib_strsubst(bp, orig, replacement)
|
||||
char *bp;
|
||||
const char *orig, *replacement;
|
||||
{
|
||||
char *found, buf[BUFSZ];
|
||||
|
||||
if (bp) {
|
||||
/* [this could be replaced by strNsubst(bp, orig, replacement, 1)] */
|
||||
found = strstr(bp, orig);
|
||||
if (found) {
|
||||
Strcpy(buf, found + strlen(orig));
|
||||
Strcpy(found, replacement);
|
||||
Strcat(bp, buf);
|
||||
}
|
||||
}
|
||||
return bp;
|
||||
}
|
||||
|
||||
static char save_bones_compat_buf[BUFSZ];
|
||||
|
||||
static void
|
||||
@@ -419,7 +450,7 @@ static const char *build_opts[] = {
|
||||
#ifdef PANICLOG
|
||||
"errors and warnings log file",
|
||||
#endif
|
||||
#ifdef MAIL_STRUCTURES
|
||||
#ifdef MAIL
|
||||
"mail daemon",
|
||||
#endif
|
||||
#if defined(GNUDOS) || defined(__DJGPP__)
|
||||
@@ -540,6 +571,29 @@ static const char *build_opts[] = {
|
||||
"and basic NetHack features"
|
||||
};
|
||||
|
||||
int
|
||||
count_and_validate_winopts(VOID_ARGS)
|
||||
{
|
||||
int i, cnt = 0;
|
||||
|
||||
/* window_opts has a fencepost entry at the end */
|
||||
for (i = 0; i < SIZE(window_opts) - 1; i++) {
|
||||
#if !defined(MAKEDEFS_C) && defined(FOR_RUNTIME)
|
||||
#ifdef WIN32
|
||||
window_opts[i].valid = FALSE;
|
||||
if ((GUILaunched
|
||||
&& case_insensitive_comp(window_opts[i].id, "mswin") != 0)
|
||||
|| (!GUILaunched
|
||||
&& case_insensitive_comp(window_opts[i].id, "mswin") == 0))
|
||||
continue;
|
||||
#endif
|
||||
#endif /* !MAKEDEFS_C && FOR_RUNTIME */
|
||||
++cnt;
|
||||
window_opts[i].valid = TRUE;
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
static void
|
||||
opt_out_words(str, length_p)
|
||||
char *str; /* input, but modified during processing */
|
||||
@@ -575,8 +629,14 @@ void
|
||||
build_options()
|
||||
{
|
||||
char buf[BUFSZ];
|
||||
int i, length, winsyscnt;
|
||||
int i, length, winsyscnt, cnt = 0;
|
||||
const char *defwinsys = DEFAULT_WINDOW_SYS;
|
||||
|
||||
#if !defined (MAKEDEFS_C) && defined(FOR_RUNTIME)
|
||||
#ifdef WIN32
|
||||
defwinsys = GUILaunched ? "mswin" : "tty";
|
||||
#endif
|
||||
#endif
|
||||
build_savebones_compat_string();
|
||||
opttext[idxopttext] = strdup(optbuf);
|
||||
if (idxopttext < (MAXOPT - 1))
|
||||
@@ -602,6 +662,14 @@ build_options()
|
||||
optbuf[0] = '\0';
|
||||
length = COLNO + 1; /* force 1st item onto new line */
|
||||
for (i = 0; i < SIZE(build_opts); i++) {
|
||||
#if !defined(MAKEDEFS_C) && defined(FOR_RUNTIME)
|
||||
#ifdef WIN32
|
||||
/* ignore the console entry if GUI version */
|
||||
if (GUILaunched
|
||||
&& !strcmp("screen control via WIN32 console I/O", build_opts[i]))
|
||||
continue;
|
||||
#endif
|
||||
#endif /* !MAKEDEFS_C && FOR_RUNTIME */
|
||||
opt_out_words(strcat(strcpy(buf, build_opts[i]),
|
||||
(i < SIZE(build_opts) - 1) ? "," : "."),
|
||||
&length);
|
||||
@@ -610,7 +678,7 @@ build_options()
|
||||
if (idxopttext < (MAXOPT - 1))
|
||||
idxopttext++;
|
||||
optbuf[0] = '\0';
|
||||
winsyscnt = SIZE(window_opts) - 1;
|
||||
winsyscnt = count_and_validate_winopts();
|
||||
opttext[idxopttext] = strdup(optbuf);
|
||||
if (idxopttext < (MAXOPT - 1))
|
||||
idxopttext++;
|
||||
@@ -621,7 +689,10 @@ build_options()
|
||||
idxopttext++;
|
||||
optbuf[0] = '\0';
|
||||
length = COLNO + 1; /* force 1st item onto new line */
|
||||
for (i = 0; i < winsyscnt; i++) {
|
||||
|
||||
for (i = 0; i < SIZE(window_opts) - 1; i++) {
|
||||
if (!window_opts[i].valid)
|
||||
continue;
|
||||
Sprintf(buf, "\"%s\"", window_opts[i].id);
|
||||
if (strcmp(window_opts[i].name, window_opts[i].id))
|
||||
Sprintf(eos(buf), " (%s)", window_opts[i].name);
|
||||
@@ -630,22 +701,26 @@ build_options()
|
||||
* 2 : foo and bar (note no period; comes from 'with default' below)
|
||||
* 3+: for, bar, and quux
|
||||
*/
|
||||
opt_out_words(strcat(buf, (winsyscnt == 1) ? "." /* no 'default' */
|
||||
: (winsyscnt == 2 && i == 0) ? " and"
|
||||
: (i == winsyscnt - 2) ? ", and"
|
||||
: ","),
|
||||
&length);
|
||||
if (cnt != (winsyscnt - 1)) {
|
||||
Strcat(buf, (winsyscnt == 1) ? "." /* no 'default' */
|
||||
: (winsyscnt == 2 && cnt == 0) ? " and"
|
||||
: (cnt == winsyscnt - 2) ? ", and"
|
||||
: ",");
|
||||
}
|
||||
opt_out_words(buf, &length);
|
||||
cnt++;
|
||||
}
|
||||
if (winsyscnt > 1) {
|
||||
Sprintf(buf, "with a default of \"%s\".", DEFAULT_WINDOW_SYS);
|
||||
if (cnt > 1) {
|
||||
Sprintf(buf, ", with a default of \"%s\".", defwinsys);
|
||||
opt_out_words(buf, &length);
|
||||
}
|
||||
(void) mdlib_strsubst(optbuf, " , ", ", ");
|
||||
opttext[idxopttext] = strdup(optbuf);
|
||||
if (idxopttext < (MAXOPT - 1))
|
||||
idxopttext++;
|
||||
optbuf[0] = '\0';
|
||||
|
||||
#if defined(MAKEDEFS_C) || (defined(CROSSCOMPILE) && defined(CROSSCOMPILE_TARGET))
|
||||
#if defined(MAKEDEFS_C) || defined(FOR_RUNTIME)
|
||||
{
|
||||
static const char *lua_info[] = {
|
||||
"", "NetHack 3.7.* uses the 'Lua' interpreter to process some data:", "",
|
||||
@@ -673,7 +748,7 @@ build_options()
|
||||
idxopttext++;
|
||||
}
|
||||
}
|
||||
#endif /* MAKEDEFS_C || (CROSSCOMPILE && CROSSCOMPILE_TARGET) */
|
||||
#endif /* MAKEDEFS_C || FOR_RUNTIME */
|
||||
|
||||
/* end with a blank line */
|
||||
opttext[idxopttext] = strdup("");
|
||||
@@ -754,7 +829,7 @@ runtime_info_init()
|
||||
extract_field(tmpbuf, rttimebuf, 2, 18); /* sec */
|
||||
t.tm_sec = atoi(tmpbuf);
|
||||
timeresult = mktime(&t);
|
||||
#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C)
|
||||
#if !defined(MAKEDEFS_C) && defined(CROSSCOMPILE_TARGET)
|
||||
BUILD_TIME = (unsigned long) timeresult;
|
||||
BUILD_DATE = rttimebuf;
|
||||
#endif
|
||||
@@ -762,7 +837,7 @@ runtime_info_init()
|
||||
nhUse(strp);
|
||||
#endif /* __DATE__ && __TIME__ */
|
||||
|
||||
#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C)
|
||||
#if !defined(MAKEDEFS_C) && defined(CROSSCOMPILE_TARGET)
|
||||
VERSION_NUMBER = version.incarnation;
|
||||
VERSION_FEATURES = version.feature_set;
|
||||
#ifdef MD_IGNORED_FEATURES
|
||||
@@ -781,7 +856,7 @@ runtime_info_init()
|
||||
#ifdef NETHACK_HOST_GIT_BRANCH
|
||||
NETHACK_GIT_BRANCH = strdup(NETHACK_HOST_GIT_BRANCH);
|
||||
#endif
|
||||
#endif /* CROSSCOMPILE_TARGET && !MAKEDEFS_C */
|
||||
#endif /* !MAKEDEFS_C && CROSSCOMPILE_TARGET */
|
||||
}
|
||||
idxopttext = 0;
|
||||
build_options();
|
||||
|
||||
@@ -356,13 +356,14 @@ CURSESOBJ= $(O)cursdial.o $(O)cursinit.o $(O)cursinvt.o $(O)cursmain.o \
|
||||
SOBJ = $(O)windmain.o $(O)winnt.o $(O)win10.o \
|
||||
$(O)safeproc.o $(O)nhlan.o $(SOUND)
|
||||
|
||||
OBJS = $(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
|
||||
$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
|
||||
$(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \
|
||||
$(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \
|
||||
$(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
|
||||
$(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(VOBJ30) \
|
||||
$(REGEX) $(CURSESOBJ) $(MDLIB)
|
||||
OBJS = $(MDLIB) \
|
||||
$(VOBJ01) $(VOBJ02) $(VOBJ03) $(VOBJ04) $(VOBJ05) \
|
||||
$(VOBJ06) $(VOBJ07) $(VOBJ08) $(VOBJ09) $(VOBJ10) \
|
||||
$(VOBJ11) $(VOBJ12) $(VOBJ13) $(VOBJ14) $(VOBJ15) \
|
||||
$(VOBJ16) $(VOBJ17) $(VOBJ18) $(VOBJ19) $(VOBJ20) \
|
||||
$(VOBJ21) $(VOBJ22) $(VOBJ23) $(VOBJ24) $(VOBJ25) \
|
||||
$(VOBJ26) $(VOBJ27) $(VOBJ28) $(VOBJ29) $(VOBJ30) \
|
||||
$(REGEX) $(CURSESOBJ)
|
||||
|
||||
WINDHDR = $(MSWSYS)\win10.h $(MSWSYS)\winos.h $(MSWSYS)\win32api.h
|
||||
|
||||
@@ -904,7 +905,7 @@ $(GAMEDIR)\NetHack.exe : $(O)gamedir.tag $(O)tile.o $(O)nttty.o $(O)guistub.o \
|
||||
$(ALLOBJ) $(TTYOBJ) $(O)console.res $(KEYDLLS) \
|
||||
$(LUATARGETS) $(PDCLIB)
|
||||
@if not exist $(GAMEDIR)\*.* mkdir $(GAMEDIR)
|
||||
@echo Linking $(@:\=/)
|
||||
@echo Linking $(@:\=/)
|
||||
$(link) $(lflagsBuild) $(conlflags) /STACK:2048 /PDB:$(GAMEDIR)\$(@B).PDB /MAP:$(O)$(@B).MAP \
|
||||
$(LIBS) $(PDCLIB) $(LUALIB) \
|
||||
$(conlibs) $(BCRYPT) -out:$@ @<<$(@B).lnk
|
||||
@@ -1035,7 +1036,7 @@ $(O)sp_lev.tag:
|
||||
|
||||
$(O)utility.tag: $(INCL)\nhlua.h $(INCL)\date.h $(INCL)\onames.h $(INCL)\pm.h \
|
||||
$(SRC)\vis_tab.c $(INCL)\vis_tab.h $(TILEUTIL16)
|
||||
@echo utilities made >$@
|
||||
@echo utilities made >$@
|
||||
@echo utilities made.
|
||||
|
||||
$(INCL)\nhlua.h:
|
||||
@@ -1193,7 +1194,7 @@ $(O)envchk.tag: $(O)obj.tag
|
||||
# @echo Warning, the CL Environment variable is defined:
|
||||
# @echo CL=$(CL)
|
||||
! ENDIF
|
||||
echo envchk >$@
|
||||
echo envchk >$@
|
||||
|
||||
#==========================================
|
||||
#=========== SECONDARY TARGETS ============
|
||||
@@ -1625,15 +1626,15 @@ spotless: clean
|
||||
if exist $(O)gamedir.tag del $(O)gamedir.tag
|
||||
if exist $(O)nh*key.lib del $(O)nh*key.lib
|
||||
if exist $(O)nh*key.exp del $(O)nh*key.exp
|
||||
if exist $(MSWIN)\mnsel.bmp del $(MSWIN)\mnsel.bmp
|
||||
if exist $(MSWIN)\mnselcnt.bmp del $(MSWIN)\mnselcnt.bmp
|
||||
if exist $(MSWIN)\mnunsel.bmp del $(MSWIN)\mnunsel.bmp
|
||||
if exist $(MSWIN)\petmark.bmp del $(MSWIN)\petmark.bmp
|
||||
if exist $(MSWIN)\pilemark.bmp del $(MSWIN)\pilemark.bmp
|
||||
if exist $(MSWIN)\rip.bmp del $(MSWIN)\rip.bmp
|
||||
if exist $(MSWIN)\splash.bmp del $(MSWIN)\splash.bmp
|
||||
if exist $(MSWIN)\nethack.ico del $(MSWIN)\nethack.ico
|
||||
if exist $(MSWSYS)\nethack.ico del $(MSWSYS)\nethack.ico
|
||||
if exist $(MSWIN)\mnsel.bmp del $(MSWIN)\mnsel.bmp
|
||||
if exist $(MSWIN)\mnselcnt.bmp del $(MSWIN)\mnselcnt.bmp
|
||||
if exist $(MSWIN)\mnunsel.bmp del $(MSWIN)\mnunsel.bmp
|
||||
if exist $(MSWIN)\petmark.bmp del $(MSWIN)\petmark.bmp
|
||||
if exist $(MSWIN)\pilemark.bmp del $(MSWIN)\pilemark.bmp
|
||||
if exist $(MSWIN)\rip.bmp del $(MSWIN)\rip.bmp
|
||||
if exist $(MSWIN)\splash.bmp del $(MSWIN)\splash.bmp
|
||||
if exist $(MSWIN)\nethack.ico del $(MSWIN)\nethack.ico
|
||||
if exist $(MSWSYS)\nethack.ico del $(MSWSYS)\nethack.ico
|
||||
if exist $(U)recover.exe del $(U)recover.exe
|
||||
if exist $(U)tile2bmp.exe del $(U)tile2bmp.exe
|
||||
if exist $(U)tilemap.exe del $(U)tilemap.exe
|
||||
|
||||
Reference in New Issue
Block a user