00001 /* 00002 * File: AppHdr.h 00003 * Summary: Precompiled header used by Crawl. 00004 * Written by: Jesse Jones 00005 * 00006 * Abstract: CodeWarrior and MSVC both support precompiled headers which can 00007 * significantly speed up compiles. Unlike CodeWarrior MSVC imposes 00008 * some annoying restrictions on precompiled headers: the precompiled 00009 * header *must* be the first include in all cc files. Any includes or 00010 * other statements that occur before the pch include are ignored. This 00011 * is really stupid and can lead to bizarre errors, but it does mean 00012 * that we shouldn't run into any problems on systems without precompiled 00013 * headers. 00014 * 00015 * Copyright © 1999 Jesse Jones. 00016 */ 00017 00018 00019 #ifndef APPHDR_H 00020 #define APPHDR_H 00021 00022 #include "platform.h" 00023 00024 #ifdef TARGET_COMPILER_VC 00025 /* Disable warning about: 00026 4290: the way VC handles the throw() specifier 00027 4267: "possible loss of data" when switching data types without a cast 00028 */ 00029 #pragma warning (disable: 4290 4267) 00030 /* Don't define min and max as macros, define them via STL */ 00031 #define NOMINMAX 00032 #endif 00033 00034 // The maximum memory that the user-script Lua interpreter can 00035 // allocate, in kilobytes. This limit is enforced to prevent 00036 // badly-written or malicious user scripts from consuming too much 00037 // memory. 00038 // 00039 #define CLUA_MAX_MEMORY_USE (2 * 1024) 00040 00041 // Enable support for Unicode character glyphs. Note that this needs 00042 // to be accompanied by changes to linker and compiler options and may 00043 // not be available on all platforms. In most cases you want to set 00044 // this option from your makefile, not directly in AppHdr.h (See 00045 // INSTALL for more details.) 00046 // 00047 // #define UNICODE_GLYPHS 00048 00049 // Uncomment to prevent Crawl from looking for a list of saves when 00050 // asking the player to enter a name. This can speed up startup 00051 // considerably if you have a lot of saves lying around. 00052 // 00053 // #define DISABLE_SAVEGAME_LISTS 00054 00055 // Uncomment to prevent Crawl from remembering startup preferences. 00056 // 00057 // #define DISABLE_STICKY_STARTUP_OPTIONS 00058 00059 // Uncomment to let valgrind debug unitialized uses of global classes 00060 // (you, env, clua, dlua, crawl_state). 00061 // 00062 // #define DEBUG_GLOBALS 00063 00064 // 00065 // Define 'UNIX' if the target OS is UNIX-like. 00066 // Unknown OSes are assumed to be here. 00067 // 00068 #if defined(TARGET_OS_MACOSX) || defined(TARGET_OS_LINUX) || \ 00069 defined(TARGET_OS_FREEBSD) || defined(TARGET_OS_NETBSD) || \ 00070 defined(TARGET_OS_OPENBSD) || defined(TARGET_COMPILER_CYGWIN) || \ 00071 defined(TARGET_OS_SOLARIS) || defined(TARGET_OS_UNKNOWN) 00072 #ifndef UNIX 00073 #define UNIX 00074 #endif 00075 #endif 00076 00077 // 00078 // OS X's Terminal.app has color handling problems; dark grey is 00079 // especially bad, so we'll want to remap that. OS X is otherwise 00080 // Unix-ish, so we shouldn't need other special handling. 00081 // 00082 #define COL_TO_REPLACE_DARKGREY BLUE 00083 00084 // 00085 // MinGW 00086 // 00087 #if defined(TARGET_COMPILER_MINGW) 00088 #ifndef REGEX_PCRE 00089 #define REGEX_PCRE 00090 #endif 00091 #endif 00092 00093 // Use this to seed the PRNG with a bit more than just time()... which 00094 // leads to problems if for any reason we get started twice in the same 00095 // second. 00096 #define USE_MORE_SECURE_SEED 00097 00098 // ========================================================================= 00099 // System Defines 00100 // ========================================================================= 00101 // Define plain_term for Unix and dos_term for DOS. 00102 00103 #ifdef UNIX 00104 // Uncomment if you're running Crawl with dgamelaunch and have 00105 // problems viewing games in progress. This affects how Crawl 00106 // clears the screen (see DGL_CLEAR_SCREEN) below. 00107 // 00108 // #define DGAMELAUNCH 00109 00110 #ifndef TARGET_COMPILER_MINGW 00111 #define USE_UNIX_SIGNALS 00112 #endif 00113 00114 // If this is defined, Crawl will attempt to save and exit when it 00115 // receives a hangup signal. 00116 #define SIGHUP_SAVE 00117 00118 #define FILE_SEPARATOR '/' 00119 00120 #define CHARACTER_SET 0 00121 #ifndef USE_TILE 00122 // NOTE: Tiles relies on the IBM character set for evaluating glyphs 00123 // of magic mapped dungeon cells. 00124 #define USE_ASCII_CHARACTERS 00125 #define USE_CURSES 00126 #endif 00127 00128 // More sophisticated character handling 00129 #define CURSES_USE_KEYPAD 00130 00131 // How long (milliseconds) curses should wait for additional characters 00132 // after seeing an Escape (0x1b) keypress. May not be available on all 00133 // curses implementations. 00134 #define CURSES_SET_ESCDELAY 20 00135 00136 // Have the utimes function to set access and modification time on 00137 // a file. 00138 #define HAVE_UTIMES 00139 00140 // Use POSIX regular expressions 00141 #ifndef REGEX_PCRE 00142 #define REGEX_POSIX 00143 #endif 00144 00145 // If you have libpcre, you can use that instead of POSIX regexes - 00146 // uncomment the line below and add -lpcre to your makefile. 00147 // #define REGEX_PCRE 00148 00149 // Uncomment (and edit as appropriate) to play sounds. 00150 // 00151 // WARNING: Enabling sounds may compromise security if Crawl is installed 00152 // setuid or setgid. Filenames passed to this command *are not 00153 // validated in any way*. 00154 // 00155 // #define SOUND_PLAY_COMMAND "/usr/bin/play -v .5 %s 2>/dev/null &" 00156 00157 // For cases when the game will be played on terms that don't support the 00158 // curses "bold == lighter" 16 colour mode. -- bwr 00159 // 00160 // Darkgrey is a particular problem in the 8 colour mode. Popular values 00161 // for replacing it around here are: WHITE, BLUE, and MAGENTA. This 00162 // option has no affect in 16 colour mode. -- bwr 00163 // 00164 // #define USE_8_COLOUR_TERM_MAP 00165 // #define COL_TO_REPLACE_DARKGREY MAGENTA 00166 00167 #include "libunix.h" 00168 00169 #elif defined(TARGET_OS_DOS) 00170 #define SHORT_FILE_NAMES 00171 #define CHARACTER_SET A_ALTCHARSET 00172 00173 #define FILE_SEPARATOR '\\' 00174 00175 #include <string> 00176 #include "libdos.h" 00177 00178 #include <dos.h> 00179 #include <file.h> 00180 00181 #define round(x) floor((x)+0.5) 00182 00183 // Use Perl-compatible regular expressions. libpcre must be available and 00184 // linked in. This is optional. 00185 #ifndef REGEX_PCRE 00186 #define REGEX_PCRE 00187 #endif 00188 00189 #elif defined(TARGET_OS_WINDOWS) 00190 #if !defined(USE_TILE) 00191 #include "libw32c.h" 00192 #endif 00193 #define CHARACTER_SET A_ALTCHARSET 00194 #define getstr(X,Y) get_console_string(X,Y) 00195 00196 // NT and better are happy with /; I'm not sure how 9x reacts. 00197 #define FILE_SEPARATOR '/' 00198 #define ALT_FILE_SEPARATOR '\\' 00199 00200 // Uncomment to play sounds. winmm must be linked in if this is uncommented. 00201 // #define WINMM_PLAY_SOUNDS 00202 00203 // Use Perl-compatible regular expressions. libpcre must be available and 00204 // linked in. This is optional. 00205 #ifndef REGEX_PCRE 00206 #define REGEX_PCRE 00207 #endif 00208 00209 #define NEED_USLEEP 00210 #else 00211 #error Missing platform #define or unsupported compiler. 00212 #endif 00213 00214 #if defined(__GNUC__) 00215 # define NORETURN __attribute__ ((noreturn)) 00216 #elif defined(_MSC_VER) 00217 # define NORETURN __declspec(noreturn) 00218 #else 00219 # define NORETURN 00220 #endif 00221 00222 // ========================================================================= 00223 // Defines for dgamelaunch-specific things. 00224 // ========================================================================= 00225 00226 #ifdef DGAMELAUNCH 00227 // DGL_CLEAR_SCREEN specifies the escape sequence to use to clear 00228 // the screen (used only when DGAMELAUNCH is defined). We make no 00229 // attempt to discover an appropriate escape sequence for the 00230 // term, assuming that dgamelaunch admins can adjust this as 00231 // needed. 00232 // 00233 // Why this is necessary: dgamelaunch's ttyplay initialises 00234 // playback by jumping to the last screen clear and playing back 00235 // from there. For that to work, ttyplay must be able to recognise 00236 // the clear screen sequence, and ncurses clear()+refresh() 00237 // doesn't do the trick. 00238 // 00239 #define DGL_CLEAR_SCREEN "\033[2J" 00240 00241 // Create .des and database cache files in a directory named with the 00242 // game version so that multiple save-compatible Crawl versions can 00243 // share the same savedir. 00244 #define DGL_VERSIONED_CACHE_DIR 00245 00246 // Update (text) database files safely; when a Crawl process 00247 // starts up and notices that a db file is out-of-date, it updates 00248 // it in-place, instead of torching the old file. 00249 #define DGL_REWRITE_PROTECT_DB_FILES 00250 00251 #ifndef USE_MORE_SECURE_SEED 00252 #error DGAMELAUNCH builds should define USE_MORE_SECURE_SEED 00253 #endif 00254 00255 // This secures the PRNG itself by hashing the values with SHA256. 00256 // It doesn't have much point if USE_MORE_SECURE_SEED is not used. 00257 // PRNG will be about 15 times slower when this is turned on, but 00258 // even with that the cpu time used by the PRNG is relatively small. 00259 #define MORE_HARDENED_PRNG 00260 00261 // Startup preferences are saved by player name rather than uid, 00262 // since all players use the same uid in dgamelaunch. 00263 #ifndef DGL_NO_STARTUP_PREFS_BY_NAME 00264 #define DGL_STARTUP_PREFS_BY_NAME 00265 #endif 00266 00267 // Increase the size of the topscores file for public servers. 00268 #ifndef SCORE_FILE_ENTRIES 00269 #define SCORE_FILE_ENTRIES 1000 00270 #endif 00271 00272 // If defined, the hiscores code dumps preformatted verbose and terse 00273 // death message strings in the logfile for the convenience of logfile 00274 // parsers. 00275 #define DGL_EXTENDED_LOGFILES 00276 00277 // Basic messaging for dgamelaunch, based on SIMPLE_MAIL for 00278 // NetHack and Slash'EM. I'm calling this "messaging" because that's 00279 // closer to reality. 00280 #define DGL_SIMPLE_MESSAGING 00281 00282 // How often we check for messages. This is not once per turn, but once 00283 // per player-input. Message checks are not performed if the keyboard 00284 // buffer is full, so messages should not interrupt macros. 00285 #define DGL_MESSAGE_CHECK_INTERVAL 1 00286 00287 // Record game milestones in an xlogfile. 00288 #define DGL_MILESTONES 00289 00290 // Save a timestamp every 100 turns so that external tools can seek in 00291 // game recordings more easily. 00292 #define DGL_TURN_TIMESTAMPS 00293 00294 // Record where players are currently. 00295 #define DGL_WHEREIS 00296 00297 // Uses <playername>-macro.txt as the macro file if uncommented. 00298 // #define DGL_NAMED_MACRO_FILE 00299 00300 // Uses Options.macro_dir as the full path to the macro file. Mutually 00301 // exclusive with DGL_NAMED_MACRO_FILE. 00302 #define DGL_MACRO_ABSOLUTE_PATH 00303 00304 // Makes the game ask the user to hit Enter after bailing out with 00305 // an error message. 00306 #define DGL_PAUSE_AFTER_ERROR 00307 00308 // Enable core dumps. Note that this will not create core dumps if 00309 // Crawl is installed setuid or setgid, but dgamelaunch installs should 00310 // not be installing Crawl set[ug]id anyway. 00311 #define DGL_ENABLE_CORE_DUMP 00312 00313 // Use UTC for dgamelaunch servers. 00314 #define TIME_FN gmtime 00315 #endif 00316 00317 #ifndef TIME_FN 00318 #define TIME_FN localtime 00319 #endif 00320 00321 #if defined(REGEX_POSIX) && defined(REGEX_PCRE) 00322 #error You can use either REGEX_POSIX or REGEX_PCRE, or neither, but not both. 00323 #endif 00324 00325 // ========================================================================= 00326 // Debugging Defines 00327 // ========================================================================= 00328 #ifdef FULLDEBUG 00329 // Bounds checking and asserts 00330 #ifndef DEBUG 00331 #define DEBUG 00332 #endif 00333 00334 // Outputs many "hidden" details, defaults to wizard on. 00335 #define DEBUG_DIAGNOSTICS 00336 00337 // Scan for bad items before every input (may be slow) 00338 // 00339 // This function might slow things down quite a bit 00340 // on slow machines because it's going to go through 00341 // every item on the level and do string comparisons 00342 // against the name. Still, it is nice to know the 00343 // turn in which "bad" items appear. 00344 #define DEBUG_ITEM_SCAN 00345 #define DEBUG_MONS_SCAN 00346 #endif 00347 00348 #ifdef _DEBUG // this is how MSVC signals a debug build 00349 #ifndef DEBUG 00350 #define DEBUG 00351 #endif 00352 #endif 00353 00354 #ifdef DEBUG 00355 #ifdef __MWERKS__ 00356 #define MSIPL_DEBUG_MODE 00357 #endif 00358 #else 00359 #if !defined(NDEBUG) 00360 #define NDEBUG // used by <assert.h> 00361 #endif 00362 #endif 00363 00364 00365 #ifdef USE_TILE 00366 #ifdef __cplusplus 00367 #include "libgui.h" 00368 #include "tilesdl.h" 00369 #endif 00370 #endif 00371 00372 // ========================================================================= 00373 // Lua user scripts (NOTE: this may also be enabled in your makefile!) 00374 // ========================================================================= 00375 // 00376 // Enables Crawl's Lua bindings for user scripts. See the section on 00377 // Lua in INSTALL for more information. NOTE: CLUA_BINDINGS is enabled 00378 // by default in all standard makefiles. Commenting it out here may 00379 // not be sufficient to disable user-Lua - you must also check your 00380 // makefile and remove -DCLUA_BINDINGS. You can use V in-game to check 00381 // whether user-scripts are enabled. 00382 // 00383 // #define CLUA_BINDINGS 00384 00385 // ========================================================================= 00386 // Game Play Defines 00387 // ========================================================================= 00388 // number of older messages stored during play and in save files 00389 #define NUM_STORED_MESSAGES 1000 00390 00391 // clamp time between command inputs at 30 seconds when reporting play time. 00392 // Anything longer means you do something other than playing -- heck, even 30s 00393 // is too long as when thinking in a tight spot people re-read the inventory, 00394 // check monsters, etc. 00395 #define IDLE_TIME_CLAMP 30 00396 00397 // Number of top scores to keep. See above for the dgamelaunch setting. 00398 #ifndef SCORE_FILE_ENTRIES 00399 #define SCORE_FILE_ENTRIES 100 00400 #endif 00401 00402 // Option to allow scoring of wizard characters. Note that even if 00403 // you define this option, wizard characters are still tagged as such 00404 // in the score file. 00405 // #define SCORE_WIZARD_CHARACTERS 00406 00407 #define SAVE_SUFFIX ".cs" 00408 00409 // If you are installing Crawl for multiple users, define SAVE_DIR 00410 // to the directory where saves, bones, and score file will go... 00411 // end it with a '/'. Only one system user should be able to access 00412 // these -- usually this means you should place them in ~/crawl/ 00413 // unless it's a DGL build. 00414 00415 // If we're on a multiuser system, file locking of shared files is 00416 // very important (else things will just keep getting corrupted) 00417 #define USE_FILE_LOCKING 00418 00419 #if defined(DGL_SIMPLE_MESSAGING) && !defined(USE_FILE_LOCKING) 00420 #error Must define USE_FILE_LOCKING for DGL_SIMPLE_MESSAGING 00421 #endif 00422 00423 #if !defined(DB_NDBM) && !defined(DB_DBH) && !defined(USE_SQLITE_DBM) 00424 #define USE_SQLITE_DBM 00425 #endif 00426 00427 // Uncomment these if you can't find these functions on your system 00428 // #define NEED_USLEEP 00429 00430 #ifndef PROPORTIONAL_FONT 00431 #define PROPORTIONAL_FONT "Vera.ttf" 00432 #endif 00433 #ifndef MONOSPACED_FONT 00434 #define MONOSPACED_FONT "VeraMono.ttf" 00435 #endif 00436 00437 #ifdef __cplusplus 00438 00439 00440 template < class T > 00441 inline void UNUSED(const volatile T &) 00442 { 00443 } 00444 00445 // And now headers we want precompiled 00446 #ifdef TARGET_COMPILER_VC 00447 #include "msvc.h" 00448 #endif 00449 00450 #include "externs.h" 00451 #include "unwind.h" 00452 #include "version.h" 00453 00454 #ifdef TARGET_COMPILER_VC 00455 #include "libw32c.h" 00456 #endif 00457 00458 #endif // __cplusplus 00459 00460 #endif // APPHDR_H