incremental improvements to cross-compiling support in NetHack 3.7

Some support of new code #defines to faciliate cross-compiling:

    OPTIONS_AT_RUNTIME    If this is defined, code to support obtaining
                          the compile time options and features is
                          included. If you define this, you'll also have
                          to compile sys/mdlib.c and link the resulting
                          object file into your game binary/executable.

    CROSSCOMPILE          Flags that this is a cross-compiled NetHack build,
                          where there are two stages:
                          1. makedefs and some other utilities are compiled
                          on the host platform and executed there to generate
                          some output files and header files needed by the
                          game.
                          2. the NetHack game files are compiled by a
                          cross-compiler to generate binary/executables for
                          a different platform than the one the build is
                          being run on. The executables produced for the
                          target platform may not be able to execute on the
                          build platform, except perhaps via a software
                          emulator.

                          The 2-stage process (1. host, 2.target) can be done
                          on the same platform to test the cross-compile
                          process. In that case, the host and target platforms
                          would be the same.

    CROSSCOMPILE_HOST     Separates/identifies code paths that should only be
                          be included in the compile on the host side, for
                          utilities that will be run on the host as part of
                          stage 1 to produce output files needed to build the
                          game. Examples are the code for makedefs, tile
                          conversion utilities, uudecode, dlb, etc.

    CROSSCOMPILE_TARGET   Separates/identifies code paths that should be
                          included on the build for the target platform
                          during stage 2, the cross-compiler stage. That
                          includes most of the pieces of the game itself
                          but the code is only flagged as such if it must
                          not execute on the host.

If you don't define any of those, things should build as before.
One follow-on change that is likely required is setting the new dependency
makedefs has on src/mdlib.c in Makefiles etc.

More information about the changes:

    makedefs

    - splinter off some of makedefs functionality into a separate file
      called src/mdlib.c.
        - src/mdlib.c, while included during the compile of makedefs.c
          for producing the makedefs utility, can also be compiled
          as a stand-alone object file for inclusion in the link step
          of your NetHack game build. The src/mdlib.c code can then
          deliver the same functionality that it provided to makedefs
          right to your NetHack game code at run-time.
          For example, do_runtime_info() will provide the caller with
          the features and options that were built into the game.
          Previously, that information was produced at build time on the
          host and stored in a dat file. Under a cross-compile situation,
          those values are highly suspect and might not even reflect the
          correct options and setting for the cross-compiled target
          platform's binary/executable. The compile of those values and
          the functionality to obtain them needs to move to the target
          cross-compiler stage of the build (stage 2).
        - date information on the target-side binary is produced from
          the cross-compiler preprocessor pre-defined macros __DATE__
          and __TIME__, as they reflect the actual compile time of the
          cross-compiled target and not host-side execution of a utility
          to produce them. The cross-compiler itself, through those
          pre-defined preprocessor macros, provides them to the target
          platform binary/executable. They reflect the actual build
          time of the target binary/executable (not values produced
          at the time the makefiles utility was built and the
          appropriate option selected to store them in a text file.)
        - most Makefiles should not require adding the new file
          src/mdlib.c because util/makedefs.c has a preprocessor
          include "../src/mdlib.c" to draw in its contents. As previously
          stated though, the Makefile dependency may be required:
		makedefs.o: ../util/makedefs.c ../src/mdlib.c
                                               ^^^^^^^^^^^^^^^
This commit is contained in:
nhmall
2019-11-22 22:35:48 -05:00
parent c9e7182f43
commit 1e0c03b3f6
18 changed files with 1501 additions and 1085 deletions

View File

@@ -25,6 +25,9 @@ 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();
}

761
src/mdlib.c Normal file
View File

