1 /* SCCS Id: @(#)global.h 3.4 2003/08/31 */ 2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3 /* NetHack may be freely redistributed. See license for details. */ 4 5 #ifndef GLOBAL_H 6 #define GLOBAL_H 7 8 #include <stdio.h> 9 10 11 /* #define BETA */ /* if a beta-test copy [MRS] */ 12 13 /* 14 * Files expected to exist in the playground directory if file areas are not 15 * enabled and in the named areas otherwise. 16 */ 17 18 #define NH_RECORD "record" /* a file containing list of topscorers */ 19 #define NH_RECORD_AREA FILE_AREA_VAR 20 #define NH_HELP "help" /* a file containing command descriptions */ 21 #define NH_HELP_AREA FILE_AREA_SHARE 22 #define NH_SHELP "hh" /* abbreviated form of the same */ 23 #define NH_SHELP_AREA FILE_AREA_SHARE 24 #define NH_DEBUGHELP "wizhelp" /* a file containing debug mode cmds */ 25 #define NH_DEBUGHELP_AREA FILE_AREA_SHARE 26 #define NH_RUMORFILE "rumors" /* a file with fortune cookies */ 27 #define NH_RUMORAREA FILE_AREA_SHARE 28 #define NH_ORACLEFILE "oracles" /* a file with oracular information */ 29 #define NH_ORACLEAREA FILE_AREA_SHARE 30 #define NH_DATAFILE "data" /* a file giving the meaning of symbols used */ 31 #define NH_DATAAREA FILE_AREA_SHARE 32 #define NH_CMDHELPFILE "cmdhelp" /* file telling what commands do */ 33 #define NH_CMDHELPAREA FILE_AREA_SHARE 34 #define NH_HISTORY "history" /* a file giving nethack's history */ 35 #define NH_HISTORY_AREA FILE_AREA_SHARE 36 #define NH_LICENSE "license" /* file with license information */ 37 #define NH_LICENSE_AREA FILE_AREA_DOC 38 #define NH_OPTIONFILE "opthelp" /* a file explaining runtime options */ 39 #define NH_OPTIONAREA FILE_AREA_SHARE 40 #define NH_OPTIONS_USED "options" /* compile-time options, for #version */ 41 #define NH_OPTIONS_USED_AREA FILE_AREA_SHARE 42 #ifdef SHORT_FILENAMES 43 # define NH_GUIDEBOOK "guideboo.txt" /* Nethack Guidebook*/ 44 #else 45 #define NH_GUIDEBOOK "Guidebook.txt" /* Nethack Guidebook*/ 46 #endif 47 #define NH_GUIDEBOOK_AREA FILE_AREA_DOC 48 49 50 #define LEV_EXT ".lev" /* extension for special level files */ 51 #define RECORD "record" /* file containing list of topscorers */ 52 #define HELP "help" /* file containing command descriptions */ 53 #define SHELP "hh" /* abbreviated form of the same */ 54 #define DEBUGHELP "wizhelp" /* file containing debug mode cmds */ 55 #define RUMORFILE "rumors" /* file with fortune cookies */ 56 #define ORACLEFILE "oracles" /* file with oracular information */ 57 #define DATAFILE "data" /* file giving the meaning of symbols used */ 58 #define CMDHELPFILE "cmdhelp" /* file telling what commands do */ 59 #define HISTORY "history" /* file giving nethack's history */ 60 #define LICENSE "license" /* file with license information */ 61 #define OPTIONFILE "opthelp" /* file explaining runtime options */ 62 #define OPTIONS_USED "options" /* compile-time options, for #version */ 63 64 #define LEV_EXT ".lev" /* extension for special level files */ 65 66 67 /* Assorted definitions that may depend on selections in config.h. */ 68 69 /* 70 * for DUMB preprocessor and compiler, e.g., cpp and pcc supplied 71 * with Microport SysV/AT, which have small symbol tables; 72 * DUMB if needed is defined in CFLAGS 73 */ 74 #ifdef DUMB 75 #ifdef BITFIELDS 76 #undef BITFIELDS 77 #endif 78 #ifndef STUPID 79 #define STUPID 80 #endif 81 #endif /* DUMB */ 82 83 /* 84 * type xchar: small integers in the range 0 - 127, usually coordinates 85 * although they are nonnegative they must not be declared unsigned 86 * since otherwise comparisons with signed quantities are done incorrectly 87 */ 88 typedef schar xchar; 89 #ifndef SKIP_BOOLEAN 90 typedef xchar boolean; /* 0 or 1 */ 91 #endif 92 93 #ifndef TRUE /* defined in some systems' native include files */ 94 #define TRUE ((boolean)1) 95 #define FALSE ((boolean)0) 96 #endif 97 98 #ifndef STRNCMPI 99 # ifndef __SASC_60 /* SAS/C already shifts to stricmp */ 100 # define strcmpi(a,b) strncmpi((a),(b),-1) 101 # endif 102 #endif 103 104 /* comment out to test effects of each #define -- these will probably 105 * disappear eventually 106 */ 107 #ifdef INTERNAL_COMP 108 # define RLECOMP /* run-length compression of levl array - JLee */ 109 # define ZEROCOMP /* zero-run compression of everything - Olaf Seibert */ 110 #endif 111 112 /* #define SPECIALIZATION */ /* do "specialized" version of new topology */ 113 114 115 #ifdef BITFIELDS 116 #define Bitfield(x,n) unsigned x:n 117 #else 118 #define Bitfield(x,n) uchar x 119 #endif 120 121 #ifdef UNWIDENED_PROTOTYPES 122 # define CHAR_P char 123 # define SCHAR_P schar 124 # define UCHAR_P uchar 125 # define XCHAR_P xchar 126 # define SHORT_P short 127 #ifndef SKIP_BOOLEAN 128 # define BOOLEAN_P boolean 129 #endif 130 # define ALIGNTYP_P aligntyp 131 #else 132 # ifdef WIDENED_PROTOTYPES 133 # define CHAR_P int 134 # define SCHAR_P int 135 # define UCHAR_P int 136 # define XCHAR_P int 137 # define SHORT_P int 138 # define BOOLEAN_P int 139 # define ALIGNTYP_P int 140 # endif 141 #endif 142 #if defined(ULTRIX_PROTO) && !defined(__STDC__) 143 /* The ultrix 2.0 and 2.1 compilers (on Ultrix 4.0 and 4.2 respectively) can't 144 * handle "struct obj *" constructs in prototypes. Their bugs are different, 145 * but both seem to work if we put "void*" in the prototype instead. This 146 * gives us minimal prototype checking but avoids the compiler bugs. 147 * 148 * OBJ_P and MONST_P should _only_ be used for declaring function pointers. 149 */ 150 #define OBJ_P void* 151 #define MONST_P void* 152 #else 153 #define OBJ_P struct obj* 154 #define MONST_P struct monst* 155 #endif 156 157 #define SIZE(x) (int)(sizeof(x) / sizeof(x[0])) 158 159 160 /* A limit for some NetHack int variables. It need not, and for comparable 161 * scoring should not, depend on the actual limit on integers for a 162 * particular machine, although it is set to the minimum required maximum 163 * signed integer for C (2^15 -1). 164 */ 165 #define LARGEST_INT 32767 166 167 168 #ifdef REDO 169 #define Getchar pgetchar 170 #endif 171 172 173 #include "coord.h" 174 /* 175 * Automatic inclusions for the subsidiary files. 176 * Please don't change the order. It does matter. 177 */ 178 179 #ifdef VMS 180 #include "vmsconf.h" 181 #endif 182 183 #ifdef UNIX 184 #include "unixconf.h" 185 #endif 186 187 #ifdef OS2 188 #include "os2conf.h" 189 #endif 190 191 #ifdef MSDOS 192 #include "pcconf.h" 193 #endif 194 195 #ifdef TOS 196 #include "tosconf.h" 197 #endif 198 199 #ifdef AMIGA 200 #include "amiconf.h" 201 #endif 202 203 #ifdef MAC 204 #include "macconf.h" 205 #endif 206 207 #ifdef __BEOS__ 208 #include "beconf.h" 209 #endif 210 211 #ifdef WIN32 212 #ifdef WIN_CE 213 #include "wceconf.h" 214 #else 215 #include "ntconf.h" 216 #endif 217 #endif 218 219 #ifndef FILE_AREAS 220 221 #define fopen_datafile_area(area, filename, mode, use_spfx) \ 222 fopen_datafile(filename, mode, use_spfx) 223 #define lock_file_area(area, filename, prefix, retryct) \ 224 lock_file(filename, prefix, retryct) 225 #define unlock_file_area(area, filename) unlock_file(filename) 226 #define dlb_fopen_area(area, name, mode) dlb_fopen(name, mode) 227 228 /* 229 * ALI 230 * 231 * By defining these, functions can pass them around even though they're 232 * not actually used. This can make the code easier to read at the cost 233 * of some efficiency. Given the high overhead of dealing with files anyway, 234 * this is often a good trade-off. 235 */ 236 237 #define FILE_AREA_VAR NULL 238 #define FILE_AREA_SAVE NULL 239 #define FILE_AREA_LEVL NULL 240 #define FILE_AREA_BONES NULL 241 #define FILE_AREA_SHARE NULL 242 #define FILE_AREA_UNSHARE NULL 243 244 #endif 245 246 /* Displayable name of this port; don't redefine if defined in *conf.h */ 247 #ifndef PORT_ID 248 # ifdef AMIGA 249 # define PORT_ID "Amiga" 250 # endif 251 # ifdef MAC 252 # define PORT_ID "Mac" 253 # endif 254 # ifdef MSDOS 255 # ifdef PC9800 256 # define PORT_ID "PC-9800" 257 # else 258 # define PORT_ID "PC" 259 # endif 260 # ifdef DJGPP 261 # define PORT_SUB_ID "djgpp" 262 # else 263 # ifdef OVERLAY 264 # define PORT_SUB_ID "overlaid" 265 # else 266 # define PORT_SUB_ID "non-overlaid" 267 # endif 268 # endif 269 # endif 270 # ifdef OS2 271 # define PORT_ID "OS/2" 272 # endif 273 # ifdef TOS 274 # define PORT_ID "ST" 275 # endif 276 # ifdef UNIX 277 # define PORT_ID "Unix" 278 # endif 279 # ifdef VMS 280 # define PORT_ID "VMS" 281 # endif 282 # ifdef WIN32 283 # define PORT_ID "Windows" 284 # ifndef PORT_SUB_ID 285 # ifdef MSWIN_GRAPHICS 286 # define PORT_SUB_ID "graphical" 287 # else 288 # define PORT_SUB_ID "tty" 289 # endif 290 # endif 291 # endif 292 #endif 293 294 #if defined(MICRO) 295 #if !defined(AMIGA) && !defined(TOS) && !defined(OS2_HPFS) 296 #define SHORT_FILENAMES /* filenames are 8.3 */ 297 #endif 298 #endif 299 300 #ifdef VMS 301 /* vms_exit() (sys/vms/vmsmisc.c) expects the non-VMS EXIT_xxx values below. 302 * these definitions allow all systems to be treated uniformly, provided 303 * main() routines do not terminate with return(), whose value is not 304 * so massaged. 305 */ 306 # ifdef EXIT_SUCCESS 307 # undef EXIT_SUCCESS 308 # endif 309 # ifdef EXIT_FAILURE 310 # undef EXIT_FAILURE 311 # endif 312 #endif 313 314 #ifndef EXIT_SUCCESS 315 # define EXIT_SUCCESS 0 316 #endif 317 #ifndef EXIT_FAILURE 318 # define EXIT_FAILURE 1 319 #endif 320 321 #if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) || defined(MSWIN_GRAPHICS) 322 # ifndef USE_TILES 323 # define USE_TILES /* glyph2tile[] will be available */ 324 # endif 325 #endif 326 #if defined(AMII_GRAPHICS) || defined(GEM_GRAPHICS) 327 # ifndef USE_TILES 328 # define USE_TILES 329 # endif 330 #endif 331 332 333 #define Sprintf (void) sprintf 334 #define Strcat (void) strcat 335 #define Strcpy (void) strcpy 336 #ifdef NEED_VARARGS 337 #define Vprintf (void) vprintf 338 #define Vfprintf (void) vfprintf 339 #define Vsprintf (void) vsprintf 340 #endif 341 342 343 /* primitive memory leak debugging; see alloc.c */ 344 #ifdef MONITOR_HEAP 345 extern long *FDECL(nhalloc, (unsigned int,const char *,int)); 346 extern void FDECL(nhfree, (genericptr_t,const char *,int)); 347 # ifndef __FILE__ 348 # define __FILE__ "" 349 # endif 350 # ifndef __LINE__ 351 # define __LINE__ 0 352 # endif 353 # define alloc(a) nhalloc(a,__FILE__,(int)__LINE__) 354 # define free(a) nhfree(a,__FILE__,(int)__LINE__) 355 #else /* !MONITOR_HEAP */ 356 extern long *FDECL(alloc, (unsigned int)); /* alloc.c */ 357 #endif 358 359 /* Used for consistency checks of various data files; declare it here so 360 that utility programs which include config.h but not hack.h can see it. */ 361 struct version_info { 362 unsigned long incarnation; /* actual version number */ 363 unsigned long feature_set; /* bitmask of config settings */ 364 unsigned long entity_count; /* # of monsters and objects */ 365 unsigned long struct_sizes; /* size of key structs */ 366 }; 367 368 369 /* 370 * Configurable internal parameters. 371 * 372 * Please be very careful if you are going to change one of these. Any 373 * changes in these parameters, unless properly done, can render the 374 * executable inoperative. 375 */ 376 377 /* size of terminal screen is (at least) (ROWNO+3) by COLNO */ 378 #define COLNO 80 379 #define ROWNO 21 380 381 /* MAXCO must hold longest uncompressed status line, and must be larger 382 * than COLNO 383 * 384 * longest practical second status line at the moment is 385 * Astral Plane $:12345 HP:700(700) Pw:111(111) AC:-127 Xp:30/123456789 386 * T:123456 Satiated Conf FoodPois Ill Blind Stun Hallu Overloaded 387 * -- or somewhat over 130 characters 388 */ 389 #if COLNO <= 140 390 #define MAXCO 160 391 #else 392 #define MAXCO (COLNO+20) 393 #endif 394 395 396 #define MAXNROFROOMS 40 /* max number of rooms per level */ 397 #define MAX_SUBROOMS 24 /* max # of subrooms in a given room */ 398 #define DOORMAX 120 /* max number of doors per level */ 399 400 #define BUFSZ 256 /* for getlin buffers */ 401 #define QBUFSZ 128 /* for building question text */ 402 #define TBUFSZ 300 /* toplines[] buffer max msg: 3 81char names */ 403 /* plus longest prefix plus a few extra words */ 404 405 #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */ 406 #define PL_CSIZ 32 /* sizeof pl_character */ 407 #define PL_FSIZ 32 /* fruit name */ 408 #define PL_PSIZ 63 /* player-given names for pets, other 409 * monsters, objects */ 410 411 #define MAXDUNGEON 16 /* current maximum number of dungeons */ 412 #define MAXLEVEL 32 /* max number of levels in one dungeon */ 413 #define MAXSTAIRS 1 /* max # of special stairways in a dungeon */ 414 #define ALIGNWEIGHT 4 /* generation weight of alignment */ 415 416 #define MAXULEV 30 /* max character experience level */ 417 418 #define MAXMONNO 120 /* extinct monst after this number created */ 419 #define MHPMAX 500 /* maximum monster hp */ 420 421 #endif /* GLOBAL_H */ 422