/*
* File: AppHdr.h
* Summary: Precompiled header used by Crawl.
* Written by: Jesse Jones
*
* Abstract: CodeWarrior and MSVC both support precompiled headers which can
* significantly speed up compiles. Unlike CodeWarrior MSVC imposes
* some annoying restrictions on precompiled headers: the precompiled
* header *must* be the first include in all cc files. Any includes or
* other statements that occur before the pch include are ignored. This
* is really stupid and can lead to bizarre errors, but it does mean
* that we shouldn't run into any problems on systems without precompiled
* headers.
*
* Copyright © 1999 Jesse Jones.
*/
/* Disable warning about:
4290: the way VC handles the throw() specifier
4267: "possible loss of data" when switching data types without a cast
*/
/* Don't define min and max as macros, define them via STL */
// The maximum memory that the user-script Lua interpreter can
// allocate, in kilobytes. This limit is enforced to prevent
// badly-written or malicious user scripts from consuming too much
// memory.
//
// Enable support for Unicode character glyphs. Note that this needs
// to be accompanied by changes to linker and compiler options and may
// not be available on all platforms. In most cases you want to set
// this option from your makefile, not directly in AppHdr.h (See
// INSTALL for more details.)
//
// #define UNICODE_GLYPHS
// Uncomment to prevent Crawl from looking for a list of saves when
// asking the player to enter a name. This can speed up startup
// considerably if you have a lot of saves lying around (even more so
// if the saves are zipped).
//
// #define DISABLE_SAVEGAME_LISTS
// Uncomment to prevent Crawl from remembering startup preferences.
//
// #define DISABLE_STICKY_STARTUP_OPTIONS
//
// Define 'UNIX' if the target OS is UNIX-like.
//
//
// OS X's Terminal.app has color handling problems; dark grey is
// especially bad, so we'll want to remap that. OS X is otherwise
// Unix-ish, so we shouldn't need other special handling.
//
//
// FreeBSD
//
// There's no /usr/bin/zip in FreeBSD.
//
// MinGW
//
// System Defines
// Define plain_term for Unix and dos_term for DOS.
// Uncomment if you're running Crawl with dgamelaunch and have
// problems viewing games in progress. This affects how Crawl
// clears the screen (see DGL_CLEAR_SCREEN) below.
//
// #define DGAMELAUNCH
// If this is defined, Crawl will attempt to save and exit when it
// receives a hangup signal.
// Unix builds use curses/ncurses, which supports colour.
//
// This will allow using the standout attribute in curses to
// mark friendly monsters... results depend on the type of
// term used... under X Windows try "rxvt".
// More sophisticated character handling
// How long (milliseconds) curses should wait for additional characters
// after seeing an Escape (0x1b) keypress. May not be available on all
// curses implementations.
// Use this to seed the PRNG with a bit more than just time()... turning
// this off is perfectly okay, the game just becomes more exploitable
// with a bit of hacking (ie only by people who know how).
//
// For now, we'll make it default to on for Linux (who should have
// no problems with compiling this).
// Use POSIX regular expressions
// If you have libpcre, you can use that instead of POSIX regexes -
// uncomment the line below and add -lpcre to your makefile.
// #define REGEX_PCRE
// Uncomment (and edit as appropriate) to play sounds.
//
// WARNING: Enabling sounds may compromise security if Crawl is installed
// setuid or setgid. Filenames passed to this command *are not
// validated in any way*.
//
// #define SOUND_PLAY_COMMAND "/usr/bin/play -v .5 %s 2>/dev/null &"
// For cases when the game will be played on terms that don't support the
// curses "bold == lighter" 16 colour mode. -- bwr
//
// Darkgrey is a particular problem in the 8 colour mode. Popular values
// for replacing it around here are: WHITE, BLUE, and MAGENTA. This
// option has no affect in 16 colour mode. -- bwr
//
// #define USE_8_COLOUR_TERM_MAP
// #define COL_TO_REPLACE_DARKGREY MAGENTA
// [dshaligram] This is distressing, but djgpp lacks (v)snprintf, and
// we have to support DOS. Ow. FIXME
// Use Perl-compatible regular expressions. libpcre must be available and
// linked in. This is optional.
// NT and better are happy with /; I'm not sure how 9x reacts.
// Uncomment to play sounds. winmm must be linked in if this is uncommented.
// #define WINMM_PLAY_SOUNDS
// Use Perl-compatible regular expressions. libpcre must be available and
// linked in. This is optional.
// Defines for dgamelaunch-specific things.
// DGL_CLEAR_SCREEN specifies the escape sequence to use to clear
// the screen (used only when DGAMELAUNCH is defined). We make no
// attempt to discover an appropriate escape sequence for the
// term, assuming that dgamelaunch admins can adjust this as
// needed.
//
// Why this is necessary: dgamelaunch's ttyplay initialises
// playback by jumping to the last screen clear and playing back
// from there. For that to work, ttyplay must be able to recognise
// the clear screen sequence, and ncurses clear()+refresh()
// doesn't do the trick.
//
// This secures the PRNG itself by hashing the values with SHA256.
// It doesn't have much point if USE_MORE_SECURE_SEED is not used.
// PRNG will be about 15 times slower when this is turned on, but
// even with that the cpu time used by the PRNG is relatively small.
// Startup preferences are saved by player name rather than uid,
// since all players use the same uid in dgamelaunch.
// Increase the size of the topscores file for public servers.
// If defined, the hiscores code dumps preformatted verbose and terse
// death message strings in the logfile for the convenience of logfile
// parsers.
// Basic messaging for dgamelaunch, based on SIMPLE_MAIL for
// NetHack and Slash'EM. I'm calling this "messaging" because that's
// closer to reality.
// How often we check for messages. This is not once per turn, but once
// per player-input. Message checks are not performed if the keyboard
// buffer is full, so messages should not interrupt macros.
// Record game milestones in an xlogfile.
// Record where players are currently.
// Uses <playername>-macro.txt as the macro file if uncommented.
// #define DGL_NAMED_MACRO_FILE
// Uses Options.macro_dir as the full path to the macro file. Mutually
// exclusive with DGL_NAMED_MACRO_FILE.
// Makes the game ask the user to hit Enter after bailing out with
// an error message.
// Enable core dumps. Note that this will not create core dumps if
// Crawl is installed setuid or setgid, but dgamelaunch installs should
// not be installing Crawl set[ug]id anyway.
// Use UTC for dgamelaunch servers.
// Debugging Defines
// Bounds checking and asserts
// Outputs many "hidden" details, defaults to wizard on.
// Scan for bad items before every input (may be slow)
//
// This function might slow things down quite a bit
// on slow machines because it's going to go through
// every item on the level and do string comparisons
// against the name. Still, it is nice to know the
// turn in which "bad" items appear.
// #define DEBUG 0 // leave this undefined for those lamers who use #ifdef
// Lua user scripts (NOTE: this may also be enabled in your makefile!)
//
// Enables Crawl's Lua bindings for user scripts. See the section on
// Lua in INSTALL for more information. NOTE: CLUA_BINDINGS is enabled
// by default in all standard makefiles. Commenting it out here may
// not be sufficient to disable user-Lua - you must also check your
// makefile and remove -DCLUA_BINDINGS. You can use V in-game to check
// whether user-scripts are enabled.
//
// #define CLUA_BINDINGS
// Game Play Defines
// number of older messages stored during play and in save files
// clamp time between command inputs at 5 minutes when reporting play time.
// Set this to the number of runes that will be required to enter Zot's
// domain. You shouldn't set this really high unless you want to
// make players spend far too much time in Pandemonium/The Abyss.
//
// Traditional setting of this is one rune, but three is pretty standard now.
// Number of top scores to keep. See above for the dgamelaunch setting.
// Option to allow scoring of wizard characters. Note that even if
// you define this option, wizard characters are still tagged as such
// in the score file.
// #define SCORE_WIZARD_CHARACTERS
// ================================================= --------------------------
//jmf: New defines for a bunch of optional features.
// ================================================= --------------------------
// Use special colours for various channels of messages
// Wizard death option (needed to test new death messages)
// Semi-Controlled Blink
// Use new system for weighting str and dex based on weapon type, -- bwr
// mv: (new 9 Aug 01) turns off missile trails, might be slow on some computers
// #define MISSILE_TRAILS_OFF
// bwr: set this to non-zero if you want to know the pluses, "runed" status
// of the monster's weapons in the hiscore file.
// ====================== -----------------------------------------------------
//jmf: end of new defines
// ====================== -----------------------------------------------------
// If you are installing Crawl for multiple users, define SAVE_DIR
// to the directory where saves, bones, and score file will go...
// end it with a '/'. Since all player files will be in the same
// directory, the players UID will be appended when this option is
// set.
//
// If you want to build Crawl that only one user will use, you do not need
// to set SAVE_DIR_PATH (and do not need to run make install).
//
// Setting it to nothing or not setting it will cause all game files to
// be dumped in the current directory.
//
// #define SAVE_DIR_PATH "/opt/crawl/lib/"
// #define SAVE_DIR_PATH ""
// Define SAVE_PACKAGE_CMD to a command to compress and bundle the save
// game files into a single unit... the two %s will be replaced with the
// players save file name. Define LOAD_UNPACKAGE_CMD to undo this process
// the %s is the same as above. The second %s in LOAD_UNPACKAGE_CMD
// is for the output directory.
//
// PACKAGE_SUFFIX is used when the package file name is needed
//
/*
FIXME: Unless sanitized elsewhere in the codebase, a specially crafted
save directory or character name will allow arbitrary code execution
with escalated privileges (namely, with group "games").
FIXME: replace system(3) with fork(2) and execve(2).
*/
// The default behaviour is to compress with zip.
// To use GNU tar instead, define SAVE_PACKAGE_TAR.
// To avoid compression entirely, define SAVE_PACKAGE_NONE.
// The --absolute-names switch is only there to suppress noise on stdout.
// All the paths are removed later by --transform.
// This is used to unpack a specific file from the archive.
// This defines the chmod permissions for score and bones files.
// If we're on a multiuser system, file locking of shared files is
// very important (else things will just keep getting corrupted)
// Define this if you'd rather have the game block on locked files,
// commenting it will poll the file lock once a second for thirty
// seconds before giving up.
// some files needed for file locking
/* MULTIUSER */
// Uncomment these if you can't find these functions on your system
// #define NEED_USLEEP
// #define NEED_SNPRINTF
// Must include libutil.h here if one of the above is defined.
template < class T >
inline void
// And now headers we want precompiled