From 2185d325c40e038f10d4fb00e430ad664bd13186 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Apr 2023 11:49:09 -0400 Subject: [PATCH] header file changes hack.h, decl.h/.c, system.h, wintty.h - Move secondary preprocessor defines down further in config.h so that they can be overridden via [platform]conf.h which is included from global.h, specifically: LIVELOGFILE when LIVELOG is defined DUMPLOG_FILE when DUMPLOG is defined - Minimize platform-specific, or compiler-specific code in hack.h and decl.h. - reorganize src/decl.c to align with include/decl.h. - a new header file cstd.h added, containing calls to C99 standard header files. - hack.h, decl.h, and decl.c have been cleaned up and had code moved so that things line up as follows: hack.h defines values that are available to all NetHack source files, contains enums for use in all NetHack source files, and contains a number of struct definitions for use in all NetHack source files. It does not contain variable declarations or variable definitions. decl.h contains the extern declarations for variables that are defined in decl.c. These variables are global and available to all NetHack source files. The location of the variables within decl.h was random, so give it some order for now. decl.c contains the definition of the variables declared in decl.h, and initializes them where appropriate. The variable definitions are laid out in much the same order as their declarations in decl.h. - wintty.h: There were some varying terminal-related prototypes in system.h, and that was the only thing left that demanded that system.h be included. Those have been replaced by an #include in include/wintty.h to get the more current (and hopefully more correct) prototypes, rather than hardcoding them in NetHack sources. For edge-case platform compatiblity, there is no #include if the build defines NO_TERMCAP_HEADERS. In that case one set of hardcoded prototypes is still used in include/wintty.h. The added #include "term.h" is also bypassed for NO_TERMS builds (builds that don't link to terminfo/termcap at all, but still present a tty interface using platform or window-port specific functions to fulfill the same role as that of terminfo/termcap). - some scattered, unnecessary #include "integer.h" were removed from various files, since that's always included in current NetHack-3.7 sources, either directly from config.h or indirectly from #include "hack.h". - system.h references removed. - new cstd.h added; the #include "system.h" references in Makefiles and project files (Xcode, visual studio), were replaced with #include "cstd.h" references. A "make depends" is probably warranted. Also: - Use of , which defines clear_screen() as a macro, conflicts with an actual function with that name in win/tty/termcap.c. The most straight-forward course of action was to rename the NetHack function, and change the references to it, from clear_screen() to term_clear_screen(), so that was done. --- include/config.h | 58 +- include/cstd.h | 57 + include/decl.h | 694 +--------- include/hack.h | 1425 ++++++++++++++------ include/pcconf.h | 2 +- include/unixconf.h | 2 +- include/vmsconf.h | 2 +- include/windconf.h | 8 +- include/wintty.h | 25 +- include/wintype.h | 2 - outdated/include/os2conf.h | 9 +- src/decl.c | 151 +-- src/utf8map.c | 1 - sys/msdos/Makefile.GCC | 4 +- sys/msdos/font.c | 1 - sys/msdos/font.h | 2 - sys/msdos/video.c | 2 +- sys/msdos/vidvesa.c | 6 +- sys/msdos/vidvga.c | 6 +- sys/share/pcunix.c | 4 +- sys/unix/Makefile.src | 6 +- sys/unix/NetHack.xcodeproj/project.pbxproj | 4 +- sys/windows/Makefile.nmake | 8 +- sys/windows/consoletty.c | 6 +- sys/windows/vs/NetHack/NetHack.vcxproj | 3 +- sys/windows/vs/NetHackW/NetHackW.vcxproj | 4 +- sys/windows/windmain.c | 8 +- win/share/bmptiles.c | 1 - win/tty/termcap.c | 4 +- win/tty/wintty.c | 12 +- 30 files changed, 1294 insertions(+), 1223 deletions(-) create mode 100644 include/cstd.h diff --git a/include/config.h b/include/config.h index d357fe0ba..8012cb15c 100644 --- a/include/config.h +++ b/include/config.h @@ -624,38 +624,12 @@ typedef unsigned char uchar; #ifdef CHRONICLE /* LIVELOG - log CHRONICLE events into LIVELOGFILE as they happen. */ /* #define LIVELOG */ -#ifdef LIVELOG -#define LIVELOGFILE "livelog" /* in-game events recorded, live */ -#endif /* LIVELOG */ #endif /* CHRONICLE */ #else #undef LIVELOG #endif /* NO_CHRONICLE */ /* #define DUMPLOG */ /* End-of-game dump logs */ -#ifdef DUMPLOG - -#ifndef DUMPLOG_MSG_COUNT -#define DUMPLOG_MSG_COUNT 50 -#endif - -#ifndef DUMPLOG_FILE -#define DUMPLOG_FILE "/tmp/nethack.%n.%d.log" -/* DUMPLOG_FILE allows following placeholders: - %% literal '%' - %v version (eg. "3.6.3-0") - %u game UID - %t game start time, UNIX timestamp format - %T current time, UNIX timestamp format - %d game start time, YYYYMMDDhhmmss format - %D current time, YYYYMMDDhhmmss format - %n player name - %N first character of player name - DUMPLOG_FILE is not used if SYSCF is defined -*/ -#endif - -#endif #define USE_ISAAC64 /* Use cross-plattform, bundled RNG */ @@ -671,7 +645,39 @@ typedef unsigned char uchar; # endif #endif +#include "cstd.h" #include "integer.h" #include "global.h" /* Define everything else according to choices above */ +/* Place the following after #include [platform]conf.h in global.h so that + overrides are possible in there, for things like unix-specfic file + paths. */ + +#ifdef LIVELOG +#ifndef LIVELOGFILE +#define LIVELOGFILE "livelog" /* in-game events recorded, live */ +#endif /* LIVELOGFILE */ +#endif /* LIVELOG */ + +#ifdef DUMPLOG +#ifndef DUMPLOG_MSG_COUNT +#define DUMPLOG_MSG_COUNT 50 +#endif /* DUMPLOG_MSG_COUNT */ +#ifndef DUMPLOG_FILE +#define DUMPLOG_FILE "/tmp/nethack.%n.%d.log" +/* DUMPLOG_FILE allows following placeholders: + %% literal '%' + %v version (eg. "3.6.3-0") + %u game UID + %t game start time, UNIX timestamp format + %T current time, UNIX timestamp format + %d game start time, YYYYMMDDhhmmss format + %D current time, YYYYMMDDhhmmss format + %n player name + %N first character of player name + DUMPLOG_FILE is not used if SYSCF is defined +*/ +#endif /* DUMPLOG_FILE */ +#endif /* DUMPLOG */ + #endif /* CONFIG_H */ diff --git a/include/cstd.h b/include/cstd.h new file mode 100644 index 000000000..707f74157 --- /dev/null +++ b/include/cstd.h @@ -0,0 +1,57 @@ +/* NetHack 3.7 cstd.h $NHDT-Date: 1596498562 2020/08/03 23:49:22 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.24 $ */ +/*-Copyright (c) Robert Patrick Rankin, 2017. */ +/* NetHack may be freely redistributed. See license for details. */ + +#ifndef CSTD_H +#define CSTD_H + +/* + * The list of standard (C99 unless noted otherwise) header files: + * + * Conditionally compiled macro that compares its argument + * to zero + * (C99) Complex number arithmetic + * Functions to determine the type contained in character + * data + * Macros reporting error conditions + * (C99) Floating-point environment + * Limits of floating-point types + * (C99) Format conversion of integer types + * (C95) Alternative operator spellings + * Ranges of integer types + * Localization utilities + * Common mathematics functions + * Nonlocal jumps + * Signal handling + * Variable arguments + * (C99) Macros for boolean type + * Common macro definitions + * (C99) Fixed-width integer types + * Input/output program utilities + * + * General utilities: memory management, program utilities, string conversions, + * random numbers, algorithms + * String handling + * (C99) Type-generic math (macros wrapping math.h and complex.h) + * Time/date utilities + * (C95) Extended multibyte and wide character utilities + * (C95) Functions to determine the type contained in wide character data + + * We watch these and try not to conflict with them, or make it tough to adopt + * these in future: + * + * (C11) alignas and alignof convenience macros + * (C11) Atomic operations + * (C23) Macros to work with the byte and bit representations of types + * (C23) Macros for performing checked integer arithmetic + * (C11) noreturn convenience macro + * (C11) Thread library + * (C11) UTF-16 and UTF-32 character utilities + * + */ + +#include +#include +#include + +#endif /* CSTD_H */ diff --git a/include/decl.h b/include/decl.h index acfd14982..6e741edee 100644 --- a/include/decl.h +++ b/include/decl.h @@ -6,279 +6,14 @@ #ifndef DECL_H #define DECL_H -/* max size of a windowtype option */ -#define WINTYPELEN 16 - -struct dgn_topology { /* special dungeon levels for speed */ - d_level d_oracle_level; - d_level d_bigroom_level; /* unused */ - d_level d_rogue_level; - d_level d_medusa_level; - d_level d_stronghold_level; - d_level d_valley_level; - d_level d_wiz1_level; - d_level d_wiz2_level; - d_level d_wiz3_level; - d_level d_juiblex_level; - d_level d_orcus_level; - d_level d_baalzebub_level; /* unused */ - d_level d_asmodeus_level; /* unused */ - d_level d_portal_level; /* only in goto_level() [do.c] */ - d_level d_sanctum_level; - d_level d_earth_level; - d_level d_water_level; - d_level d_fire_level; - d_level d_air_level; - d_level d_astral_level; - xint16 d_tower_dnum; - xint16 d_sokoban_dnum; - xint16 d_mines_dnum, d_quest_dnum; - d_level d_qstart_level, d_qlocate_level, d_nemesis_level; - d_level d_knox_level; - d_level d_mineend_level; - d_level d_sokoend_level; -}; - -/* macros for accessing the dungeon levels by their old names */ -/* clang-format off */ -#define oracle_level (gd.dungeon_topology.d_oracle_level) -#define bigroom_level (gd.dungeon_topology.d_bigroom_level) -#define rogue_level (gd.dungeon_topology.d_rogue_level) -#define medusa_level (gd.dungeon_topology.d_medusa_level) -#define stronghold_level (gd.dungeon_topology.d_stronghold_level) -#define valley_level (gd.dungeon_topology.d_valley_level) -#define wiz1_level (gd.dungeon_topology.d_wiz1_level) -#define wiz2_level (gd.dungeon_topology.d_wiz2_level) -#define wiz3_level (gd.dungeon_topology.d_wiz3_level) -#define juiblex_level (gd.dungeon_topology.d_juiblex_level) -#define orcus_level (gd.dungeon_topology.d_orcus_level) -#define baalzebub_level (gd.dungeon_topology.d_baalzebub_level) -#define asmodeus_level (gd.dungeon_topology.d_asmodeus_level) -#define portal_level (gd.dungeon_topology.d_portal_level) -#define sanctum_level (gd.dungeon_topology.d_sanctum_level) -#define earth_level (gd.dungeon_topology.d_earth_level) -#define water_level (gd.dungeon_topology.d_water_level) -#define fire_level (gd.dungeon_topology.d_fire_level) -#define air_level (gd.dungeon_topology.d_air_level) -#define astral_level (gd.dungeon_topology.d_astral_level) -#define tower_dnum (gd.dungeon_topology.d_tower_dnum) -#define sokoban_dnum (gd.dungeon_topology.d_sokoban_dnum) -#define mines_dnum (gd.dungeon_topology.d_mines_dnum) -#define quest_dnum (gd.dungeon_topology.d_quest_dnum) -#define qstart_level (gd.dungeon_topology.d_qstart_level) -#define qlocate_level (gd.dungeon_topology.d_qlocate_level) -#define nemesis_level (gd.dungeon_topology.d_nemesis_level) -#define knox_level (gd.dungeon_topology.d_knox_level) -#define mineend_level (gd.dungeon_topology.d_mineend_level) -#define sokoend_level (gd.dungeon_topology.d_sokoend_level) -/* clang-format on */ - -#define dunlev_reached(x) (gd.dungeons[(x)->dnum].dunlev_ureached) - -#include "quest.h" - -extern NEARDATA char tune[6]; - -#define MAXLINFO (MAXDUNGEON * MAXLEVEL) - -/* structure for 'program_state'; not saved and restored */ -struct sinfo { - int gameover; /* self explanatory? */ - int stopprint; /* inhibit further end of game disclosure */ -#ifdef HANGUPHANDLING - volatile int done_hup; /* SIGHUP or moral equivalent received - * -- no more screen output */ - int preserve_locks; /* don't remove level files prior to exit */ -#endif - int something_worth_saving; /* in case of panic */ - int panicking; /* `panic' is in progress */ - int exiting; /* an exit handler is executing */ - int saving; /* creating a save file */ - int restoring; /* reloading a save file */ - int in_moveloop; /* normal gameplay in progress */ - int in_impossible; /* reporting a warning */ - int in_docrt; /* in docrt(): redrawing the whole screen */ - int in_self_recover; /* processing orphaned level files */ - int in_checkpoint; /* saving insurance checkpoint */ - int in_parseoptions; /* in parseoptions */ - int in_role_selection; /* role/race/&c selection menus in progress */ - int config_error_ready; /* config_error_add is ready, available */ - int beyond_savefile_load; /* set when past savefile loading */ -#ifdef PANICLOG - int in_paniclog; /* writing a paniclog entry */ -#endif - int wizkit_wishing; /* starting wizard mode game w/ WIZKIT file */ - /* getting_a_command: only used for ALTMETA config to process ESC, but - present and updated unconditionally; set by parse() when requesting - next command keystroke, reset by readchar() as it returns a key */ - int getting_a_command; /* next key pressed will be entering a cmnd */ -}; - -/* Flags for controlling uptodate */ -#define UTD_CHECKSIZES 0x01 -#define UTD_CHECKFIELDCOUNTS 0x02 -#define UTD_SKIP_SANITY1 0x04 -#define UTD_SKIP_SAVEFILEINFO 0x08 - -/* NetHack ftypes */ -#define NHF_LEVELFILE 1 -#define NHF_SAVEFILE 2 -#define NHF_BONESFILE 3 -/* modes */ -#define READING 0x0 -#define COUNTING 0x1 -#define WRITING 0x2 -#define FREEING 0x4 -#define MAX_BMASK 4 -/* operations of the various saveXXXchn & co. routines */ -#define perform_bwrite(nhfp) ((nhfp)->mode & (COUNTING | WRITING)) -#define release_data(nhfp) ((nhfp)->mode & FREEING) - -/* Content types for fieldlevel files */ -struct fieldlevel_content { - boolean deflt; /* individual fields */ - boolean binary; /* binary rather than text */ - boolean json; /* JSON */ -}; - -typedef struct { - int fd; /* for traditional structlevel binary writes */ - int mode; /* holds READING, WRITING, or FREEING modes */ - int ftype; /* NHF_LEVELFILE, NHF_SAVEFILE, or NHF_BONESFILE */ - int fnidx; /* index of procs for fieldlevel saves */ - long count; /* holds current line count for default style file, - field count for binary style */ - boolean structlevel; /* traditional structure binary saves */ - boolean fieldlevel; /* fieldlevel saves saves each field individually */ - boolean addinfo; /* if set, some additional context info from core */ - boolean eof; /* place to mark eof reached */ - boolean bendian; /* set to true if executing on big-endian machine */ - FILE *fpdef; /* file pointer for fieldlevel default style */ - FILE *fpdefmap; /* file pointer mapfile for def format */ - FILE *fplog; /* file pointer logfile */ - FILE *fpdebug; /* file pointer debug info */ - struct fieldlevel_content style; -} NHFILE; - -extern const char quitchars[]; -extern const char vowels[]; -extern const char ynchars[]; -extern const char ynqchars[]; -extern const char ynaqchars[]; -extern const char ynNaqchars[]; -extern NEARDATA long yn_number; - -extern const char disclosure_options[]; - -struct kinfo { - struct kinfo *next; /* chain of delayed killers */ - int id; /* uprop keys to ID a delayed killer */ - int format; /* one of the killer formats */ -#define KILLED_BY_AN 0 -#define KILLED_BY 1 -#define NO_KILLER_PREFIX 2 - char name[BUFSZ]; /* actual killer name */ -}; - -/* game events log */ -struct gamelog_line { - long turn; /* turn when this happened */ - long flags; /* LL_foo flags */ - char *text; - struct gamelog_line *next; -}; - -enum movemodes { - MV_ANY = -1, - MV_WALK, - MV_RUN, - MV_RUSH, - - N_MOVEMODES -}; - -enum movementdirs { - DIR_ERR = -1, - DIR_W, - DIR_NW, - DIR_N, - DIR_NE, - DIR_E, - DIR_SE, - DIR_S, - DIR_SW, - DIR_DOWN, - DIR_UP, - - N_DIRS_Z -}; -/* N_DIRS_Z, minus up & down */ -#define N_DIRS (N_DIRS_Z - 2) -/* direction adjustments */ -#define DIR_180(dir) (((dir) + 4) % N_DIRS) -#define DIR_LEFT(dir) (((dir) + 7) % N_DIRS) -#define DIR_RIGHT(dir) (((dir) + 1) % N_DIRS) -#define DIR_LEFT2(dir) (((dir) + 6) % N_DIRS) -#define DIR_RIGHT2(dir) (((dir) + 2) % N_DIRS) -#define DIR_CLAMP(dir) (((dir) + N_DIRS) % N_DIRS) - -extern const schar xdir[], ydir[], zdir[], dirs_ord[]; - -struct multishot { - int n, i; - short o; - boolean s; -}; - -extern NEARDATA boolean has_strong_rngseed; -extern const int shield_static[]; - -#include "spell.h" - -/* default object class symbols */ -extern const struct class_sym def_oc_syms[MAXOCLASSES]; -/* current object class symbols */ -extern uchar oc_syms[MAXOCLASSES]; - -/* default mon class symbols */ -extern const struct class_sym def_monsyms[MAXMCLASSES]; -/* current mon class symbols */ -extern uchar monsyms[MAXMCLASSES]; +/* The names of the colors used for gems, etc. */ +extern const char *c_obj_colors[]; /* lua callback queue names */ extern const char * const nhcb_name[]; extern int nhcb_counts[]; -#include "obj.h" -extern NEARDATA struct obj *uarm, *uarmc, *uarmh, *uarms, *uarmg, *uarmf, - *uarmu, /* under-wear, so to speak */ - *uskin, *uamul, *uleft, *uright, *ublindf, *uwep, *uswapwep, *uquiver; - -extern NEARDATA struct obj *uchain; /* defined only when punished */ -extern NEARDATA struct obj *uball; - -#include "engrave.h" -extern struct engr *head_engr; - -#include "you.h" -extern NEARDATA struct you u; -extern NEARDATA time_t ubirthday; -extern NEARDATA struct u_realtime urealtime; - -struct mvitals { - uchar born; - uchar died; - uchar mvflags; -}; - -struct c_color_names { - const char *const c_black, *const c_amber, *const c_golden, - *const c_light_blue, *const c_red, *const c_green, *const c_silver, - *const c_blue, *const c_purple, *const c_white, *const c_orange; -}; - extern NEARDATA const struct c_color_names c_color_names; - #define NH_BLACK c_color_names.c_black #define NH_AMBER c_color_names.c_amber #define NH_GOLDEN c_color_names.c_golden @@ -291,19 +26,8 @@ extern NEARDATA const struct c_color_names c_color_names; #define NH_WHITE c_color_names.c_white #define NH_ORANGE c_color_names.c_orange -/* The names of the colors used for gems, etc. */ -extern const char *c_obj_colors[]; - -struct c_common_strings { - const char *const c_nothing_happens, *const c_thats_enough_tries, - *const c_silly_thing_to, *const c_shudder_for_moment, - *const c_something, *const c_Something, *const c_You_can_move_again, - *const c_Never_mind, *c_vision_clears, *const c_the_your[2], - *const c_fakename[2]; -}; - +/* common_strings */ extern const struct c_common_strings c_common_strings; - #define nothing_happens c_common_strings.c_nothing_happens #define thats_enough_tries c_common_strings.c_thats_enough_tries #define silly_thing_to c_common_strings.c_silly_thing_to @@ -318,41 +42,63 @@ extern const struct c_common_strings c_common_strings; name ending in 's' */ #define fakename c_common_strings.c_fakename -/* material strings */ -extern const char *materialnm[]; +/* default object class symbols */ +extern const struct class_sym def_oc_syms[MAXOCLASSES]; + +/* default mon class symbols */ +extern const struct class_sym def_monsyms[MAXMCLASSES]; + +extern const char disclosure_options[]; /* empty string that is non-const for parameter use */ extern char emptystr[]; -/* Monster name articles */ -#define ARTICLE_NONE 0 -#define ARTICLE_THE 1 -#define ARTICLE_A 2 -#define ARTICLE_YOUR 3 +#ifdef WIN32 +extern boolean fqn_prefix_locked[PREFIX_COUNT]; +#endif +#ifdef PREFIXES_IN_USE +extern const char *fqn_prefix_names[PREFIX_COUNT]; +#endif -/* x_monnam() monster name suppress masks */ -#define SUPPRESS_IT 0x01 -#define SUPPRESS_INVISIBLE 0x02 -#define SUPPRESS_HALLUCINATION 0x04 -#define SUPPRESS_SADDLE 0x08 -#define EXACT_NAME 0x0F -#define SUPPRESS_NAME 0x10 -#define AUGMENT_IT 0x20 /* use "someone" or "something" instead of "it" */ +extern NEARDATA boolean has_strong_rngseed; +extern struct engr *head_engr; + +/* material strings */ +extern const char *materialnm[]; + +/* current mon class symbols */ +extern uchar monsyms[MAXMCLASSES]; + +/* current object class symbols */ +extern uchar oc_syms[MAXOCLASSES]; + +extern const char quitchars[]; +extern NEARDATA char tune[6]; +extern const schar xdir[], ydir[], zdir[], dirs_ord[]; +extern const char vowels[]; +extern const char ynchars[]; +extern const char ynqchars[]; +extern const char ynaqchars[]; +extern const char ynNaqchars[]; +extern NEARDATA long yn_number; +extern struct restore_info restoreinfo; +extern NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; +extern const int shield_static[]; + +extern NEARDATA struct obj *uarm, *uarmc, *uarmh, *uarms, *uarmg, *uarmf, + *uarmu, /* under-wear, so to speak */ + *uskin, *uamul, *uleft, *uright, *ublindf, *uwep, *uswapwep, *uquiver; +extern NEARDATA struct obj *uchain; /* defined only when punished */ +extern NEARDATA struct obj *uball; +extern NEARDATA struct you u; +extern NEARDATA time_t ubirthday; +extern NEARDATA struct u_realtime urealtime; /* Window system stuff */ extern NEARDATA winid WIN_MESSAGE; extern NEARDATA winid WIN_STATUS; extern NEARDATA winid WIN_MAP, WIN_INVEN; -/* pline (et al) for a single string argument (suppress compiler warning) */ -#define pline1(cstr) pline("%s", cstr) -#define Your1(cstr) Your("%s", cstr) -#define You1(cstr) You("%s", cstr) -#define verbalize1(cstr) verbalize("%s", cstr) -#define You_hear1(cstr) You_hear("%s", cstr) -#define Sprintf1(buf, cstr) Sprintf(buf, "%s", cstr) -#define panic1(cstr) panic("%s", cstr) - #ifndef TCAP_H extern struct tc_gbl_data { /* also declared in tcap.h */ char *tc_AS, *tc_AE; /* graphics start and end (tty font swapping) */ @@ -364,352 +110,10 @@ extern struct tc_gbl_data { /* also declared in tcap.h */ #define CO gt.tc_gbl_data.tc_CO #endif -/* Some systems want to use full pathnames for some subsets of file names, - * rather than assuming that they're all in the current directory. This - * provides all the subclasses that seem reasonable, and sets up for all - * prefixes being null. Port code can set those that it wants. - */ -#define HACKPREFIX 0 /* shared, RO */ -#define LEVELPREFIX 1 /* per-user, RW */ -#define SAVEPREFIX 2 /* per-user, RW */ -#define BONESPREFIX 3 /* shared, RW */ -#define DATAPREFIX 4 /* dungeon/dlb; must match value in dlb.c */ -#define SCOREPREFIX 5 /* shared, RW */ -#define LOCKPREFIX 6 /* shared, RW */ -#define SYSCONFPREFIX 7 /* shared, RO */ -#define CONFIGPREFIX 8 -#define TROUBLEPREFIX 9 /* shared or per-user, RW (append-only) */ -#define PREFIX_COUNT 10 -/* used in files.c; xxconf.h can override if needed */ -#ifndef FQN_MAX_FILENAME -#define FQN_MAX_FILENAME 512 -#endif - -#if defined(NOCWD_ASSUMPTIONS) || defined(VAR_PLAYGROUND) -/* the bare-bones stuff is unconditional above to simplify coding; for - * ports that actually use prefixes, add some more localized things - */ -#define PREFIXES_IN_USE -#endif - -#ifdef WIN32 -extern boolean fqn_prefix_locked[PREFIX_COUNT]; -#endif -#ifdef PREFIXES_IN_USE -extern const char *fqn_prefix_names[PREFIX_COUNT]; -#endif - -struct restore_info { - const char *name; - int mread_flags; -}; -extern struct restore_info restoreinfo; - -extern NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; - -struct selectionvar { - int wid, hei; - boolean bounds_dirty; - NhRect bounds; /* use selection_getbounds() */ - char *map; -}; - -struct autopickup_exception { - struct nhregex *regex; - char *pattern; - boolean grab; - struct autopickup_exception *next; -}; - -struct plinemsg_type { - xint16 msgtype; /* one of MSGTYP_foo */ - struct nhregex *regex; - char *pattern; - struct plinemsg_type *next; -}; - -#define MSGTYP_NORMAL 0 -#define MSGTYP_NOREP 1 -#define MSGTYP_NOSHOW 2 -#define MSGTYP_STOP 3 -/* bitmask for callers of hide_unhide_msgtypes() */ -#define MSGTYP_MASK_REP_SHOW ((1 << MSGTYP_NOREP) | (1 << MSGTYP_NOSHOW)) - -enum bcargs {override_restriction = -1}; -struct breadcrumbs { - const char *funcnm; - int linenum; - boolean in_effect; -}; #ifdef PANICTRACE extern const char *ARGV0; #endif -enum earlyarg { - ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS -#ifndef NODUMPENUMS - , ARG_DUMPENUMS -#endif -#ifdef ENHANCED_SYMBOLS - , ARG_DUMPGLYPHIDS -#endif -#ifdef WIN32 - , ARG_WINDOWS -#endif -}; - -struct early_opt { - enum earlyarg e; - const char *name; - int minlength; - boolean valallowed; -}; - -/* special key functions */ -enum nh_keyfunc { - NHKF_ESC = 0, - - NHKF_GETDIR_SELF, - NHKF_GETDIR_SELF2, - NHKF_GETDIR_HELP, - NHKF_GETDIR_MOUSE, /* simulated click for #therecmdmenu; use '_' as - * direction to initiate, then getpos() finishing - * with ',' (left click) or '.' (right click) */ - NHKF_COUNT, - NHKF_GETPOS_SELF, - NHKF_GETPOS_PICK, - NHKF_GETPOS_PICK_Q, /* quick */ - NHKF_GETPOS_PICK_O, /* once */ - NHKF_GETPOS_PICK_V, /* verbose */ - NHKF_GETPOS_SHOWVALID, - NHKF_GETPOS_AUTODESC, - NHKF_GETPOS_MON_NEXT, - NHKF_GETPOS_MON_PREV, - NHKF_GETPOS_OBJ_NEXT, - NHKF_GETPOS_OBJ_PREV, - NHKF_GETPOS_DOOR_NEXT, - NHKF_GETPOS_DOOR_PREV, - NHKF_GETPOS_UNEX_NEXT, - NHKF_GETPOS_UNEX_PREV, - NHKF_GETPOS_INTERESTING_NEXT, - NHKF_GETPOS_INTERESTING_PREV, - NHKF_GETPOS_VALID_NEXT, - NHKF_GETPOS_VALID_PREV, - NHKF_GETPOS_HELP, - NHKF_GETPOS_MENU, - NHKF_GETPOS_LIMITVIEW, - NHKF_GETPOS_MOVESKIP, - - NUM_NHKF -}; - -/* commands[] is used to directly access cmdlist[] instead of looping - through it to find the entry for a given input character; - move_X is the character used for moving one step in direction X; - alphadirchars corresponds to old sdir, - dirchars corresponds to ``iflags.num_pad ? ndir : sdir''; - pcHack_compat and phone_layout only matter when num_pad is on, - swap_yz only matters when it's off */ -struct cmd { - unsigned serialno; /* incremented after each update */ - boolean num_pad; /* same as iflags.num_pad except during updates */ - boolean pcHack_compat; /* for numpad: affects 5, M-5, and M-0 */ - boolean phone_layout; /* inverted keypad: 1,2,3 above, 7,8,9 below */ - boolean swap_yz; /* QWERTZ keyboards; use z to move NW, y to zap */ - const char *dirchars; /* current movement/direction characters */ - const char *alphadirchars; /* same as dirchars if !numpad */ - const struct ext_func_tab *commands[256]; /* indexed by input character */ - const struct ext_func_tab *mousebtn[NUM_MOUSE_BUTTONS]; - char spkeys[NUM_NHKF]; - char extcmd_char; /* key that starts an extended command ('#') */ -}; - - -#define ENTITIES 2 - -struct entity { - struct monst *emon; /* youmonst for the player */ - struct permonst *edata; /* must be non-zero for record to be valid */ - int ex, ey; -}; - -struct valuable_data { - long count; - int typ; -}; - -struct val_list { - struct valuable_data *list; - int size; -}; - -/* at most one of `door' and `box' should be non-null at any given time */ -struct xlock_s { - struct rm *door; - struct obj *box; - int picktyp, /* key|pick|card for unlock, sharp vs blunt for #force */ - chance, usedtime; - boolean magic_key; -}; - -struct trapinfo { - struct obj *tobj; - coordxy tx, ty; - int time_needed; - boolean force_bungle; -}; - -enum vanq_order_modes { - VANQ_MLVL_MNDX = 0, /* t - traditional: by monster level */ - VANQ_MSTR_MNDX, /* d - by difficulty rating */ - VANQ_ALPHA_SEP, /* a - alphabetical, first uniques, then ordinary */ - VANQ_ALPHA_MIX, /* A - alpha with uniques and ordinary intermixed */ - VANQ_MCLS_HTOL, /* C - by class, high to low within class */ - VANQ_MCLS_LTOH, /* c - by class, low to high within class */ - VANQ_COUNT_H_L, /* n - by count, high to low */ - VANQ_COUNT_L_H, /* z - by count, low to high */ - - NUM_VANQ_ORDER_MODES -}; - -struct rogueroom { - coordxy rlx, rly; - coordxy dx, dy; - boolean real; - uchar doortable; - int nroom; /* Only meaningful for "real" rooms */ -}; - -typedef struct ls_t { - struct ls_t *next; - coordxy x, y; /* source's position */ - short range; /* source's current range */ - short flags; - short type; /* type of light source */ - anything id; /* source's identifier */ -} light_source; - -struct container { - struct container *next; - coordxy x, y; - short what; - genericptr_t list; -}; - -enum bubble_contains_types { - CONS_OBJ = 0, - CONS_MON, - CONS_HERO, - CONS_TRAP -}; - -#define MAX_BMASK 4 - -struct bubble { - coordxy x, y; /* coordinates of the upper left corner */ - schar dx, dy; /* the general direction of the bubble's movement */ - uchar bm[MAX_BMASK + 2]; /* bubble bit mask */ - struct bubble *prev, *next; /* need to traverse the list up and down */ - struct container *cons; -}; - -struct musable { - struct obj *offensive; - struct obj *defensive; - struct obj *misc; - int has_offense, has_defense, has_misc; - /* =0, no capability; otherwise, different numbers. - * If it's an object, the object is also set (it's 0 otherwise). - */ -}; - -struct h2o_ctx { - int dkn_boom, unk_boom; /* track dknown, !dknown separately */ - boolean ctx_valid; -}; - -struct launchplace { - struct obj *obj; - coordxy x, y; -}; - -struct repo { /* repossession context */ - struct monst *shopkeeper; - coord location; -}; - -/* from options.c */ -#define MAX_MENU_MAPPED_CMDS 32 /* some number */ - -/* player selection constants */ -#define BP_ALIGN 0 -#define BP_GEND 1 -#define BP_RACE 2 -#define BP_ROLE 3 -#define NUM_BP 4 - -#define NUM_ROLES (13) -struct role_filter { - boolean roles[NUM_ROLES + 1]; - short mask; -}; - -/* read.c, create_particular() & create_particular_parse() */ -struct _create_particular_data { - int quan; - int which; - int fem; /* -1, MALE, FEMALE, NEUTRAL */ - int genderconf; /* conflicting gender */ - char monclass; - boolean randmonst; - boolean maketame, makepeaceful, makehostile; - boolean sleeping, saddled, invisible, hidden; -}; - -/* some array sizes for 'g' */ -#define WIZKIT_MAX 128 -#define CVT_BUF_SIZE 64 - -#define LUA_VER_BUFSIZ 20 -#define LUA_COPYRIGHT_BUFSIZ 120 - -/* - * Rudimentary command queue. - * Allows the code to put keys and extended commands into the queue, - * and they're executed just as if the user did them. Time passes - * normally when doing queued actions. The queue will get cleared - * if hero is interrupted. - */ -enum cmdq_cmdtypes { - CMDQ_KEY = 0, /* a literal character, cmdq_add_key() */ - CMDQ_EXTCMD, /* extended command, cmdq_add_ec() */ - CMDQ_DIR, /* direction, cmdq_add_dir() */ - CMDQ_USER_INPUT, /* placeholder for user input, cmdq_add_userinput() */ - CMDQ_INT, /* integer value, cmdq_add_int() */ -}; - -struct _cmd_queue { - int typ; - char key; - schar dirx, diry, dirz; - int intval; - const struct ext_func_tab *ec_entry; - struct _cmd_queue *next; -}; - -struct enum_dump { - int val; - const char *nm; -}; - -typedef long cmdcount_nht; /* Command counts */ - -enum { - CQ_CANNED = 0, /* internal canned sequence */ - CQ_REPEAT, /* user-inputted, if gi.in_doagain, replayed */ - NUM_CQS -}; - /* * 'gX' -- instance_globals holds engine state that does not need to be * persisted upon game exit. The initialization state is well defined diff --git a/include/hack.h b/include/hack.h index 13de5e507..ad215db96 100644 --- a/include/hack.h +++ b/include/hack.h @@ -11,6 +11,38 @@ #endif #include "lint.h" +#include "align.h" +#include "dungeon.h" +#include "objclass.h" +#include "wintype.h" +#include "flag.h" +#include "rect.h" +#include "sym.h" +#include "trap.h" +#include "youprop.h" +#include "display.h" + +#include "botl.h" +#include "color.h" +#include "context.h" +#include "dungeon.h" +#include "engrave.h" +#include "mkroom.h" +#include "obj.h" +#include "quest.h" +#include "rect.h" +#include "region.h" +#include "rm.h" +#include "sndprocs.h" +#include "spell.h" +#include "sym.h" +#include "sys.h" +#include "timeout.h" +#include "winprocs.h" +#include "wintype.h" +#include "vision.h" +#include "you.h" + #define TELL 1 #define NOTELL 0 #define ON 1 @@ -20,24 +52,20 @@ #define DUMMY { 0 } /* array initializer, letting [1..N-1] default */ #define DEF_NOTHING ' ' /* default symbol for NOTHING and UNEXPLORED */ -/* The UNDEFINED macros are used to initialize variables whose - initialized value is not relied upon. - UNDEFINED_VALUE: used to initialize any scalar type except pointers. - UNDEFINED_VALUES: used to initialize any non scalar type without pointers. - UNDEFINED_PTR: can be used only on pointer types. */ -#define UNDEFINED_VALUE 0 -#define UNDEFINED_VALUES { 0 } -#define UNDEFINED_PTR NULL +/* Macros for how a rumor was delivered in outrumor() */ +#define BY_ORACLE 0 +#define BY_COOKIE 1 +#define BY_PAPER 2 +#define BY_OTHER 9 -/* symbolic names for capacity levels */ -enum encumbrance_types { - UNENCUMBERED = 0, - SLT_ENCUMBER = 1, /* Burdened */ - MOD_ENCUMBER = 2, /* Stressed */ - HVY_ENCUMBER = 3, /* Strained */ - EXT_ENCUMBER = 4, /* Overtaxed */ - OVERLOADED = 5 /* Overloaded */ -}; +/* bitmask flags for corpse_xname(); + PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */ +#define CXN_NORMAL 0 /* no special handling */ +#define CXN_SINGULAR 1 /* override quantity if greather than 1 */ +#define CXN_NO_PFX 2 /* suppress "the" from "the Unique Monst */ +#define CXN_PFX_THE 4 /* prefix with "the " (unless pname) */ +#define CXN_ARTICLE 8 /* include a/an/the prefix */ +#define CXN_NOCORPSE 16 /* suppress " corpse" suffix */ /* weight increment of heavy iron ball */ #define IRON_BALL_W_INCR 160 @@ -45,6 +73,11 @@ enum encumbrance_types { /* number of turns it takes for vault guard to show up */ #define VAULT_GUARD_TIME 30 +/* sellobj_state() states */ +#define SELL_NORMAL (0) +#define SELL_DELIBERATE (1) +#define SELL_DONTSELL (2) + #define SHOP_DOOR_COST 400L /* cost of a destroyed shop door */ #define SHOP_BARS_COST 300L /* cost of iron bars */ #define SHOP_HOLE_COST 200L /* cost of making hole/trapdoor */ @@ -53,48 +86,202 @@ enum encumbrance_types { #define SHOP_PIT_COST 100L /* cost of making a pit */ #define SHOP_WEB_COST 30L /* cost of removing a web */ -/* hunger states - see hu_stat in eat.c */ -enum hunger_state_types { - SATIATED = 0, - NOT_HUNGRY = 1, - HUNGRY = 2, - WEAK = 3, - FAINTING = 4, - FAINTED = 5, - STARVED = 6 +/* flags for look_here() */ +#define LOOKHERE_NOFLAGS 0U +#define LOOKHERE_PICKED_SOME 1U +#define LOOKHERE_SKIP_DFEATURE 2U + +/* max size of a windowtype option */ +#define WINTYPELEN 16 + +/* str_or_len from sp_lev.h */ +typedef union str_or_len { + char *str; + int len; +} Str_or_Len; + +enum artifacts_nums { +#define ARTI_ENUM +#include "artilist.h" +#undef ARTI_ENUM + AFTER_LAST_ARTIFACT }; -/* Macros for how a rumor was delivered in outrumor() */ -#define BY_ORACLE 0 -#define BY_COOKIE 1 -#define BY_PAPER 2 -#define BY_OTHER 9 - -/* Macros for why you are no longer riding */ -enum dismount_types { - DISMOUNT_GENERIC = 0, - DISMOUNT_FELL = 1, - DISMOUNT_THROWN = 2, - DISMOUNT_KNOCKED = 3, /* hero hit for knockback effect */ - DISMOUNT_POLY = 4, - DISMOUNT_ENGULFED = 5, - DISMOUNT_BONES = 6, - DISMOUNT_BYCHOICE = 7 +enum misc_arti_nums { + NROFARTIFACTS = (AFTER_LAST_ARTIFACT - 1) }; -/* polyself flags */ -enum polyself_flags { - POLY_NOFLAGS = 0x00, - POLY_CONTROLLED = 0x01, - POLY_MONSTER = 0x02, - POLY_REVERT = 0x04, - POLY_LOW_CTRL = 0x08 +/* related to breadcrumb struct */ +enum bcargs {override_restriction = -1}; + +struct breadcrumbs { + const char *funcnm; + int linenum; + boolean in_effect; }; -/* sellobj_state() states */ -#define SELL_NORMAL (0) -#define SELL_DELIBERATE (1) -#define SELL_DONTSELL (2) +/* types of calls to bhit() */ +enum bhit_call_types { + ZAPPED_WAND = 0, + THROWN_WEAPON = 1, + THROWN_TETHERED_WEAPON = 2, + KICKED_WEAPON = 3, + FLASHED_LIGHT = 4, + INVIS_BEAM = 5 +}; + +/* Macros for messages referring to hands, eyes, feet, etc... */ +enum bodypart_types { + ARM = 0, + EYE = 1, + FACE = 2, + FINGER = 3, + FINGERTIP = 4, + FOOT = 5, + HAND = 6, + HANDED = 7, + HEAD = 8, + LEG = 9, + LIGHT_HEADED = 10, + NECK = 11, + SPINE = 12, + TOE = 13, + HAIR = 14, + BLOOD = 15, + LUNG = 16, + NOSE = 17, + STOMACH = 18 +}; + +#define MAX_BMASK 4 + +struct bubble { + coordxy x, y; /* coordinates of the upper left corner */ + schar dx, dy; /* the general direction of the bubble's movement */ + uchar bm[MAX_BMASK + 2]; /* bubble bit mask */ + struct bubble *prev, *next; /* need to traverse the list up and down */ + struct container *cons; +}; + +enum bubble_contains_types { + CONS_OBJ = 0, + CONS_MON, + CONS_HERO, + CONS_TRAP +}; + +/* + * Rudimentary command queue. + * Allows the code to put keys and extended commands into the queue, + * and they're executed just as if the user did them. Time passes + * normally when doing queued actions. The queue will get cleared + * if hero is interrupted. + */ +enum cmdq_cmdtypes { + CMDQ_KEY = 0, /* a literal character, cmdq_add_key() */ + CMDQ_EXTCMD, /* extended command, cmdq_add_ec() */ + CMDQ_DIR, /* direction, cmdq_add_dir() */ + CMDQ_USER_INPUT, /* placeholder for user input, cmdq_add_userinput() */ + CMDQ_INT, /* integer value, cmdq_add_int() */ +}; + +struct _cmd_queue { + int typ; + char key; + schar dirx, diry, dirz; + int intval; + const struct ext_func_tab *ec_entry; + struct _cmd_queue *next; +}; + +enum { + CQ_CANNED = 0, /* internal canned sequence */ + CQ_REPEAT, /* user-inputted, if gi.in_doagain, replayed */ + NUM_CQS +}; + +typedef long cmdcount_nht; /* Command counts */ + + +/* special key functions */ +enum nh_keyfunc { + NHKF_ESC = 0, + + NHKF_GETDIR_SELF, + NHKF_GETDIR_SELF2, + NHKF_GETDIR_HELP, + NHKF_GETDIR_MOUSE, /* simulated click for #therecmdmenu; use '_' as + * direction to initiate, then getpos() finishing + * with ',' (left click) or '.' (right click) */ + NHKF_COUNT, + NHKF_GETPOS_SELF, + NHKF_GETPOS_PICK, + NHKF_GETPOS_PICK_Q, /* quick */ + NHKF_GETPOS_PICK_O, /* once */ + NHKF_GETPOS_PICK_V, /* verbose */ + NHKF_GETPOS_SHOWVALID, + NHKF_GETPOS_AUTODESC, + NHKF_GETPOS_MON_NEXT, + NHKF_GETPOS_MON_PREV, + NHKF_GETPOS_OBJ_NEXT, + NHKF_GETPOS_OBJ_PREV, + NHKF_GETPOS_DOOR_NEXT, + NHKF_GETPOS_DOOR_PREV, + NHKF_GETPOS_UNEX_NEXT, + NHKF_GETPOS_UNEX_PREV, + NHKF_GETPOS_INTERESTING_NEXT, + NHKF_GETPOS_INTERESTING_PREV, + NHKF_GETPOS_VALID_NEXT, + NHKF_GETPOS_VALID_PREV, + NHKF_GETPOS_HELP, + NHKF_GETPOS_MENU, + NHKF_GETPOS_LIMITVIEW, + NHKF_GETPOS_MOVESKIP, + + NUM_NHKF +}; + +/* commands[] is used to directly access cmdlist[] instead of looping + through it to find the entry for a given input character; + move_X is the character used for moving one step in direction X; + alphadirchars corresponds to old sdir, + dirchars corresponds to ``iflags.num_pad ? ndir : sdir''; + pcHack_compat and phone_layout only matter when num_pad is on, + swap_yz only matters when it's off */ +struct cmd { + unsigned serialno; /* incremented after each update */ + boolean num_pad; /* same as iflags.num_pad except during updates */ + boolean pcHack_compat; /* for numpad: affects 5, M-5, and M-0 */ + boolean phone_layout; /* inverted keypad: 1,2,3 above, 7,8,9 below */ + boolean swap_yz; /* QWERTZ keyboards; use z to move NW, y to zap */ + const char *dirchars; /* current movement/direction characters */ + const char *alphadirchars; /* same as dirchars if !numpad */ + const struct ext_func_tab *commands[256]; /* indexed by input character */ + const struct ext_func_tab *mousebtn[NUM_MOUSE_BUTTONS]; + char spkeys[NUM_NHKF]; + char extcmd_char; /* key that starts an extended command ('#') */ +}; + +struct c_color_names { + const char *const c_black, *const c_amber, *const c_golden, + *const c_light_blue, *const c_red, *const c_green, *const c_silver, + *const c_blue, *const c_purple, *const c_white, *const c_orange; +}; + +struct c_common_strings { + const char *const c_nothing_happens, *const c_thats_enough_tries, + *const c_silly_thing_to, *const c_shudder_for_moment, + *const c_something, *const c_Something, *const c_You_can_move_again, + *const c_Never_mind, *c_vision_clears, *const c_the_your[2], + *const c_fakename[2]; +}; + +struct container { + struct container *next; + coordxy x, y; + short what; + genericptr_t list; +}; /* alteration types--keep in synch with costly_alteration(mkobj.c) */ enum cost_alteration_types { @@ -119,26 +306,137 @@ enum cost_alteration_types { COST_CORRODE = 18 /* acid damage */ }; -/* bitmask flags for corpse_xname(); - PFX_THE takes precedence over ARTICLE, NO_PFX takes precedence over both */ -#define CXN_NORMAL 0 /* no special handling */ -#define CXN_SINGULAR 1 /* override quantity if greater than 1 */ -#define CXN_NO_PFX 2 /* suppress "the" from "the Unique Monst */ -#define CXN_PFX_THE 4 /* prefix with "the " (unless pname) */ -#define CXN_ARTICLE 8 /* include a/an/the prefix */ -#define CXN_NOCORPSE 16 /* suppress " corpse" suffix */ +/* read.c, create_particular() & create_particular_parse() */ +struct _create_particular_data { + int quan; + int which; + int fem; /* -1, MALE, FEMALE, NEUTRAL */ + int genderconf; /* conflicting gender */ + char monclass; + boolean randmonst; + boolean maketame, makepeaceful, makehostile; + boolean sleeping, saddled, invisible, hidden; +}; -/* flags for look_here() */ -#define LOOKHERE_NOFLAGS 0U -#define LOOKHERE_PICKED_SOME 1U -#define LOOKHERE_SKIP_DFEATURE 2U +/* Dismount: causes for why you are no longer riding */ +enum dismount_types { + DISMOUNT_GENERIC = 0, + DISMOUNT_FELL = 1, + DISMOUNT_THROWN = 2, + DISMOUNT_KNOCKED = 3, /* hero hit for knockback effect */ + DISMOUNT_POLY = 4, + DISMOUNT_ENGULFED = 5, + DISMOUNT_BONES = 6, + DISMOUNT_BYCHOICE = 7 +}; -/* getpos() return values */ -enum getpos_retval { - LOOK_TRADITIONAL = 0, /* '.' -- ask about "more info?" */ - LOOK_QUICK = 1, /* ',' -- skip "more info?" */ - LOOK_ONCE = 2, /* ';' -- skip and stop looping */ - LOOK_VERBOSE = 3 /* ':' -- show more info w/o asking */ +struct dgn_topology { /* special dungeon levels for speed */ + d_level d_oracle_level; + d_level d_bigroom_level; /* unused */ + d_level d_rogue_level; + d_level d_medusa_level; + d_level d_stronghold_level; + d_level d_valley_level; + d_level d_wiz1_level; + d_level d_wiz2_level; + d_level d_wiz3_level; + d_level d_juiblex_level; + d_level d_orcus_level; + d_level d_baalzebub_level; /* unused */ + d_level d_asmodeus_level; /* unused */ + d_level d_portal_level; /* only in goto_level() [do.c] */ + d_level d_sanctum_level; + d_level d_earth_level; + d_level d_water_level; + d_level d_fire_level; + d_level d_air_level; + d_level d_astral_level; + xint16 d_tower_dnum; + xint16 d_sokoban_dnum; + xint16 d_mines_dnum, d_quest_dnum; + d_level d_qstart_level, d_qlocate_level, d_nemesis_level; + d_level d_knox_level; + d_level d_mineend_level; + d_level d_sokoend_level; +}; + +/* macros for accessing the dungeon levels by their old names */ +/* clang-format off */ +#define oracle_level (gd.dungeon_topology.d_oracle_level) +#define bigroom_level (gd.dungeon_topology.d_bigroom_level) +#define rogue_level (gd.dungeon_topology.d_rogue_level) +#define medusa_level (gd.dungeon_topology.d_medusa_level) +#define stronghold_level (gd.dungeon_topology.d_stronghold_level) +#define valley_level (gd.dungeon_topology.d_valley_level) +#define wiz1_level (gd.dungeon_topology.d_wiz1_level) +#define wiz2_level (gd.dungeon_topology.d_wiz2_level) +#define wiz3_level (gd.dungeon_topology.d_wiz3_level) +#define juiblex_level (gd.dungeon_topology.d_juiblex_level) +#define orcus_level (gd.dungeon_topology.d_orcus_level) +#define baalzebub_level (gd.dungeon_topology.d_baalzebub_level) +#define asmodeus_level (gd.dungeon_topology.d_asmodeus_level) +#define portal_level (gd.dungeon_topology.d_portal_level) +#define sanctum_level (gd.dungeon_topology.d_sanctum_level) +#define earth_level (gd.dungeon_topology.d_earth_level) +#define water_level (gd.dungeon_topology.d_water_level) +#define fire_level (gd.dungeon_topology.d_fire_level) +#define air_level (gd.dungeon_topology.d_air_level) +#define astral_level (gd.dungeon_topology.d_astral_level) +#define tower_dnum (gd.dungeon_topology.d_tower_dnum) +#define sokoban_dnum (gd.dungeon_topology.d_sokoban_dnum) +#define mines_dnum (gd.dungeon_topology.d_mines_dnum) +#define quest_dnum (gd.dungeon_topology.d_quest_dnum) +#define qstart_level (gd.dungeon_topology.d_qstart_level) +#define qlocate_level (gd.dungeon_topology.d_qlocate_level) +#define nemesis_level (gd.dungeon_topology.d_nemesis_level) +#define knox_level (gd.dungeon_topology.d_knox_level) +#define mineend_level (gd.dungeon_topology.d_mineend_level) +#define sokoend_level (gd.dungeon_topology.d_sokoend_level) +/* clang-format on */ + +#define dunlev_reached(x) (gd.dungeons[(x)->dnum].dunlev_ureached) +#define MAXLINFO (MAXDUNGEON * MAXLEVEL) + + +enum earlyarg { + ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS +#ifndef NODUMPENUMS + , ARG_DUMPENUMS +#endif +#ifdef ENHANCED_SYMBOLS + , ARG_DUMPGLYPHIDS +#endif +#ifdef WIN32 + , ARG_WINDOWS +#endif +}; + +struct early_opt { + enum earlyarg e; + const char *name; + int minlength; + boolean valallowed; +}; + +/* symbolic names for capacity levels */ +enum encumbrance_types { + UNENCUMBERED = 0, + SLT_ENCUMBER = 1, /* Burdened */ + MOD_ENCUMBER = 2, /* Stressed */ + HVY_ENCUMBER = 3, /* Strained */ + EXT_ENCUMBER = 4, /* Overtaxed */ + OVERLOADED = 5 /* Overloaded */ +}; + +struct entity { + struct monst *emon; /* youmonst for the player */ + struct permonst *edata; /* must be non-zero for record to be valid */ + int ex, ey; +}; + +struct enum_dump { + int val; + const char *nm; }; /* @@ -165,17 +463,322 @@ enum game_end_types { ASCENDED = 15 }; +/* game events log */ +struct gamelog_line { + long turn; /* turn when this happened */ + long flags; /* LL_foo flags */ + char *text; + struct gamelog_line *next; +}; + + +/* values returned from getobj() callback functions */ +enum getobj_callback_returns { + /* generally invalid - can't be used for this purpose. will give a "silly + * thing" message if the player tries to pick it, unless a more specific + * failure message is in getobj itself - e.g. "You cannot foo gold". */ + GETOBJ_EXCLUDE = -3, + /* invalid because it is not in inventory; used when the hands/self + * possibility is queried and the player passed up something on the + * floor before getobj. */ + GETOBJ_EXCLUDE_NONINVENT = -2, + /* invalid because it is an inaccessible or unwanted piece of gear, but + * pseudo-valid for the purposes of allowing the player to select it and + * getobj to return it if there is a prompt instead of getting "silly + * thing", in order for the getobj caller to present a specific failure + * message. Other than that, the only thing this does differently from + * GETOBJ_EXCLUDE is that it inserts an "else" in "You don't have anything + * else to foo". */ + GETOBJ_EXCLUDE_INACCESS = -1, + /* invalid for purposes of not showing a prompt if nothing is valid but + * pseudo-valid for selecting - identical to GETOBJ_EXCLUDE_INACCESS but + * without the "else" in "You don't have anything else to foo". */ + GETOBJ_EXCLUDE_SELECTABLE = 0, + /* valid - invlet not presented in the summary or the ? menu as a + * recommendation, but is selectable if the player enters it anyway. + * Used for objects that are actually valid but unimportantly so, such + * as shirts for reading. */ + GETOBJ_DOWNPLAY = 1, + /* valid - will be shown in summary and ? menu */ + GETOBJ_SUGGEST = 2, +}; + +/* getpos() return values */ +enum getpos_retval { + LOOK_TRADITIONAL = 0, /* '.' -- ask about "more info?" */ + LOOK_QUICK = 1, /* ',' -- skip "more info?" */ + LOOK_ONCE = 2, /* ';' -- skip and stop looping */ + LOOK_VERBOSE = 3 /* ':' -- show more info w/o asking */ +}; + +struct h2o_ctx { + int dkn_boom, unk_boom; /* track dknown, !dknown separately */ + boolean ctx_valid; +}; + +/* attack mode for hmon() */ +enum hmon_atkmode_types { + HMON_MELEE = 0, /* hand-to-hand */ + HMON_THROWN = 1, /* normal ranged (or spitting while poly'd) */ + HMON_KICKED = 2, /* alternate ranged */ + HMON_APPLIED = 3, /* polearm, treated as ranged */ + HMON_DRAGGED = 4 /* attached iron ball, pulled into mon */ +}; + +/* hunger states - see hu_stat in eat.c */ +enum hunger_state_types { + SATIATED = 0, + NOT_HUNGRY = 1, + HUNGRY = 2, + WEAK = 3, + FAINTING = 4, + FAINTED = 5, + STARVED = 6 +}; + +struct kinfo { + struct kinfo *next; /* chain of delayed killers */ + int id; /* uprop keys to ID a delayed killer */ + int format; /* one of the killer formats */ +#define KILLED_BY_AN 0 +#define KILLED_BY 1 +#define NO_KILLER_PREFIX 2 + char name[BUFSZ]; /* actual killer name */ +}; + +struct launchplace { + struct obj *obj; + coordxy x, y; +}; + +/* light source */ +typedef struct ls_t { + struct ls_t *next; + coordxy x, y; /* source's position */ + short range; /* source's current range */ + short flags; + short type; /* type of light source */ + anything id; /* source's identifier */ +} light_source; + + +enum movemodes { + MV_ANY = -1, + MV_WALK, + MV_RUN, + MV_RUSH, + + N_MOVEMODES +}; + +enum movementdirs { + DIR_ERR = -1, + DIR_W, + DIR_NW, + DIR_N, + DIR_NE, + DIR_E, + DIR_SE, + DIR_S, + DIR_SW, + DIR_DOWN, + DIR_UP, + + N_DIRS_Z +}; +/* N_DIRS_Z, minus up & down */ +#define N_DIRS (N_DIRS_Z - 2) +/* direction adjustments */ +#define DIR_180(dir) (((dir) + 4) % N_DIRS) +#define DIR_LEFT(dir) (((dir) + 7) % N_DIRS) +#define DIR_RIGHT(dir) (((dir) + 1) % N_DIRS) +#define DIR_LEFT2(dir) (((dir) + 6) % N_DIRS) +#define DIR_RIGHT2(dir) (((dir) + 2) % N_DIRS) +#define DIR_CLAMP(dir) (((dir) + N_DIRS) % N_DIRS) + +struct multishot { + int n, i; + short o; + boolean s; +}; + +struct musable { + struct obj *offensive; + struct obj *defensive; + struct obj *misc; + int has_offense, has_defense, has_misc; + /* =0, no capability; otherwise, different numbers. + * If it's an object, the object is also set (it's 0 otherwise). + */ +}; + +struct mvitals { + uchar born; + uchar died; + uchar mvflags; +}; + + +/* Lua callback functions */ +enum nhcore_calls { + NHCORE_START_NEW_GAME = 0, + NHCORE_RESTORE_OLD_GAME, + NHCORE_MOVELOOP_TURN, + NHCORE_GAME_EXIT, + NHCORE_GETPOS_TIP, + + NUM_NHCORE_CALLS +}; + +/* Lua callbacks. TODO: Merge with NHCORE */ +enum nhcb_calls { + NHCB_CMD_BEFORE = 0, + NHCB_LVL_ENTER, + NHCB_LVL_LEAVE, + NHCB_END_TURN, + + NUM_NHCB +}; + +/* + * option setting restrictions + */ + +enum optset_restrictions { + set_in_sysconf = 0, /* system config file option only */ + set_in_config = 1, /* config file option only */ + set_viaprog = 2, /* may be set via extern program, not seen in game */ + set_gameview = 3, /* may be set via extern program, displayed in game */ + set_in_game = 4, /* may be set via extern program or set in the game */ + set_wizonly = 5, /* may be set set in the game if wizmode */ + set_wiznofuz = 6, /* wizard-mode only, but not by fuzzer */ + set_hidden = 7 /* placeholder for prefixed entries, never show it */ +}; +#define SET__IS_VALUE_VALID(s) ((s < set_in_sysconf) || (s > set_wiznofuz)) + +struct plinemsg_type { + xint16 msgtype; /* one of MSGTYP_foo */ + struct nhregex *regex; + char *pattern; + struct plinemsg_type *next; +}; + +#define MSGTYP_NORMAL 0 +#define MSGTYP_NOREP 1 +#define MSGTYP_NOSHOW 2 +#define MSGTYP_STOP 3 +/* bitmask for callers of hide_unhide_msgtypes() */ +#define MSGTYP_MASK_REP_SHOW ((1 << MSGTYP_NOREP) | (1 << MSGTYP_NOSHOW)) + +/* polyself flags */ +enum polyself_flags { + POLY_NOFLAGS = 0x00, + POLY_CONTROLLED = 0x01, + POLY_MONSTER = 0x02, + POLY_REVERT = 0x04, + POLY_LOW_CTRL = 0x08 +}; + +struct repo { /* repossession context */ + struct monst *shopkeeper; + coord location; +}; + +struct restore_info { + const char *name; + int mread_flags; +}; + +enum restore_stages { + REST_GSTATE = 1, /* restoring current level and game state */ + REST_LEVELS = 2, /* restoring remainder of dungeon */ +}; + +struct rogueroom { + coordxy rlx, rly; + coordxy dx, dy; + boolean real; + uchar doortable; + int nroom; /* Only meaningful for "real" rooms */ +}; + +#define NUM_ROLES (13) +struct role_filter { + boolean roles[NUM_ROLES + 1]; + short mask; +}; + +enum saveformats { + invalid = 0, + historical = 1, /* entire struct, binary, as-is */ + lendian = 2, /* each field, binary, little-endian */ + ascii = 3 /* each field, ascii text (just proof of concept) */ +}; + +struct selectionvar { + int wid, hei; + boolean bounds_dirty; + NhRect bounds; /* use selection_getbounds() */ + char *map; +}; + +/* structure for 'program_state'; not saved and restored */ +struct sinfo { + int gameover; /* self explanatory? */ + int stopprint; /* inhibit further end of game disclosure */ +#ifdef HANGUPHANDLING + volatile int done_hup; /* SIGHUP or moral equivalent received + * -- no more screen output */ + int preserve_locks; /* don't remove level files prior to exit */ +#endif + int something_worth_saving; /* in case of panic */ + int panicking; /* `panic' is in progress */ + int exiting; /* an exit handler is executing */ + int saving; /* creating a save file */ + int restoring; /* reloading a save file */ + int in_moveloop; /* normal gameplay in progress */ + int in_impossible; /* reportig a warning */ + int in_docrt; /* in docrt(): redrawing the whole screen */ + int in_self_recover; /* processsing orphaned level files */ + int in_checkpoint; /* saving insurance checkpoint */ + int in_parseoptions; /* in parseoptions */ + int in_role_selection; /* role/race/&c selection menus in progress */ + int config_error_ready; /* config_error_add is ready, available */ + int beyond_savefile_load; /* set when past savefile loading */ +#ifdef PANICLOG + int in_paniclog; /* writing a panicloc entry */ +#endif + int wizkit_wishing; /* starting wizard mode game w/ WIZKIT file */ + /* getting_a_command: only used for ALTMETA config to process ESC, but + present and updated unconditionally; set by parse() when requesting + next command keystroke, reset by readchar() as it returns a key */ + int getting_a_command; /* next key pressed will be entering a cmnd */ +}; + +/* sortloot() return type; needed before extern.h */ +struct sortloot_item { + struct obj *obj; + char *str; /* result of loot_xname(obj) in some cases, otherwise null */ + int indx; /* signed int, because sortloot()'s qsort comparison routine + assumes (a->indx - b->indx) might yield a negative result */ + xint16 orderclass; /* order rather than object class; 0 => not yet init'd */ + xint16 subclass; /* subclass for some classes */ + xint16 disco; /* discovery status */ +}; +typedef struct sortloot_item Loot; + typedef struct strbuf { int len; char * str; char buf[256]; } strbuf_t; -/* str_or_len from sp_lev.h */ -typedef union str_or_len { - char *str; - int len; -} Str_or_Len; +struct trapinfo { + struct obj *tobj; + coordxy tx, ty; + int time_needed; + boolean force_bungle; +}; /* values for rtype are defined in dungeon.h */ /* lev_region from sp_lev.h */ @@ -191,29 +794,331 @@ typedef struct { Str_or_Len rname; } lev_region; +/* Flags for controlling uptodate */ +#define UTD_CHECKSIZES 0x01 +#define UTD_CHECKFIELDCOUNTS 0x02 +#define UTD_SKIP_SANITY1 0x04 +#define UTD_SKIP_SAVEFILEINFO 0x08 -#include "align.h" -#include "dungeon.h" -#include "wintype.h" -#include "sym.h" -#include "mkroom.h" - -enum artifacts_nums { -#define ARTI_ENUM -#include "artilist.h" -#undef ARTI_ENUM - AFTER_LAST_ARTIFACT +#define ENTITIES 2 +struct valuable_data { + long count; + int typ; }; -enum misc_arti_nums { - NROFARTIFACTS = (AFTER_LAST_ARTIFACT - 1) +struct val_list { + struct valuable_data *list; + int size; }; -#include "objclass.h" -#include "youprop.h" -#include "context.h" -#include "rm.h" -#include "botl.h" +enum vanq_order_modes { + VANQ_MLVL_MNDX = 0, /* t - traditional: by monster level */ + VANQ_MSTR_MNDX, /* d - by difficulty rating */ + VANQ_ALPHA_SEP, /* a - alphabetical, first uniques, then ordinary */ + VANQ_ALPHA_MIX, /* A - alpha with uniques and ordinary intermixed */ + VANQ_MCLS_HTOL, /* C - by class, high to low within class */ + VANQ_MCLS_LTOH, /* c - by class, low to high within class */ + VANQ_COUNT_H_L, /* n - by count, high to low */ + VANQ_COUNT_L_H, /* z - by count, low to high */ + + NUM_VANQ_ORDER_MODES +}; + +struct autopickup_exception { + struct nhregex *regex; + char *pattern; + boolean grab; + struct autopickup_exception *next; +}; + +#if !defined(NO_VERBOSE_GRANULARITY) +#define VB_ELEMENTS 5 +/* + * Maintenance Notes: + * - if one of the function's involved has a name change, + * and the Verbose() macro use instance is updated to match, + * it will have to be reflected below. If the use instance + * isn't updated to reflect the function name change, + * it will continue to work using the old name if it matches + * one of the entries below. + */ + +enum verbosity_values { + vb0interrupt_multi = 0x00000001, + vb0use_stethoscope = 0x00000002, + vb0Mb_hit = 0x00000004, + vb0adjattrib = 0x00000008, + vb0ballfall = 0x00000010, + vb0use_crystal_ball1 = 0x00000020, + vb0use_crystal_ball2 = 0x00000040, + vb0digactualhole1 = 0x00000080, + vb0digactualhole2 = 0x00000100, + vb0mdig_tunnel1 = 0x00000200, + vb0mdig_tunnel2 = 0x00000400, + vb0boulder_hits_pool1 = 0x00000800, + vb0boulder_hits_pool2 = 0x00001000, + vb0drop1 = 0x00002000, + vb0drop2 = 0x00004000, + vb0drop3 = 0x00008000, + vb0go_to_level1 = 0x00010000, + vb0go_to_level2 = 0x00020000, + vb0go_to_level3 = 0x00040000, + vb0rot_corpse = 0x00080000, + vb0getpos1 = 0x00100000, + vb0getpos2 = 0x00200000, + vb0off_msg = 0x00400000, + vb0on_msg = 0x00800000, + vb0Blindf_on = 0x01000000, + vb0dog_eat = 0x02000000, + vb0dog_invent = 0x04000000, + vb0dokick = 0x08000000, + vb0toss_up = 0x10000000, + vb0consume_tin1 = 0x20000000, + vb0consume_tin2 = 0x40000000, + + vb1doengrave1 = 0x00000001, + vb1doengrave2 = 0x00000002, + vb1doengrave3 = 0x00000004, + vb1explode = 0x00000008, + vb1moverock = 0x00000010, + vb1still_chewing = 0x00000020, + vb1trapmove1 = 0x00000040, + vb1trapmove2 = 0x00000080, + vb1trapmove3 = 0x00000100, + vb1trapmove4 = 0x00000200, + vb1trapmove5 = 0x00000400, + vb1getobj1 = 0x00000800, + vb1getobj2 = 0x00001000, + vb1doprgold = 0x00002000, + vb1doorlock1 = 0x00004000, + vb1doorlock2 = 0x00008000, + vb1monpoly1 = 0x00010000, + vb1monpoly2 = 0x00020000, + vb1mswingsm = 0x00040000, + vb1missmu = 0x00080000, + vb1mswings = 0x00100000, + vb1wildmiss = 0x00200000, + vb1gulpmu = 0x00400000, + vb1explmu = 0x00800000, + vb1meatmetal1 = 0x01000000, + vb1meatmetal2 = 0x02000000, + vb1meatmetal3 = 0x04000000, + vb1meatmetal4 = 0x08000000, + vb1relobj = 0x10000000, + vb1ready_weapon = 0x20000000, + vb1wield_tool = 0x40000000, + + vb2meatobj1 = 0x00000001, + vb2meatobj2 = 0x00000002, + vb2meatobj3 = 0x00000004, + vb2meatobj4 = 0x00000008, + vb2meatcorpse1 = 0x00000010, + vb2meatcorpse2 = 0x00000020, + vb2mpickgold = 0x00000040, + vb2mpickstuff = 0x00000080, + vb2setmangry = 0x00000100, + vb2mb_trapped = 0x00000200, + vb2m_move1 = 0x00000400, + vb2m_move2 = 0x00000800, + vb2m_move3 = 0x00001000, + vb2m_move4 = 0x00002000, + vb2m_move5 = 0x00004000, + vb2thitu1 = 0x00008000, + vb2thitu2 = 0x00010000, + vb2m_throw = 0x00020000, + vb2handler_menustyle = 0x00040000, + vb2handler_autounlock = 0x00080000, + vb2handler_msg_window = 0x00100000, + vb2handler_whatis_coord1 = 0x00200000, + vb2handler_whatis_coord2 = 0x00400000, + vb2dolook = 0x00800000, + vb2describe_decor1 = 0x01000000, + vb2describe_decor2 = 0x02000000, + vb2loot_mon = 0x04000000, + vb2dotip = 0x08000000, + vb2polymon = 0x10000000, + vb2teleds = 0x20000000, + vb2level_tele = 0x40000000, + + vb3ghost_from_bottle = 0x00000001, + vb3dodip1 = 0x00000002, + vb3dodip2 = 0x00000004, + vb3dodip3 = 0x00000008, + vb3intemple = 0x00000010, + vb3doread1 = 0x00000020, + vb3doread2 = 0x00000040, + vb3doread3 = 0x00000080, + vb3doread4 = 0x00000100, + vb3doread5 = 0x00000200, + vb3doread6 = 0x00000400, + vb3doread7 = 0x00000800, + vb3drop_boulder_on_player= 0x00001000, + vb3do_genocide = 0x00002000, + vb3call_kops1 = 0x00004000, + vb3call_kops2 = 0x00008000, + vb3call_kops3 = 0x00010000, + vb3erode_obj1 = 0x00020000, + vb3erode_obj2 = 0x00040000, + vb3erode_obj3 = 0x00080000, + vb3trapeffect_rocktrap = 0x00100000, + vb3climb_pit = 0x00200000, + vb3drown = 0x00400000, + vb3mon_adjust_speed = 0x00800000, + vb3hit = 0x01000000, + vb3miss = 0x02000000, + vb3makewish = 0x04000000, + vb3prinv = 0x08000000, + /* 3 available bits*/ + + vb4do_attack = 0x00000001, + vb4known_hitum = 0x00000002, + vb4hmon_hitmon1 = 0x00000004, + vb4hmon_hitmon2 = 0x00000008, + vb4mhitm_ad_tlpt = 0x00000010, + vb4mhitm_ad_wrap1 = 0x00000020, + vb4mhitm_ad_wrap2 = 0x00000040, + vb4mhitm_ad_dgst = 0x00000080, + vb4damageum = 0x00000100, + vb4missum = 0x00000200, + vb4hmonas1 = 0x00000400, + vb4hmonas2 = 0x00000800, + vb4hmonas3 = 0x00001000, + vb4hmonas4 = 0x00002000, + vb4passive = 0x00004000, + vb4flash_hits_mon = 0x00008000, + /* 11 available bits */ + + vb_elements = VB_ELEMENTS +}; +#undef VB_ELEMENTS +extern long verbosity_suppressions[vb_elements]; /* in decl.c */ + +#define Verbose(n,s) (flags.verbose && \ + (((n) >= 0 && (n) < vb_elements) && \ + !(verbosity_suppressions[(n)] & vb##n##s))) + +#else /* NO_VERBOSE_GRANULARITY */ +#define Verbose(n,s) (flags.verbose) +#endif /* !NO_VERBOSE_GRANULARITY */ + + +/* at most one of `door' and `box' should be non-null at any given time */ +struct xlock_s { + struct rm *door; + struct obj *box; + int picktyp, /* key|pick|card for unlock, sharp vs blunt for #force */ + chance, usedtime; + boolean magic_key; +}; + +/* NetHack ftypes */ +#define NHF_LEVELFILE 1 +#define NHF_SAVEFILE 2 +#define NHF_BONESFILE 3 +/* modes */ +#define READING 0x0 +#define COUNTING 0x1 +#define WRITING 0x2 +#define FREEING 0x4 +#define MAX_BMASK 4 +/* operations of the various saveXXXchn & co. routines */ +#define perform_bwrite(nhfp) ((nhfp)->mode & (COUNTING | WRITING)) +#define release_data(nhfp) ((nhfp)->mode & FREEING) + +/* Content types for fieldlevel files */ +struct fieldlevel_content { + boolean deflt; /* individual fields */ + boolean binary; /* binary rather than text */ + boolean json; /* JSON */ +}; + +typedef struct { + int fd; /* for traditional structlevel binary writes */ + int mode; /* holds READING, WRITING, or FREEING modes */ + int ftype; /* NHF_LEVELFILE, NHF_SAVEFILE, or NHF_BONESFILE */ + int fnidx; /* index of procs for fieldlevel saves */ + long count; /* holds current line count for default style file, + field count for binary style */ + boolean structlevel; /* traditional structure binary saves */ + boolean fieldlevel; /* fieldlevel saves saves each field individually */ + boolean addinfo; /* if set, some additional context info from core */ + boolean eof; /* place to mark eof reached */ + boolean bendian; /* set to true if executing on big-endian machine */ + FILE *fpdef; /* file pointer for fieldlevel default style */ + FILE *fpdefmap; /* file pointer mapfile for def format */ + FILE *fplog; /* file pointer logfile */ + FILE *fpdebug; /* file pointer debug info */ + struct fieldlevel_content style; +} NHFILE; + +/* Monster name articles */ +#define ARTICLE_NONE 0 +#define ARTICLE_THE 1 +#define ARTICLE_A 2 +#define ARTICLE_YOUR 3 + +/* x_monnam() monster name suppress masks */ +#define SUPPRESS_IT 0x01 +#define SUPPRESS_INVISIBLE 0x02 +#define SUPPRESS_HALLUCINATION 0x04 +#define SUPPRESS_SADDLE 0x08 +#define EXACT_NAME 0x0F +#define SUPPRESS_NAME 0x10 +#define AUGMENT_IT 0x20 /* use "someone" or "something" instead of "it" */ + +/* pline (et al) for a single string argument (suppress compiler warning) */ +#define pline1(cstr) pline("%s", cstr) +#define Your1(cstr) Your("%s", cstr) +#define You1(cstr) You("%s", cstr) +#define verbalize1(cstr) verbalize("%s", cstr) +#define You_hear1(cstr) You_hear("%s", cstr) +#define Sprintf1(buf, cstr) Sprintf(buf, "%s", cstr) +#define panic1(cstr) panic("%s", cstr) + +/* Some systems want to use full pathnames for some subsets of file names, + * rather than assuming that they're all in the current directory. This + * provides all the subclasses that seem reasonable, and sets up for all + * prefixes being null. Port code can set those that it wants. + */ +#define HACKPREFIX 0 /* shared, RO */ +#define LEVELPREFIX 1 /* per-user, RW */ +#define SAVEPREFIX 2 /* per-user, RW */ +#define BONESPREFIX 3 /* shared, RW */ +#define DATAPREFIX 4 /* dungeon/dlb; must match value in dlb.c */ +#define SCOREPREFIX 5 /* shared, RW */ +#define LOCKPREFIX 6 /* shared, RW */ +#define SYSCONFPREFIX 7 /* shared, RO */ +#define CONFIGPREFIX 8 +#define TROUBLEPREFIX 9 /* shared or per-user, RW (append-only) */ +#define PREFIX_COUNT 10 +/* used in files.c; xxconf.h can override if needed */ +#ifndef FQN_MAX_FILENAME +#define FQN_MAX_FILENAME 512 +#endif + +#if defined(NOCWD_ASSUMPTIONS) || defined(VAR_PLAYGROUND) +/* the bare-bones stuff is unconditional above to simplify coding; for + * ports that actually use prefixes, add some more localized things + */ +#define PREFIXES_IN_USE +#endif + +/* from options.c */ +#define MAX_MENU_MAPPED_CMDS 32 /* some number */ + +/* player selection constants */ +#define BP_ALIGN 0 +#define BP_GEND 1 +#define BP_RACE 2 +#define BP_ROLE 3 +#define NUM_BP 4 + +/* some array sizes for 'g?' */ +#define WIZKIT_MAX 128 +#define CVT_BUF_SIZE 64 + +#define LUA_VER_BUFSIZ 20 +#define LUA_COPYRIGHT_BUFSIZ 120 /* Symbol offsets */ #define SYM_OFF_P (0) @@ -223,56 +1128,14 @@ enum misc_arti_nums { #define SYM_OFF_X (SYM_OFF_W + WARNCOUNT) #define SYM_MAX (SYM_OFF_X + MAXOTHER) -#include "rect.h" -#include "region.h" -#include "trap.h" -#include "display.h" -#include "sndprocs.h" -#include "decl.h" -#include "timeout.h" - -/* types of calls to bhit() */ -enum bhit_call_types { - ZAPPED_WAND = 0, - THROWN_WEAPON = 1, - THROWN_TETHERED_WEAPON = 2, - KICKED_WEAPON = 3, - FLASHED_LIGHT = 4, - INVIS_BEAM = 5 -}; - -/* attack mode for hmon() */ -enum hmon_atkmode_types { - HMON_MELEE = 0, /* hand-to-hand */ - HMON_THROWN = 1, /* normal ranged (or spitting while poly'd) */ - HMON_KICKED = 2, /* alternate ranged */ - HMON_APPLIED = 3, /* polearm, treated as ranged */ - HMON_DRAGGED = 4 /* attached iron ball, pulled into mon */ -}; - -enum saveformats { - invalid = 0, - historical = 1, /* entire struct, binary, as-is */ - lendian = 2, /* each field, binary, little-endian */ - ascii = 3 /* each field, ascii text (just proof of concept) */ -}; - -enum restore_stages { - REST_GSTATE = 1, /* restoring current level and game state */ - REST_LEVELS = 2, /* restoring remainder of dungeon */ -}; - -/* sortloot() return type; needed before extern.h */ -struct sortloot_item { - struct obj *obj; - char *str; /* result of loot_xname(obj) in some cases, otherwise null */ - int indx; /* signed int, because sortloot()'s qsort comparison routine - assumes (a->indx - b->indx) might yield a negative result */ - xint16 orderclass; /* order rather than object class; 0 => not yet init'd */ - xint16 subclass; /* subclass for some classes */ - xint16 disco; /* discovery status */ -}; -typedef struct sortloot_item Loot; +/* The UNDEFINED macros are used to initialize variables whose + initialized value is not relied upon. + UNDEFINED_VALUE: used to initialize any scalar type except pointers. + UNDEFINED_VALUES: used to initialize any non scalar type without pointers. + UNDEFINED_PTR: can be used only on pointer types. */ +#define UNDEFINED_VALUE 0 +#define UNDEFINED_VALUES { 0 } +#define UNDEFINED_PTR NULL #define MATCH_WARN_OF_MON(mon) \ (Warn_of_mon \ @@ -283,13 +1146,6 @@ typedef struct sortloot_item Loot; typedef uint32_t mmflags_nht; /* makemon MM_ flags */ -#include "flag.h" -#include "vision.h" -#include "engrave.h" - -#include "extern.h" -#include "winprocs.h" -#include "sys.h" /* flags to control makemon(); goodpos() uses some plus has some of its own*/ #define NO_MM_FLAGS 0x000000L /* use this rather than plain 0 */ @@ -514,50 +1370,6 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */ #define RLOC_MSG 0x02 /* show vanish/appear msg */ #define RLOC_NOMSG 0x04 /* prevent appear msg, even for STRAT_APPEARMSG */ -/* Lua callback functions */ -enum nhcore_calls { - NHCORE_START_NEW_GAME = 0, - NHCORE_RESTORE_OLD_GAME, - NHCORE_MOVELOOP_TURN, - NHCORE_GAME_EXIT, - NHCORE_GETPOS_TIP, - - NUM_NHCORE_CALLS -}; - -/* Lua callbacks. TODO: Merge with NHCORE */ -enum nhcb_calls { - NHCB_CMD_BEFORE = 0, - NHCB_LVL_ENTER, - NHCB_LVL_LEAVE, - NHCB_END_TURN, - - NUM_NHCB -}; - -/* Macros for messages referring to hands, eyes, feet, etc... */ -enum bodypart_types { - ARM = 0, - EYE = 1, - FACE = 2, - FINGER = 3, - FINGERTIP = 4, - FOOT = 5, - HAND = 6, - HANDED = 7, - HEAD = 8, - LEG = 9, - LIGHT_HEADED = 10, - NECK = 11, - SPINE = 12, - TOE = 13, - HAIR = 14, - BLOOD = 15, - LUNG = 16, - NOSE = 17, - STOMACH = 18 -}; - /* indices for some special tin types */ #define ROTTEN_TIN 0 #define HOMEMADE_TIN 1 @@ -628,37 +1440,6 @@ enum bodypart_types { #define NC_SHOW_MSG 0x01U #define NC_VIA_WAND_OR_SPELL 0x02U -/* values returned from getobj() callback functions */ -enum getobj_callback_returns { - /* generally invalid - can't be used for this purpose. will give a "silly - * thing" message if the player tries to pick it, unless a more specific - * failure message is in getobj itself - e.g. "You cannot foo gold". */ - GETOBJ_EXCLUDE = -3, - /* invalid because it is not in inventory; used when the hands/self - * possibility is queried and the player passed up something on the - * floor before getobj. */ - GETOBJ_EXCLUDE_NONINVENT = -2, - /* invalid because it is an inaccessible or unwanted piece of gear, but - * pseudo-valid for the purposes of allowing the player to select it and - * getobj to return it if there is a prompt instead of getting "silly - * thing", in order for the getobj caller to present a specific failure - * message. Other than that, the only thing this does differently from - * GETOBJ_EXCLUDE is that it inserts an "else" in "You don't have anything - * else to foo". */ - GETOBJ_EXCLUDE_INACCESS = -1, - /* invalid for purposes of not showing a prompt if nothing is valid but - * pseudo-valid for selecting - identical to GETOBJ_EXCLUDE_INACCESS but - * without the "else" in "You don't have anything else to foo". */ - GETOBJ_EXCLUDE_SELECTABLE = 0, - /* valid - invlet not presented in the summary or the ? menu as a - * recommendation, but is selectable if the player enters it anyway. - * Used for objects that are actually valid but unimportantly so, such - * as shirts for reading. */ - GETOBJ_DOWNPLAY = 1, - /* valid - will be shown in summary and ? menu */ - GETOBJ_SUGGEST = 2, -}; - /* constant passed to explode() for gas spores because gas spores are weird * Specifically, this is an exception to the whole "explode() uses dobuzz types" * system (the range -1 to -9 isn't used by it, for some reason), where this is @@ -685,22 +1466,6 @@ enum getobj_callback_returns { /* monster shooting a wand; note: not -9 to -0 because -0 is ambiguous */ #define BZ_M_WAND(bztyp) (-30 - (bztyp)) /* -39..-30 */ -/* - * option setting restrictions - */ - -enum optset_restrictions { - set_in_sysconf = 0, /* system config file option only */ - set_in_config = 1, /* config file option only */ - set_viaprog = 2, /* may be set via extern program, not seen in game */ - set_gameview = 3, /* may be set via extern program, displayed in game */ - set_in_game = 4, /* may be set via extern program or set in the game */ - set_wizonly = 5, /* may be set set in the game if wizmode */ - set_wiznofuz = 6, /* wizard-mode only, but not by fuzzer */ - set_hidden = 7 /* placeholder for prefixed entries, never show it */ -}; -#define SET__IS_VALUE_VALID(s) ((s < set_in_sysconf) || (s > set_wiznofuz)) - #define FEATURE_NOTICE_VER(major, minor, patch) \ (((unsigned long) major << 24) | ((unsigned long) minor << 16) \ | ((unsigned long) patch << 8) | ((unsigned long) 0)) @@ -752,177 +1517,17 @@ enum optset_restrictions { #define QSORTCALLBACK #endif +#define SIG_RET_TYPE void (*)(int) + #define DEVTEAM_EMAIL "devteam@nethack.org" #define DEVTEAM_URL "https://www.nethack.org/" -#if !defined(NO_VERBOSE_GRANULARITY) -#define VB_ELEMENTS 5 -/* - * Maintenance Notes: - * - if one of the function's involved has a name change, - * and the Verbose() macro use instance is updated to match, - * it will have to be reflected below. If the use instance - * isn't updated to reflect the function name change, - * it will continue to work using the old name if it matches - * one of the entries below. - */ +#if !defined(CROSSCOMPILE) || defined(CROSSCOMPILE_TARGET) +#include "nhlua.h" +#endif -enum verbosity_values { - vb0interrupt_multi = 0x00000001, - vb0use_stethoscope = 0x00000002, - vb0Mb_hit = 0x00000004, - vb0adjattrib = 0x00000008, - vb0ballfall = 0x00000010, - vb0use_crystal_ball1 = 0x00000020, - vb0use_crystal_ball2 = 0x00000040, - vb0digactualhole1 = 0x00000080, - vb0digactualhole2 = 0x00000100, - vb0mdig_tunnel1 = 0x00000200, - vb0mdig_tunnel2 = 0x00000400, - vb0boulder_hits_pool1 = 0x00000800, - vb0boulder_hits_pool2 = 0x00001000, - vb0drop1 = 0x00002000, - vb0drop2 = 0x00004000, - vb0drop3 = 0x00008000, - vb0go_to_level1 = 0x00010000, - vb0go_to_level2 = 0x00020000, - vb0go_to_level3 = 0x00040000, - vb0rot_corpse = 0x00080000, - vb0getpos1 = 0x00100000, - vb0getpos2 = 0x00200000, - vb0off_msg = 0x00400000, - vb0on_msg = 0x00800000, - vb0Blindf_on = 0x01000000, - vb0dog_eat = 0x02000000, - vb0dog_invent = 0x04000000, - vb0dokick = 0x08000000, - vb0toss_up = 0x10000000, - vb0consume_tin1 = 0x20000000, - vb0consume_tin2 = 0x40000000, - - vb1doengrave1 = 0x00000001, - vb1doengrave2 = 0x00000002, - vb1doengrave3 = 0x00000004, - vb1explode = 0x00000008, - vb1moverock = 0x00000010, - vb1still_chewing = 0x00000020, - vb1trapmove1 = 0x00000040, - vb1trapmove2 = 0x00000080, - vb1trapmove3 = 0x00000100, - vb1trapmove4 = 0x00000200, - vb1trapmove5 = 0x00000400, - vb1getobj1 = 0x00000800, - vb1getobj2 = 0x00001000, - vb1doprgold = 0x00002000, - vb1doorlock1 = 0x00004000, - vb1doorlock2 = 0x00008000, - vb1monpoly1 = 0x00010000, - vb1monpoly2 = 0x00020000, - vb1mswingsm = 0x00040000, - vb1missmu = 0x00080000, - vb1mswings = 0x00100000, - vb1wildmiss = 0x00200000, - vb1gulpmu = 0x00400000, - vb1explmu = 0x00800000, - vb1meatmetal1 = 0x01000000, - vb1meatmetal2 = 0x02000000, - vb1meatmetal3 = 0x04000000, - vb1meatmetal4 = 0x08000000, - vb1relobj = 0x10000000, - vb1ready_weapon = 0x20000000, - vb1wield_tool = 0x40000000, - - vb2meatobj1 = 0x00000001, - vb2meatobj2 = 0x00000002, - vb2meatobj3 = 0x00000004, - vb2meatobj4 = 0x00000008, - vb2meatcorpse1 = 0x00000010, - vb2meatcorpse2 = 0x00000020, - vb2mpickgold = 0x00000040, - vb2mpickstuff = 0x00000080, - vb2setmangry = 0x00000100, - vb2mb_trapped = 0x00000200, - vb2m_move1 = 0x00000400, - vb2m_move2 = 0x00000800, - vb2m_move3 = 0x00001000, - vb2m_move4 = 0x00002000, - vb2m_move5 = 0x00004000, - vb2thitu1 = 0x00008000, - vb2thitu2 = 0x00010000, - vb2m_throw = 0x00020000, - vb2handler_menustyle = 0x00040000, - vb2handler_autounlock = 0x00080000, - vb2handler_msg_window = 0x00100000, - vb2handler_whatis_coord1 = 0x00200000, - vb2handler_whatis_coord2 = 0x00400000, - vb2dolook = 0x00800000, - vb2describe_decor1 = 0x01000000, - vb2describe_decor2 = 0x02000000, - vb2loot_mon = 0x04000000, - vb2dotip = 0x08000000, - vb2polymon = 0x10000000, - vb2teleds = 0x20000000, - vb2level_tele = 0x40000000, - - vb3ghost_from_bottle = 0x00000001, - vb3dodip1 = 0x00000002, - vb3dodip2 = 0x00000004, - vb3dodip3 = 0x00000008, - vb3intemple = 0x00000010, - vb3doread1 = 0x00000020, - vb3doread2 = 0x00000040, - vb3doread3 = 0x00000080, - vb3doread4 = 0x00000100, - vb3doread5 = 0x00000200, - vb3doread6 = 0x00000400, - vb3doread7 = 0x00000800, - vb3drop_boulder_on_player= 0x00001000, - vb3do_genocide = 0x00002000, - vb3call_kops1 = 0x00004000, - vb3call_kops2 = 0x00008000, - vb3call_kops3 = 0x00010000, - vb3erode_obj1 = 0x00020000, - vb3erode_obj2 = 0x00040000, - vb3erode_obj3 = 0x00080000, - vb3trapeffect_rocktrap = 0x00100000, - vb3climb_pit = 0x00200000, - vb3drown = 0x00400000, - vb3mon_adjust_speed = 0x00800000, - vb3hit = 0x01000000, - vb3miss = 0x02000000, - vb3makewish = 0x04000000, - vb3prinv = 0x08000000, - /* 3 available bits*/ - - vb4do_attack = 0x00000001, - vb4known_hitum = 0x00000002, - vb4hmon_hitmon1 = 0x00000004, - vb4hmon_hitmon2 = 0x00000008, - vb4mhitm_ad_tlpt = 0x00000010, - vb4mhitm_ad_wrap1 = 0x00000020, - vb4mhitm_ad_wrap2 = 0x00000040, - vb4mhitm_ad_dgst = 0x00000080, - vb4damageum = 0x00000100, - vb4missum = 0x00000200, - vb4hmonas1 = 0x00000400, - vb4hmonas2 = 0x00000800, - vb4hmonas3 = 0x00001000, - vb4hmonas4 = 0x00002000, - vb4passive = 0x00004000, - vb4flash_hits_mon = 0x00008000, - /* 11 available bits */ - - vb_elements = VB_ELEMENTS -}; -#undef VB_ELEMENTS -extern long verbosity_suppressions[vb_elements]; /* in decl.c */ - -#define Verbose(n,s) (flags.verbose && \ - (((n) >= 0 && (n) < vb_elements) && \ - !(verbosity_suppressions[(n)] & vb##n##s))) - -#else /* NO_VERBOSE_GRANULARITY */ -#define Verbose(n,s) (flags.verbose) -#endif /* !NO_VERBOSE_GRANULARITY */ +#include "extern.h" +#include "decl.h" #endif /* HACK_H */ + diff --git a/include/pcconf.h b/include/pcconf.h index 14eda0be1..46a612393 100644 --- a/include/pcconf.h +++ b/include/pcconf.h @@ -177,7 +177,7 @@ #ifndef SYSTEM_H #if !defined(_MSC_VER) -#include "system.h" +/* #include "system.h" */ #endif #endif diff --git a/include/unixconf.h b/include/unixconf.h index 4d5a12b29..ee3fc69bc 100644 --- a/include/unixconf.h +++ b/include/unixconf.h @@ -314,7 +314,7 @@ #define SHELL /* do not delete the '!' command */ #endif -#include "system.h" +/* #include "system.h" */ #if defined(POSIX_TYPES) || defined(__GNUC__) #include diff --git a/include/vmsconf.h b/include/vmsconf.h index a6a020895..78a7de6f6 100644 --- a/include/vmsconf.h +++ b/include/vmsconf.h @@ -255,7 +255,7 @@ typedef __mode_t mode_t; # pragma message disable DOLLARID #endif -#include "system.h" +/* #include "system.h" */ /* Use the high quality random number routines. */ #ifndef USE_ISAAC64 diff --git a/include/windconf.h b/include/windconf.h index 9557cedea..0f8931b19 100644 --- a/include/windconf.h +++ b/include/windconf.h @@ -24,9 +24,9 @@ #define SYSCF /* Use a global configuration */ #define SYSCF_FILE "sysconf" /* Use a file to hold the SYSCF configuration */ -#define DUMPLOG /* Enable dumplog files */ -/*#define DUMPLOG_FILE "nethack-%n-%d.log"*/ -#define DUMPLOG_MSG_COUNT 50 +#ifdef DUMPLOG +#define DUMPLOG_FILE "%TEMP%/nethack-%n-%d.log" +#endif /*#define CHANGE_COLOR*/ /* allow palette changes */ @@ -292,7 +292,7 @@ ATTRNORETURN extern void nethack_exit(int) NORETURN; extern boolean file_exists(const char *); extern boolean file_newer(const char *, const char *); #ifndef SYSTEM_H -#include "system.h" +/* #include "system.h" */ #endif /* Override the default version of nhassert. The default version is unable diff --git a/include/wintty.h b/include/wintty.h index b8446f906..1a6f2ece3 100644 --- a/include/wintty.h +++ b/include/wintty.h @@ -158,7 +158,7 @@ E void xputs(const char *); E void xputg(const glyph_info *, const glyph_info *); #endif E void cl_end(void); -E void clear_screen(void); +E void term_clear_screen(void); E void home(void); E void standoutbeg(void); E void standoutend(void); @@ -291,7 +291,26 @@ E win_request_info *tty_ctrl_nhwindow(winid, int, win_request_info *); E void tty_refresh_inventory(int start, int stop, int y); #endif -#ifdef NO_TERMS +/* termcap is implied if NO_TERMS is not defined */ +#ifndef NO_TERMS +#ifndef NO_TERMCAP_HEADERS +#ifdef delay_output /* avoid conflict in curses.h */ +#undef delay_output +#endif +#include +#ifdef clear_screen /* avoid a conflict */ +#undef clear_screen +#endif +#include +#else +extern int tgetent(char *, const char *); +extern void tputs(const char *, int, int (*)(int)); +extern int tgetnum(const char *); +extern int tgetflag(const char *); +extern char *tgetstr(const char *, char **); +extern char *tgoto(const char *, int, int); +#endif /* NO_TERMCAP_HEADERS */ +#else /* ?NO_TERMS */ #ifdef MAC #ifdef putchar #undef putchar @@ -317,7 +336,7 @@ E int term_puts(const char *str); E void video_update_positionbar(char *); #endif #endif /*MSDOS*/ -#endif /*NO_TERMS*/ +#endif /* NO_TERMS */ #undef E diff --git a/include/wintype.h b/include/wintype.h index 77b8af6c0..b498c13f3 100644 --- a/include/wintype.h +++ b/include/wintype.h @@ -5,8 +5,6 @@ #ifndef WINTYPE_H #define WINTYPE_H -#include "integer.h" - typedef int winid; /* a window identifier */ /* generic parameter - must not be any larger than a pointer */ diff --git a/outdated/include/os2conf.h b/outdated/include/os2conf.h index fd625512a..20b2fe82d 100644 --- a/outdated/include/os2conf.h +++ b/outdated/include/os2conf.h @@ -65,14 +65,7 @@ #endif #ifndef SYSTEM_H -#include "system.h" -#endif - -#ifndef index -#define index strchr -#endif -#ifndef rindex -#define rindex strrchr +/* #include "system.h" */ #endif #include diff --git a/src/decl.c b/src/decl.c index 959fd1f89..9caca237f 100644 --- a/src/decl.c +++ b/src/decl.c @@ -5,46 +5,6 @@ #include "hack.h" -const char quitchars[] = " \r\n\033"; -const char vowels[] = "aeiouAEIOU"; -const char ynchars[] = "yn"; -const char ynqchars[] = "ynq"; -const char ynaqchars[] = "ynaq"; -const char ynNaqchars[] = "yn#aq"; -NEARDATA long yn_number = 0L; - -const char disclosure_options[] = "iavgco"; - -/* x/y/z deltas for the 10 movement directions (8 compass pts, 2 down/up) */ -const schar xdir[N_DIRS_Z] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 }; -const schar ydir[N_DIRS_Z] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 }; -const schar zdir[N_DIRS_Z] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 }; -/* redordered directions, cardinals first */ -const schar dirs_ord[N_DIRS] = - { DIR_W, DIR_N, DIR_E, DIR_S, DIR_NW, DIR_NE, DIR_SE, DIR_SW }; - -NEARDATA struct flag flags; -NEARDATA boolean has_strong_rngseed = FALSE; -NEARDATA struct instance_flags iflags; -NEARDATA struct you u; -NEARDATA time_t ubirthday; -NEARDATA struct u_realtime urealtime; - -NEARDATA struct obj *uwep, *uarm, *uswapwep, - *uquiver, /* quiver */ - *uarmu, /* under-wear, so to speak */ - *uskin, /* dragon armor, if a dragon */ - *uarmc, *uarmh, *uarms, *uarmg,*uarmf, *uamul, - *uright, *uleft, *ublindf, *uchain, *uball; - -struct engr *head_engr; - -const int shield_static[SHIELD_COUNT] = { - S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */ - S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, - S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, -}; - const char * const nhcb_name[NUM_NHCB] = { "cmd_before", "level_enter", @@ -53,12 +13,10 @@ const char * const nhcb_name[NUM_NHCB] = { }; int nhcb_counts[NUM_NHCB] = DUMMY; - NEARDATA const struct c_color_names c_color_names = { "black", "amber", "golden", "light blue", "red", "green", "silver", "blue", "purple", "white", "orange" }; - const char *c_obj_colors[] = { "black", /* CLR_BLACK */ "red", /* CLR_RED */ @@ -78,44 +36,19 @@ const char *c_obj_colors[] = { "white", /* CLR_WHITE */ }; -const struct c_common_strings c_common_strings = { "Nothing happens.", - "That's enough tries!", - "That is a silly thing to %s.", - "shudder for a moment.", - "something", - "Something", - "You can move again.", - "Never mind.", - "vision quickly clears.", - { "the", "your" }, - { "mon", "you" } }; - -/* NOTE: the order of these words exactly corresponds to the - order of oc_material values #define'd in objclass.h. */ -const char *materialnm[] = { "mysterious", "liquid", "wax", "organic", - "flesh", "paper", "cloth", "leather", - "wooden", "bone", "dragonhide", "iron", - "metal", "copper", "silver", "gold", - "platinum", "mithril", "plastic", "glass", - "gemstone", "stone" }; - -char emptystr[] = {0}; /* non-const */ - -/* Global windowing data, defined here for multi-window-system support */ -NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN; -#ifdef WIN32 -boolean fqn_prefix_locked[PREFIX_COUNT] = { FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, - FALSE, FALSE, FALSE, - FALSE }; -#endif - -#ifdef PREFIXES_IN_USE -const char *fqn_prefix_names[PREFIX_COUNT] = { - "hackdir", "leveldir", "savedir", "bonesdir", "datadir", - "scoredir", "lockdir", "sysconfdir", "configdir", "troubledir" +const struct c_common_strings c_common_strings = + { "Nothing happens.", + "That's enough tries!", + "That is a silly thing to %s.", + "shudder for a moment.", + "something", + "Something", + "You can move again.", + "Never mind.", + "vision quickly clears.", + { "the", "your" }, + { "mon", "you" } }; -#endif const struct savefile_info default_sfinfo = { #ifdef NHSTDC @@ -140,7 +73,67 @@ const struct savefile_info default_sfinfo = { #endif }; +const char disclosure_options[] = "iavgco"; +char emptystr[] = {0}; /* non-const */ + +NEARDATA struct flag flags; /* extern declaration is in flag.h, not decl.h */ + +/* Global windowing data, defined here for multi-window-system support */ +#ifdef WIN32 +boolean fqn_prefix_locked[PREFIX_COUNT] = { FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, + FALSE, FALSE, FALSE, + FALSE }; +#endif +#ifdef PREFIXES_IN_USE +const char *fqn_prefix_names[PREFIX_COUNT] = { + "hackdir", "leveldir", "savedir", "bonesdir", "datadir", + "scoredir", "lockdir", "sysconfdir", "configdir", "troubledir" +}; +#endif + +/* x/y/z deltas for the 10 movement directions (8 compass pts, 2 down/up) */ +const schar xdir[N_DIRS_Z] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 }; +const schar ydir[N_DIRS_Z] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 }; +const schar zdir[N_DIRS_Z] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 }; +/* redordered directions, cardinals first */ +const schar dirs_ord[N_DIRS] = + { DIR_W, DIR_N, DIR_E, DIR_S, DIR_NW, DIR_NE, DIR_SE, DIR_SW }; + +NEARDATA boolean has_strong_rngseed = FALSE; +struct engr *head_engr; +NEARDATA struct instance_flags iflags; +/* NOTE: the order of these words exactly corresponds to the + order of oc_material values #define'd in objclass.h. */ +const char *materialnm[] = { "mysterious", "liquid", "wax", "organic", + "flesh", "paper", "cloth", "leather", + "wooden", "bone", "dragonhide", "iron", + "metal", "copper", "silver", "gold", + "platinum", "mithril", "plastic", "glass", + "gemstone", "stone" }; +const char quitchars[] = " \r\n\033"; NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo; +const int shield_static[SHIELD_COUNT] = { + S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */ + S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, + S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, +}; +NEARDATA struct you u; +NEARDATA time_t ubirthday; +NEARDATA struct u_realtime urealtime; +NEARDATA struct obj *uwep, *uarm, *uswapwep, + *uquiver, /* quiver */ + *uarmu, /* under-wear, so to speak */ + *uskin, /* dragon armor, if a dragon */ + *uarmc, *uarmh, *uarms, *uarmg,*uarmf, *uamul, + *uright, *uleft, *ublindf, *uchain, *uball; +const char vowels[] = "aeiouAEIOU"; +NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN; +const char ynchars[] = "yn"; +const char ynqchars[] = "ynq"; +const char ynaqchars[] = "ynaq"; +const char ynNaqchars[] = "yn#aq"; +NEARDATA long yn_number = 0L; #ifdef PANICTRACE const char *ARGV0; diff --git a/src/utf8map.c b/src/utf8map.c index e81aa8380..6a2bc3718 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -3,7 +3,6 @@ /* NetHack may be freely redistributed. See license for details. */ #include "hack.h" -#include "integer.h" #include extern const struct symparse loadsyms[]; diff --git a/sys/msdos/Makefile.GCC b/sys/msdos/Makefile.GCC index 74c14523a..065d52967 100644 --- a/sys/msdos/Makefile.GCC +++ b/sys/msdos/Makefile.GCC @@ -400,7 +400,7 @@ YOUPROP_H = $(PERMONST_H) $(MONDATA_H) $(INCL)/prop.h \ YOU_H = $(MONST_H) $(YOUPROP_H) $(INCL)/align.h \ $(INCL)/attrib.h $(INCL)/you.h DISPLAY_H = $(MONDATA_H) $(INCL)/vision.h $(INCL)/display.h -PCCONF_H = $(INCL)/micro.h $(INCL)/system.h $(INCL)/pcconf.h \ +PCCONF_H = $(INCL)/micro.h $(INCL)/cstd.h $(INCL)/pcconf.h \ $(MSYS)/pcvideo.h CONFIG_H = $(GLOBAL_H) $(INCL)/fnamesiz.h $(INCL)/tradstdc.h \ $(INCL)/config1.h $(INCL)/config.h @@ -1081,7 +1081,7 @@ TARGET_CFLAGS=$(cflags) #$(CONFIG_H): ../include/config.h ../include/config1.h ../include/patchlevel.h \ # ../include/tradstdc.h ../include/integer.h \ # ../include/global.h ../include/coord.h ../include/vmsconf.h \ -# ../include/system.h ../include/nhlua.h ../include/unixconf.h \ +# ../include/cstd.h ../include/nhlua.h ../include/unixconf.h \ # ../include/pcconf.h ../include/micro.h ../include/windconf.h \ # ../include/warnings.h ../include/fnamesiz.h # touch $(CONFIG_H) diff --git a/sys/msdos/font.c b/sys/msdos/font.c index 8a4471d51..f3dfe7d10 100755 --- a/sys/msdos/font.c +++ b/sys/msdos/font.c @@ -1,7 +1,6 @@ /* Maintain a data structure describing a monospaced bitmap font */ #include "hack.h" -#include "integer.h" #include "font.h" static uint32 read_u32(const unsigned char *); diff --git a/sys/msdos/font.h b/sys/msdos/font.h index d5274fa6f..97868e37a 100755 --- a/sys/msdos/font.h +++ b/sys/msdos/font.h @@ -3,8 +3,6 @@ #ifndef FONT_H #define FONT_H -#include "integer.h" - /* * The file format is Linux PSF, version 2. Version 1 is not supported. * Actual Linux fonts are restricted to 256 or 512 glyphs; for NetHack, the diff --git a/sys/msdos/video.c b/sys/msdos/video.c index 24362cfc6..2fa7f8733 100644 --- a/sys/msdos/video.c +++ b/sys/msdos/video.c @@ -156,7 +156,7 @@ backsp(void) } void -clear_screen(void) +term_clear_screen(void) { if (!iflags.grmode) { txt_clear_screen(); diff --git a/sys/msdos/vidvesa.c b/sys/msdos/vidvesa.c index e616636e5..226c3906e 100644 --- a/sys/msdos/vidvesa.c +++ b/sys/msdos/vidvesa.c @@ -1062,7 +1062,7 @@ vesa_Init(void) iflags.over_view = FALSE; CO = 80; LI = 25; - /* clear_screen() */ /* not vesa_clear_screen() */ + /* term_clear_screen() */ /* not vesa_clear_screen() */ return; } #endif @@ -1078,7 +1078,7 @@ vesa_Init(void) iflags.over_view = FALSE; CO = 80; LI = 25; - /* clear_screen() */ /* not vesa_clear_screen() */ + /* term_clear_screen() */ /* not vesa_clear_screen() */ return; } @@ -1100,7 +1100,7 @@ vesa_Init(void) vesa_SetPalette(paletteptr); g_attribute = attrib_gr_normal; font = vesa_FontPtrs(); - clear_screen(); + term_clear_screen(); clipx = 0; clipxmax = clipx + (viewport_cols - 1); clipy = 0; diff --git a/sys/msdos/vidvga.c b/sys/msdos/vidvga.c index 7752770ec..aa287e83e 100644 --- a/sys/msdos/vidvga.c +++ b/sys/msdos/vidvga.c @@ -268,7 +268,7 @@ void vga_cl_end(int col, int row) /* * This is being done via character writes. * This should perhaps be optimized for speed by using VGA write - * mode 2 methods as did clear_screen() + * mode 2 methods as did term_clear_screen() */ for (count = col; count < (CO - 1); ++count) { vga_WriteChar(' ', count, row, BACKGROUND_VGA_COLOR); @@ -769,7 +769,7 @@ vga_Init(void) iflags.over_view = FALSE; CO = 80; LI = 25; - /* clear_screen() */ /* not vga_clear_screen() */ + /* term_clear_screen() */ /* not vga_clear_screen() */ return; } #endif @@ -807,7 +807,7 @@ vga_Init(void) psf_font = NULL; } - clear_screen(); + term_clear_screen(); clipx = 0; clipxmax = clipx + (viewport_size - 1); } diff --git a/sys/share/pcunix.c b/sys/share/pcunix.c index 8bccd1184..68c6fe051 100644 --- a/sys/share/pcunix.c +++ b/sys/share/pcunix.c @@ -19,7 +19,7 @@ extern char orgdir[]; #if defined(TTY_GRAPHICS) extern void backsp(void); -extern void clear_screen(void); +extern void term_clear_screen(void); #endif #if 0 @@ -189,7 +189,7 @@ getlock(void) if (recover_savefile()) { #if defined(TTY_GRAPHICS) if (WINDOWPORT(tty)) - clear_screen(); /* display gets fouled up otherwise */ + term_clear_screen(); /* display gets fouled up otherwise */ #endif goto gotlock; } else { diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 1df1c91a8..725c1d31c 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -432,7 +432,7 @@ QUIETCC=0 # Nothing below this line should have to be changed. # # Other things that have to be reconfigured are in config.h, -# {unixconf.h, pcconf.h}, and possibly system.h +# {unixconf.h, pcconf.h}, and possibly cstd.h # Add rule for possible cross-compiler $(TARGETPFX)%.o : %.c @@ -549,7 +549,7 @@ HACKINCL = align.h artifact.h artilist.h attrib.h botl.h \ permonst.h prop.h rect.h region.h sym.h defsym.h rm.h sp_lev.h \ spell.h sndprocs.h seffects.h sys.h system.h tcap.h timeout.h \ tradstdc.h trap.h unixconf.h vision.h vmsconf.h wintty.h wincurs.h \ - winX.h winprocs.h wintype.h you.h youprop.h + winX.h winprocs.h wintype.h you.h youprop.h cstd.h HSOURCES = $(HACKINCL) dgn_file.h @@ -800,7 +800,7 @@ depend: ../sys/unix/depend.awk \ $(CONFIG_H): ../include/config.h ../include/config1.h ../include/patchlevel.h \ ../include/tradstdc.h ../include/integer.h \ ../include/global.h ../include/coord.h ../include/vmsconf.h \ - ../include/system.h ../include/nhlua.h ../include/unixconf.h \ + ../include/cstd.h ../include/nhlua.h ../include/unixconf.h \ ../include/pcconf.h ../include/micro.h ../include/windconf.h \ ../include/warnings.h ../include/fnamesiz.h touch $(CONFIG_H) diff --git a/sys/unix/NetHack.xcodeproj/project.pbxproj b/sys/unix/NetHack.xcodeproj/project.pbxproj index 6dd49f8f0..33846e005 100644 --- a/sys/unix/NetHack.xcodeproj/project.pbxproj +++ b/sys/unix/NetHack.xcodeproj/project.pbxproj @@ -306,7 +306,7 @@ 3186A38521A4B0FB0052BF02 /* mextra.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = mextra.h; path = ../../include/mextra.h; sourceTree = ""; }; 3186A38721A4B0FB0052BF02 /* color.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = color.h; path = ../../include/color.h; sourceTree = ""; }; 3186A38821A4B0FB0052BF02 /* artifact.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = artifact.h; path = ../../include/artifact.h; sourceTree = ""; }; - 3186A38A21A4B0FB0052BF02 /* system.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = system.h; path = ../../include/system.h; sourceTree = ""; }; + 3186A38A21A4B0FB0052BF02 /* cstd.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cstd.h; path = ../../include/cstd.h; sourceTree = ""; }; 3186A38E21A4B0FC0052BF02 /* dlb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dlb.h; path = ../../include/dlb.h; sourceTree = ""; }; 3186A38F21A4B0FC0052BF02 /* monflag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = monflag.h; path = ../../include/monflag.h; sourceTree = ""; }; 3186A39121A4B0FC0052BF02 /* micro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = micro.h; path = ../../include/micro.h; sourceTree = ""; }; @@ -823,7 +823,7 @@ 3186A3B621A4B0FD0052BF02 /* sp_lev.h */, 3186A3A321A4B0FD0052BF02 /* spell.h */, 3186A3CB21A4B0FE0052BF02 /* sys.h */, - 3186A38A21A4B0FB0052BF02 /* system.h */, + 3186A38A21A4B0FB0052BF02 /* cstd.h */, 3186A3C321A4B0FE0052BF02 /* tcap.h */, 3186A3A121A4B0FD0052BF02 /* tile2x11.h */, 3186A39421A4B0FC0052BF02 /* tileset.h */, diff --git a/sys/windows/Makefile.nmake b/sys/windows/Makefile.nmake index eec12a67a..b8758ce19 100644 --- a/sys/windows/Makefile.nmake +++ b/sys/windows/Makefile.nmake @@ -453,7 +453,7 @@ HACKINCL = $(INCL)\align.h $(INCL)\artifact.h $(INCL)\artilist.h \ $(INCL)\optlist.h $(INCL)\patchlevel.h $(INCL)\pcconf.h \ $(INCL)\permonst.h $(INCL)\prop.h $(INCL)\rect.h $(INCL)\region.h \ $(INCL)\sym.h $(INCL)\defsym.h $(INCL)\rm.h $(INCL)\sp_lev.h \ - $(INCL)\spell.h $(INCL)\sys.h $(INCL)\system.h $(INCL)\tcap.h \ + $(INCL)\spell.h $(INCL)\sys.h $(INCL)\cstd.h $(INCL)\tcap.h \ $(INCL)\timeout.h $(INCL)\tradstdc.h $(INCL)\trap.h \ $(INCL)\unixconf.h $(INCL)\vision.h $(INCL)\vmsconf.h \ $(INCL)\wintty.h $(INCL)\wincurs.h $(INCL)\winX.h \ @@ -851,7 +851,7 @@ RCFLAGS = $(RCFLAGS) -dRCWAV CONFIG_H = $(INCL)\config.h $(INCL)\config1.h $(INCL)\patchlevel.h \ $(INCL)\tradstdc.h $(INCL)\global.h $(INCL)\coord.h \ - $(INCL)\vmsconf.h $(INCL)\system.h $(INCL)\nhlua.h \ + $(INCL)\vmsconf.h $(INCL)\cstd.h $(INCL)\nhlua.h \ $(INCL)\unixconf.h $(INCL)\pcconf.h $(INCL)\micro.h \ $(INCL)\windconf.h $(INCL)\warnings.h \ $(INCL)\fnamesiz.h @@ -2339,7 +2339,7 @@ MOCPATH = moc.exe #$(CONFIG_H): $(INCL)\config.h $(INCL)\config1.h $(INCL)\patchlevel.h \ # $(INCL)\tradstdc.h $(INCL)\integer.h \ # $(INCL)\global.h $(INCL)\coord.h $(INCL)\vmsconf.h \ -# $(INCL)\system.h $(INCL)\nhlua.h $(INCL)\unixconf.h \ +# $(INCL)\cstd.h $(INCL)\nhlua.h $(INCL)\unixconf.h \ # $(INCL)\pcconf.h $(INCL)\micro.h $(INCL)\windconf.h \ # $(INCL)\warnings.h $(INCL)\fnamesiz.h # touch $(CONFIG_H) @@ -2759,7 +2759,7 @@ MOCPATH = moc.exe #$(CONFIG_H): $(INCL)\config.h $(INCL)\config1.h $(INCL)\patchlevel.h \ # $(INCL)\tradstdc.h $(INCL)\integer.h \ # $(INCL)\global.h $(INCL)\coord.h $(INCL)\vmsconf.h \ -# $(INCL)\system.h $(INCL)\nhlua.h $(INCL)\unixconf.h \ +# $(INCL)\cstd.h $(INCL)\nhlua.h $(INCL)\unixconf.h \ # $(INCL)\pcconf.h $(INCL)\micro.h $(INCL)\windconf.h \ # $(INCL)\warnings.h $(INCL)\fnamesiz.h # touch $(CONFIG_H) diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index 35e552734..1bbbeccf3 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -1054,7 +1054,7 @@ tty_start_screen(void) void tty_end_screen(void) { - clear_screen(); + term_clear_screen(); really_move_cursor(); buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0); back_buffer_flip(); @@ -1067,7 +1067,7 @@ CtrlHandler(DWORD ctrltype) switch (ctrltype) { /* case CTRL_C_EVENT: */ case CTRL_BREAK_EVENT: - clear_screen(); + term_clear_screen(); case CTRL_CLOSE_EVENT: case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: @@ -1557,7 +1557,7 @@ raw_clear_screen(void) } void -clear_screen(void) +term_clear_screen(void) { buffer_fill_to_end(console.back_buffer, &clear_cell, 0, 0); home(); diff --git a/sys/windows/vs/NetHack/NetHack.vcxproj b/sys/windows/vs/NetHack/NetHack.vcxproj index 456c27eb4..a997957aa 100644 --- a/sys/windows/vs/NetHack/NetHack.vcxproj +++ b/sys/windows/vs/NetHack/NetHack.vcxproj @@ -210,6 +210,7 @@ + @@ -285,4 +286,4 @@ - \ No newline at end of file + diff --git a/sys/windows/vs/NetHackW/NetHackW.vcxproj b/sys/windows/vs/NetHackW/NetHackW.vcxproj index 23be63a74..c185cd1dc 100644 --- a/sys/windows/vs/NetHackW/NetHackW.vcxproj +++ b/sys/windows/vs/NetHackW/NetHackW.vcxproj @@ -225,6 +225,7 @@ + @@ -273,7 +274,6 @@ - @@ -316,4 +316,4 @@ - \ No newline at end of file + diff --git a/sys/windows/windmain.c b/sys/windows/windmain.c index 93f9a54b4..bcfeca6b0 100644 --- a/sys/windows/windmain.c +++ b/sys/windows/windmain.c @@ -36,7 +36,7 @@ extern void mswin_destroy_reg(void); extern void backsp(void); #endif #endif -extern void clear_screen(void); +extern void term_clear_screen(void); #ifdef update_file #undef update_file @@ -1288,14 +1288,14 @@ getlock(void) : "not start a new game"); #ifdef WIN32CON if (istty) - clear_screen(); + term_clear_screen(); #endif raw_printf("%s", oops); if (prompt_result == 1) { /* recover */ if (recover_savefile()) { #if 0 if (istty) - clear_screen(); /* display gets fouled up otherwise */ + term_clear_screen(); /* display gets fouled up otherwise */ #endif goto gotlock; } else { @@ -1309,7 +1309,7 @@ getlock(void) if (eraseoldlocks()) { #ifdef WIN32CON if (istty) - clear_screen(); /* display gets fouled up otherwise */ + term_clear_screen(); /* display gets fouled up otherwise */ #endif goto gotlock; } else { diff --git a/win/share/bmptiles.c b/win/share/bmptiles.c index 38fab4512..31ea391bb 100644 --- a/win/share/bmptiles.c +++ b/win/share/bmptiles.c @@ -3,7 +3,6 @@ /* NetHack may be freely redistributed. See license for details. */ #include "config.h" -#include "integer.h" #include "tileset.h" /* First BMP file header */ diff --git a/win/tty/termcap.c b/win/tty/termcap.c index 2eab34028..cd2fb290c 100644 --- a/win/tty/termcap.c +++ b/win/tty/termcap.c @@ -496,7 +496,7 @@ tty_start_screen(void) void tty_end_screen(void) { - clear_screen(); + term_clear_screen(); xputs(VE); xputs(TE); } @@ -618,7 +618,7 @@ cl_end(void) } void -clear_screen(void) +term_clear_screen(void) { /* note: if CL is null, then termcap initialization failed, so don't attempt screen-oriented I/O during final cleanup. diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 7945fc201..06089c85d 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -903,7 +903,7 @@ erase_menu_or_text(winid window, struct WinDesc *cw, boolean clear) tty_curs(window, 1, 0); cl_eos(); } else if (clear) { - clear_screen(); + term_clear_screen(); } else { docrt(); flush_screen(1); @@ -1004,7 +1004,7 @@ tty_clear_nhwindow(winid window) gc.context.botlx = 1; /*FALLTHRU*/ case NHW_BASE: - clear_screen(); + term_clear_screen(); /* [this should reset state for MESSAGE, MAP, and STATUS] */ break; case NHW_MENU: @@ -1312,7 +1312,7 @@ process_menu_window(winid window, struct WinDesc *cw) tty_curs(window, 1, 0); cl_eos(); } else - clear_screen(); + term_clear_screen(); } rp = resp; @@ -1669,7 +1669,7 @@ process_text_window(winid window, struct WinDesc *cw) tty_curs(window, 1, 0); cl_eos(); } else - clear_screen(); + term_clear_screen(); n = 0; } tty_curs(window, 1, n++); @@ -1814,7 +1814,7 @@ tty_display_nhwindow( tty_curs(window, 1, 0); cl_eos(); } else - clear_screen(); + term_clear_screen(); ttyDisplay->toplin = TOPLINE_EMPTY; } else { if (WIN_MESSAGE != WIN_ERR) @@ -1897,7 +1897,7 @@ tty_destroy_nhwindow(winid window) if (cw->type == NHW_MESSAGE) iflags.window_inited = 0; if (cw->type == NHW_MAP) - clear_screen(); + term_clear_screen(); #ifdef TTY_PERM_INVENT if (cw->type == NHW_PERMINVENT) { int r, c;