@@ -0,0 +1,761 @@
/* NetHack 3.7 mdlib.c $NHDT-Date: 1562180226 2019/07/03 18:57:06 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.149 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Kenneth Lorber, Kensington, Maryland, 2015. */
/* Copyright (c) M. Stephenson, 1990, 1991. */
/* Copyright (c) Dean Luick, 1990. */
/* NetHack may be freely redistributed. See license for details. */
/*
* This can be linked into a binary to provide the functionality
* via the contained functions, or it can be #included directly
* into util/makedefs.c to provide it there.
*/
#ifndef MAKEDEFS_C
#define MDLIB_C
#include "config.h"
#ifdef MONITOR_HEAP
#undef free /* makedefs, mdlib don't use the alloc and free in src/alloc.c */
#endif
#include "permonst.h"
#include "objclass.h"
#include "monsym.h"
#include "artilist.h"
#include "dungeon.h"
#include "obj.h"
#include "monst.h"
#include "you.h"
#include "context.h"
#include "flag.h"
#include "dlb.h"
#include <ctype.h>
/* version information */
#ifdef SHORT_FILENAMES
#include "patchlev.h"
#else
#include "patchlevel.h"
#endif
#define Fprintf (void) fprintf
#define Fclose (void) fclose
#define Unlink (void) unlink
#if !defined(AMIGA) || defined(AZTEC_C)
#define rewind(fp) fseek((fp), 0L, SEEK_SET) /* guarantee a return value */
#endif /* AMIGA || AZTEC_C */
#endif /* !MAKEDEFS_C */
void NDECL(build_options);
static char *FDECL(bannerc_string, (char *, const char *));
static void FDECL(opt_out_words, (char *, int *));
static void NDECL(build_savebones_compat_string);
static int idxopttext, done_runtime_opt_init_once = 0;
#define MAXOPT 30
static char rttimebuf[MAXOPT];
static char *opttext[ROWNO] = {0};
char optbuf[BUFSZ];
static struct version_info version;
static const char opt_indent[] = " ";
#ifndef MAKEDEFS_C
static int FDECL(case_insensitive_comp, (const char *, const char *));
static void NDECL(make_version);
static char *FDECL(version_id_string, (char *, const char *));
static char *FDECL(version_string, (char *, const char *));
static char *FDECL(eos, (char *));
/* REPRODUCIBLE_BUILD will change this to TRUE */
static boolean date_via_env = FALSE;
#endif /* !MAKEDEFS_C */
struct win_info {
const char *id, /* DEFAULT_WINDOW_SYS string */
*name; /* description, often same as id */
};
static struct win_info window_opts[] = {
#ifdef TTY_GRAPHICS
{ "tty",
/* testing 'USE_TILES' here would bring confusion because it could
apply to another interface such as X11, so check MSDOS explicitly
instead; even checking TTY_TILES_ESCCODES would probably be
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"
#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"
#endif
},
#endif /*TTY_GRAPHICS */
#ifdef CURSES_GRAPHICS
{ "curses", "terminal-based graphics" },
#endif
#ifdef X11_GRAPHICS
{ "X11", "X11" },
#endif
#ifdef QT_GRAPHICS /* too vague; there are multiple incompatible versions */
{ "Qt", "Qt" },
#endif
#ifdef GNOME_GRAPHICS /* unmaintained/defunct */
{ "Gnome", "Gnome" },
#endif
#ifdef MAC /* defunct OS 9 interface */
{ "mac", "Mac" },
#endif
#ifdef AMIGA_INTUITION /* unmaintained/defunct */
{ "amii", "Amiga Intuition" },
#endif
#ifdef GEM_GRAPHICS /* defunct Atari interface */
{ "Gem", "Gem" },
#endif
#ifdef MSWIN_GRAPHICS /* win32 */
{ "mswin", "mswin" },
#endif
#ifdef BEOS_GRAPHICS /* unmaintained/defunct */
{ "BeOS", "BeOS InterfaceKit" },
#endif
{ 0, 0 }
};
/*
* Use this to explicitly mask out features during version checks.
*
* ZEROCOMP, RLECOMP, and ZLIB_COMP describe compression features
* that the port/plaform which wrote the savefile was capable of
* dealing with. Don't reject a savefile just because the port
* reading the savefile doesn't match on all/some of them.
* The actual compression features used to produce the savefile are
* recorded in the savefile_info structure immediately following the
* version_info, and that is what needs to be checked against the
* feature set of the port that is reading the savefile back in.
* That check is done in src/restore.c now.
*
*/
#ifndef MD_IGNORED_FEATURES
#define MD_IGNORED_FEATURES \
(0L | (1L << 19) /* SCORE_ON_BOTL */ \
| (1L << 27) /* ZEROCOMP */ \
| (1L << 28) /* RLECOMP */ \
)
#endif /* MD_IGNORED_FEATUES */
static void
make_version()
{
register int i;
/*
* integer version number
*/
version.incarnation = ((unsigned long) VERSION_MAJOR << 24)
| ((unsigned long) VERSION_MINOR << 16)
| ((unsigned long) PATCHLEVEL << 8)
| ((unsigned long) EDITLEVEL);
/*
* encoded feature list
* Note: if any of these magic numbers are changed or reassigned,
* EDITLEVEL in patchlevel.h should be incremented at the same time.
* The actual values have no special meaning, and the category
* groupings are just for convenience.
*/
version.feature_set = (unsigned long) (0L
/* levels and/or topology (0..4) */
/* monsters (5..9) */
#ifdef MAIL_STRUCTURES
| (1L << 6)
#endif
/* objects (10..14) */
/* flag bits and/or other global variables (15..26) */
#ifdef TEXTCOLOR
| (1L << 17)
#endif
#ifdef INSURANCE
| (1L << 18)
#endif
#ifdef SCORE_ON_BOTL
| (1L << 19)
#endif
/* data format (27..31)
* External compression methods such as COMPRESS and ZLIB_COMP
* do not affect the contents and are thus excluded from here */
#ifdef ZEROCOMP
| (1L << 27)
#endif
#ifdef RLECOMP
| (1L << 28)
#endif
);
/*
* Value used for object & monster sanity check.
* (NROFARTIFACTS<<24) | (NUM_OBJECTS<<12) | (NUMMONS<<0)
*/
for (i = 1; artifact_names[i]; i++)
continue;
version.entity_count = (unsigned long) (i - 1);
for (i = 1; objects[i].oc_class != ILLOBJ_CLASS; i++)
continue;
version.entity_count = (version.entity_count << 12) | (unsigned long) i;
for (i = 0; mons[i].mlet; i++)
continue;
version.entity_count = (version.entity_count << 12) | (unsigned long) i;
/*
* Value used for compiler (word size/field alignment/padding) check.
*/
version.struct_sizes1 =
(((unsigned long) sizeof(struct context_info) << 24)
| ((unsigned long) sizeof(struct obj) << 17)
| ((unsigned long) sizeof(struct monst) << 10)
| ((unsigned long) sizeof(struct you)));
version.struct_sizes2 = (((unsigned long) sizeof(struct flag) << 10) |
/* free bits in here */
#ifdef SYSFLAGS
((unsigned long) sizeof(struct sysflag)));
#else
((unsigned long) 0L));
#endif
return;
}
static char *
version_string(outbuf, delim)
char *outbuf;
const char *delim;
{
Sprintf(outbuf, "%d%s%d%s%d", VERSION_MAJOR, delim, VERSION_MINOR, delim,
PATCHLEVEL);
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
Sprintf(eos(outbuf), "-%d", EDITLEVEL);
#endif
return outbuf;
}
static char *
version_id_string(outbuf, build_date)
char *outbuf;
const char *build_date;
{
char subbuf[64], versbuf[64];
char betabuf[64];
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
#if (NH_DEVEL_STATUS == NH_STATUS_BETA)
Strcpy(betabuf, " Beta");
#else
Strcpy(betabuf, " Work-in-progress");
#endif
#else
betabuf[0] = '\0';
#endif
subbuf[0] = '\0';
#ifdef PORT_SUB_ID
subbuf[0] = ' ';
Strcpy(&subbuf[1], PORT_SUB_ID);
#endif
Sprintf(outbuf, "%s NetHack%s Version %s%s - last %s %s.", PORT_ID,
subbuf, version_string(versbuf, "."), betabuf,
date_via_env ? "revision" : "build", build_date);
return outbuf;
}
static char *
bannerc_string(outbuf, build_date)
char *outbuf;
const char *build_date;
{
char subbuf[64], versbuf[64];
subbuf[0] = '\0';
#ifdef PORT_SUB_ID
subbuf[0] = ' ';
Strcpy(&subbuf[1], PORT_SUB_ID);
#endif
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
#if (NH_DEVEL_STATUS == NH_STATUS_BETA)
Strcat(subbuf, " Beta");
#else
Strcat(subbuf, " Work-in-progress");
#endif
#endif
Sprintf(outbuf, " Version %s %s%s, %s %s.",
version_string(versbuf, "."), PORT_ID, subbuf,
date_via_env ? "revised" : "built", &build_date[4]);
#if 0
Sprintf(outbuf, "%s NetHack%s %s Copyright 1985-%s (built %s)",
PORT_ID, subbuf, version_string(versbuf,"."), RELEASE_YEAR,
&build_date[4]);
#endif
return outbuf;
}
static int
case_insensitive_comp(s1, s2)
const char *s1;
const char *s2;
{
uchar u1, u2;
for (;; s1++, s2++) {
u1 = (uchar) *s1;
if (isupper(u1))
u1 = tolower(u1);
u2 = (uchar) *s2;
if (isupper(u2))
u2 = tolower(u2);
if (u1 == '\0' || u1 != u2)
break;
}
return u1 - u2;
}
static char *
eos(str)
char *str;
{
while (*str)
str++;
return str;
}
static char save_bones_compat_buf[BUFSZ];
static void
build_savebones_compat_string()
{
#ifdef VERSION_COMPATIBILITY
unsigned long uver = VERSION_COMPATIBILITY;
#endif
Strcpy(save_bones_compat_buf,
"save and bones files accepted from version");
#ifdef VERSION_COMPATIBILITY
Sprintf(eos(save_bones_compat_buf), "s %lu.%lu.%lu through %d.%d.%d",
((uver & 0xFF000000L) >> 24), ((uver & 0x00FF0000L) >> 16),
((uver & 0x0000FF00L) >> 8), VERSION_MAJOR, VERSION_MINOR,
PATCHLEVEL);
#else
Sprintf(eos(save_bones_compat_buf), " %d.%d.%d only", VERSION_MAJOR,
VERSION_MINOR, PATCHLEVEL);
#endif
}
static const char *build_opts[] = {
#ifdef AMIGA_WBENCH
"Amiga WorkBench support",
#endif
#ifdef ANSI_DEFAULT
"ANSI default terminal",
#endif
#ifdef TEXTCOLOR
"color",
#endif
#ifdef TTY_GRAPHICS
#ifdef TTY_TILES_ESCCODES
"console escape codes for tile hinting",
#endif
#endif
#ifdef COM_COMPL
"command line completion",
#endif
#ifdef LIFE
"Conway's Game of Life",
#endif
#ifdef COMPRESS
"data file compression",
#endif
#ifdef ZLIB_COMP
"ZLIB data file compression",
#endif
#ifdef DLB
#ifndef VERSION_IN_DLB_FILENAME
"data librarian",
#else
"data librarian with a version-dependent name",
#endif
#endif
#ifdef DUMPLOG
"end-of-game dumplogs",
#endif
#ifdef HOLD_LOCKFILE_OPEN
"exclusive lock on level 0 file",
#endif
#if defined(MSGHANDLER) && (defined(POSIX_TYPES) || defined(__GNUC__))
"external program as a message handler",
#endif
#ifdef MFLOPPY
"floppy drive support",
#endif
#ifdef INSURANCE
"insurance files for recovering from crashes",
#endif
#ifdef LOGFILE
"log file",
#endif
#ifdef XLOGFILE
"extended log file",
#endif
#ifdef PANICLOG
"errors and warnings log file",
#endif
#ifdef MAIL_STRUCTURES
"mail daemon",
#endif
#if defined(GNUDOS) || defined(__DJGPP__)
"MSDOS protected mode",
#endif
#ifdef NEWS
"news file",
#endif
#ifdef OVERLAY
#ifdef MOVERLAY
"MOVE overlays",
#else
#ifdef VROOMM
"VROOMM overlays",
#else
"overlays",
#endif
#endif
#endif
/* pattern matching method will be substituted by nethack at run time */
"pattern matching via :PATMATCH:",
#ifdef USE_ISAAC64
"pseudo random numbers generated by ISAAC64",
#ifdef DEV_RANDOM
#ifdef NHSTDC
/* include which specific one */
"strong PRNG seed available from " DEV_RANDOM,
#else
"strong PRNG seed available from DEV_RANDOM",
#endif
#else
#ifdef WIN32
"strong PRNG seed available from CNG BCryptGenRandom()",
#endif
#endif /* DEV_RANDOM */
#else /* ISAAC64 */
#ifdef RANDOM
"pseudo random numbers generated by random()",
#else
"pseudo random numbers generated by C rand()",
#endif
#endif /* ISAAC64 */
#ifdef SELECTSAVED
"restore saved games via menu",
#endif
#ifdef SCORE_ON_BOTL
"score on status line",
#endif
#ifdef CLIPPING
"screen clipping",
#endif
#ifdef NO_TERMS
#ifdef MAC
"screen control via mactty",
#endif
#ifdef SCREEN_BIOS
"screen control via BIOS",
#endif
#ifdef SCREEN_DJGPPFAST
"screen control via DJGPP fast",
#endif
#ifdef SCREEN_VGA
"screen control via VGA graphics",
#endif
#ifdef WIN32CON
"screen control via WIN32 console I/O",
#endif
#endif /* NO_TERMS */
#ifdef SHELL
"shell command",
#endif
"traditional status display",
#ifdef STATUS_HILITES
"status via windowport with highlighting",
#else
"status via windowport without highlighting",
#endif
#ifdef SUSPEND
"suspend command",
#endif
#ifdef TTY_GRAPHICS
#ifdef TERMINFO
"terminal info library",
#else
#if defined(TERMLIB) || (!defined(MICRO) && !defined(WIN32))
"terminal capability library",
#endif
#endif
#endif /*TTY_GRAPHICS*/
#ifdef USE_XPM
"tiles file in XPM format",
#endif
#ifdef GRAPHIC_TOMBSTONE
"graphical RIP screen",
#endif
#ifdef TIMED_DELAY
"timed wait for display effects",
#endif
#ifdef USER_SOUNDS
"user sounds",
#endif
#ifdef PREFIXES_IN_USE
"variable playground",
#endif
#ifdef VISION_TABLES
"vision tables",
#endif
#ifdef ZEROCOMP
"zero-compressed save files",
#endif
#ifdef RLECOMP
"run-length compression of map in save files",
#endif
#ifdef SYSCF
"system configuration at run-time",
#endif
save_bones_compat_buf,
"and basic NetHack features"
};
static void
opt_out_words(str, length_p)
char *str; /* input, but modified during processing */
int *length_p; /* in/out */
{
char *word;
while (*str) {
word = index(str, ' ');
#if 0
/* treat " (" as unbreakable space */
if (word && *(word + 1) == '(')
word = index(word + 1, ' ');
#endif
if (word)
*word = '\0';
if (*length_p + (int) strlen(str) > COLNO - 5) {
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
Sprintf(optbuf, "%s", opt_indent),
*length_p = (int) strlen(opt_indent);
} else {
Sprintf(eos(optbuf), " "), (*length_p)++;
}
Sprintf(eos(optbuf),
"%s", str), *length_p += (int) strlen(str);
str += strlen(str) + (word ? 1 : 0);
}
}
void
build_options()
{
char buf[BUFSZ];
int i, length, winsyscnt;
build_savebones_compat_string();
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
Sprintf(optbuf,
"%sNetHack version %d.%d.%d%s\n",
opt_indent,
VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
#if (NH_DEVEL_STATUS == NH_STATUS_BETA)
" [beta]"
#else
" [work-in-progress]"
#endif
#else
""
#endif /* NH_DEVEL_STATUS == NH_STATUS_RELEASED */
);
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
Sprintf(optbuf,
"Options compiled into this edition:");
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
optbuf[0] = '\0';
length = COLNO + 1; /* force 1st item onto new line */
for (i = 0; i < SIZE(build_opts); i++) {
opt_out_words(strcat(strcpy(buf, build_opts[i]),
(i < SIZE(build_opts) - 1) ? "," : "."),
&length);
}
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
optbuf[0] = '\0';
winsyscnt = SIZE(window_opts) - 1;
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
Sprintf(optbuf, "Supported windowing system%s:",
(winsyscnt > 1) ? "s" : "");
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
optbuf[0] = '\0';
length = COLNO + 1; /* force 1st item onto new line */
for (i = 0; i < winsyscnt; i++) {
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);
/*
* 1 : foo.
* 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 (winsyscnt > 1) {
Sprintf(buf, "with a default of \"%s\".", DEFAULT_WINDOW_SYS);
opt_out_words(buf, &length);
}
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
optbuf[0] = '\0';
/* end with a blank line */
opttext[idxopttext] = strdup(optbuf);
if (idxopttext < (MAXOPT - 1))
idxopttext++;
optbuf[0] = '\0';
return;
}
#if defined(__DATE__) && defined(__TIME__)
#define extract_field(t,s,n,z) \
do { \
for (i = 0; i < n; ++i) \
t[i] = s[i + z]; \
t[i] = '\0'; \
} while (0)
#endif
void
runtime_info_init()
{
int i;
char tmpbuf[BUFSZ], *strp;
const char *mth[] = {
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
struct tm t = {0};
time_t timeresult;
if (!done_runtime_opt_init_once) {
done_runtime_opt_init_once = 1;
build_savebones_compat_string();
/* construct the current version number */
make_version();
/*
* In a cross-compiled environment, you can't execute
* the target binaries during the build, so we can't
* use makedefs to write the values of the build
* date and time to a file for retrieval. Not for
* information meaningful to the target execution
* environment.
*
* How can we capture the build date/time of the target
* binaries in such a situation? We need to rely on the
* cross-compiler itself to do it for us during the
* cross-compile.
*
* To that end, we are going to make use of the
* following pre-defined preprocessor macros for this:
* gcc, msvc, clang __DATE__ "Feb 12 1996"
* gcc, msvc, clang __TIME__ "23:59:01"
*
*/
#if defined(__DATE__) && defined(__TIME__)
if (sizeof __DATE__ + sizeof __TIME__ + sizeof "123" <
sizeof rttimebuf)
Sprintf(rttimebuf, "%s %s", __DATE__, __TIME__);
/* "Feb 12 1996 23:59:01"
01234567890123456789 */
if ((int) strlen(rttimebuf) == 20) {
extract_field(tmpbuf, rttimebuf, 4, 7); /* year */
t.tm_year = atoi(tmpbuf) - 1900;
extract_field(tmpbuf, rttimebuf, 3, 0); /* mon */
for (i = 0; i < SIZE(mth); ++i)
if (!case_insensitive_comp(tmpbuf, mth[i])) {
t.tm_mon = i;
break;
}
extract_field(tmpbuf, rttimebuf, 2, 4); /* mday */
strp = tmpbuf;
if (*strp == ' ')
strp++;
t.tm_mday = atoi(strp);
extract_field(tmpbuf, rttimebuf, 2, 12); /* hour */
t.tm_hour = atoi(tmpbuf);
extract_field(tmpbuf, rttimebuf, 2, 15); /* min */
t.tm_min = atoi(tmpbuf);
extract_field(tmpbuf, rttimebuf, 2, 18); /* sec */
t.tm_sec = atoi(tmpbuf);
timeresult = mktime(&t);
#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C)
BUILD_TIME = (unsigned long) timeresult;
BUILD_DATE = rttimebuf;
#endif
#else /* __DATE__ && __TIME__ */
nhUse(strp);
#endif /* __DATE__ && __TIME__ */
#if defined(CROSSCOMPILE_TARGET) && !defined(MAKEDEFS_C)
VERSION_NUMBER = version.incarnation;
VERSION_FEATURES = version.feature_set;
#ifdef MD_IGNORED_FEATURES
IGNORED_FEATURES = MD_IGNORED_FEATURES;
#endif
VERSION_SANITY1 = version.entity_count;
VERSION_SANITY2 = version.struct_sizes1;
VERSION_SANITY3 = version.struct_sizes2;
VERSION_STRING = strdup(version_string(tmpbuf, "."));
VERSION_ID = strdup(version_id_string(tmpbuf, BUILD_DATE));
COPYRIGHT_BANNER_C = strdup(bannerc_string(tmpbuf, BUILD_DATE));
#ifdef HOST_NETHACK_GIT_SHA
NETHACK_GIT_SHA = strdup(HOST_NETHACK_GIT_SHA);
#endif
#ifdef HOST_NETHACK_GIT_BRANCH
NETHACK_GIT_BRANCH = strdup(HOST_NETHACK_GIT_BRANCH);
#endif
#endif /* CROSSCOMPILE_TARGET && !MAKEDEFS_C */
}
idxopttext = 0;
build_options();
}
}
const char *
do_runtime_info(rtcontext)
int *rtcontext;
{
const char *retval = (const char *) 0;
if (!done_runtime_opt_init_once)
runtime_info_init();
if (idxopttext && rtcontext)
if (*rtcontext >= 0 && *rtcontext < (MAXOPT - 1)) {
retval = opttext[*rtcontext];
*rtcontext += 1;
}
return retval;
}
/*mdlib.c*/

View File

@@ -1,5 +1,5 @@
/* NetHack 3.7 sfdata.c $Date$ $Revision$ */
/* Copyright (c) NetHack Development Team 2018. */
/* NetHack 3.7 sfdata.c */
/* Copyright (c) NetHack Development Team 2019. */
/* NetHack may be freely redistributed. See license for details. */
/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE! */
@@ -12,9 +12,6 @@
#include "wintype.h"
#include "sfproto.h"
#define BUILD_DATE "Tue Jun 25 09:57:33 2019"
#define BUILD_TIME (1561471053L)
#define NHTYPE_SIMPLE 1
#define NHTYPE_COMPLEX 2
struct nhdatatypes_t {

View File

@@ -19,11 +19,44 @@
#include "patchlevel.h"
#endif
#if defined(CROSSCOMPILE)
struct cross_target_s cross_target = {
/* https://groups.google.com/forum/#!original/
comp.sources.games/91SfKYg_xzI/dGnR3JnspFkJ */
"Tue, 28-Jul-87 13:18:57 EDT",
"Version 1.0, built Jul 28 13:18:57 1987.",
"0000000000000000000000000000000000000000",
"master",
"1.0.0-0",
"NetHack Version 1.0.0-0 - last build Tue Jul 28 13:18:57 1987.",
0x01010000UL,
0x00000000UL,
0x00000000UL,
0x00000000UL,
0x00000000UL,
0x00000000UL,
554476737UL,
};
#endif /* CROSSCOMPILE */
#if defined(NETHACK_GIT_SHA)
const char *NetHack_git_sha = NETHACK_GIT_SHA;
const char *NetHack_git_sha
#if !defined(CROSSCOMPILE) || (defined(CROSSCOMPILE) && defined(CROSSCOMPILE_HOST))
= NETHACK_GIT_SHA
#else
= NETHACK_HOST_GIT_SHA
#endif
;
#endif
#if defined(NETHACK_GIT_BRANCH)
const char *NetHack_git_branch = NETHACK_GIT_BRANCH;
const char *NetHack_git_branch
#if !defined(CROSSCOMPILE) || (defined(CROSSCOMPILE) && defined(CROSSCOMPILE_HOST))
= NETHACK_GIT_BRANCH
#else
= NETHACK_HOST_GIT_BRANCH
#endif
;
#endif
static void FDECL(insert_rtoption, (char *));
@@ -98,7 +131,12 @@ doversion()
int
doextversion()
{
#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET)
const char *rtbuf;
int rtcontext = 0;
#else
dlb *f;
#endif
char buf[BUFSZ], *p = 0;
winid win = create_nhwindow(NHW_TEXT);
@@ -119,12 +157,15 @@ doextversion()
putstr(win, 0, p);
}
#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET)
#else
f = dlb_fopen(OPTIONS_USED, "r");
if (!f) {
putstr(win, 0, "");
Sprintf(buf, "[Configuration '%s' not available?]", OPTIONS_USED);
putstr(win, 0, buf);
} else {
#endif
/*
* already inserted above:
* + outdented program name and version plus build date and time
@@ -146,8 +187,15 @@ doextversion()
*/
boolean prolog = TRUE; /* to skip indented program name */
#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET)
while ((rtbuf = do_runtime_info(&rtcontext))) {
if ((int) strlen(rtbuf) >= (BUFSZ - 1))
continue;
Strcpy(buf, rtbuf);
#else
while (dlb_fgets(buf, BUFSZ, f)) {
(void) strip_newline(buf);
#endif
if (index(buf, '\t') != 0)
(void) tabexpand(buf);
@@ -167,10 +215,16 @@ doextversion()
if (*buf)
putstr(win, 0, buf);
}
#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET)
#else
(void) dlb_fclose(f);
#endif
display_nhwindow(win, FALSE);
destroy_nhwindow(win);
#if defined(OPTIONS_AT_RUNTIME) || defined(CROSSCOMPILE_TARGET)
#else
}
#endif
return 0;
}
@@ -370,11 +424,23 @@ void
store_version(nhfp)
NHFILE *nhfp;
{
#if !defined(CROSSCOMPILE) || (defined(CROSSCOMPILE) && defined(CROSSCOMPILE_HOST))
static const struct version_info version_data = {
VERSION_NUMBER, VERSION_FEATURES,
VERSION_SANITY1, VERSION_SANITY2, VERSION_SANITY3
#else
struct version_info version_data = {
0UL,0UL,0UL,0UL,0Ul
#endif
};
#if defined(CROSSCOMPILE) && !defined(CROSSCOMPILE_HOST)
version_data.incarnation = VERSION_NUMBER; /* actual version number */
version_data.feature_set = VERSION_FEATURES; /* bitmask of config settings */
version_data.entity_count = VERSION_SANITY1; /* # of monsters and objects */
version_data.struct_sizes1 = VERSION_SANITY2; /* size of key structs */
version_data.struct_sizes2 = VERSION_SANITY3; /* size of more key structs */
#endif
if (nhfp->structlevel) {
bufoff(nhfp->fd);
/* bwrite() before bufon() uses plain write() */