global.h

Go to the documentation of this file.
00001 /*      SCCS Id: @(#)global.h   3.4     2003/08/31      */
00002 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
00003 /* NetHack may be freely redistributed.  See license for details. */
00004 
00005 #ifndef GLOBAL_H
00006 #define GLOBAL_H
00007 
00008 #include <stdio.h>
00009 
00010 
00011 /* #define BETA */      /* if a beta-test copy  [MRS] */
00012 
00013 /*
00014  * Files expected to exist in the playground directory.
00015  */
00016 
00017 #define RECORD        "record"  /* file containing list of topscorers */
00018 #define HELP          "help"    /* file containing command descriptions */
00019 #define SHELP         "hh"      /* abbreviated form of the same */
00020 #define DEBUGHELP     "wizhelp" /* file containing debug mode cmds */
00021 #define RUMORFILE     "rumors"  /* file with fortune cookies */
00022 #define ORACLEFILE    "oracles" /* file with oracular information */
00023 #define DATAFILE      "data"    /* file giving the meaning of symbols used */
00024 #define CMDHELPFILE   "cmdhelp" /* file telling what commands do */
00025 #define HISTORY       "history" /* file giving nethack's history */
00026 #define LICENSE       "license" /* file with license information */
00027 #define OPTIONFILE    "opthelp" /* file explaining runtime options */
00028 #define OPTIONS_USED  "options" /* compile-time options, for #version */
00029 
00030 #define LEV_EXT ".lev"          /* extension for special level files */
00031 
00032 
00033 /* Assorted definitions that may depend on selections in config.h. */
00034 
00035 /*
00036  * for DUMB preprocessor and compiler, e.g., cpp and pcc supplied
00037  * with Microport SysV/AT, which have small symbol tables;
00038  * DUMB if needed is defined in CFLAGS
00039  */
00040 #ifdef DUMB
00041 #ifdef BITFIELDS
00042 #undef BITFIELDS
00043 #endif
00044 #ifndef STUPID
00045 #define STUPID
00046 #endif
00047 #endif  /* DUMB */
00048 
00049 /*
00050  * type xchar: small integers in the range 0 - 127, usually coordinates
00051  * although they are nonnegative they must not be declared unsigned
00052  * since otherwise comparisons with signed quantities are done incorrectly
00053  */
00054 typedef schar   xchar;
00055 #ifndef SKIP_BOOLEAN
00056 typedef xchar   boolean;                /* 0 or 1 */
00057 #endif
00058 
00059 #ifndef TRUE            /* defined in some systems' native include files */
00060 #define TRUE    ((boolean)1)
00061 #define FALSE   ((boolean)0)
00062 #endif
00063 
00064 #ifndef STRNCMPI
00065 # ifndef __SASC_60              /* SAS/C already shifts to stricmp */
00066 #  define strcmpi(a,b) strncmpi((a),(b),-1)
00067 # endif
00068 #endif
00069 
00070 /* comment out to test effects of each #define -- these will probably
00071  * disappear eventually
00072  */
00073 #ifdef INTERNAL_COMP
00074 # define RLECOMP        /* run-length compression of levl array - JLee */
00075 # define ZEROCOMP       /* zero-run compression of everything - Olaf Seibert */
00076 #endif
00077 
00078 /* #define SPECIALIZATION */    /* do "specialized" version of new topology */
00079 
00080 
00081 #ifdef BITFIELDS
00082 #define Bitfield(x,n)   unsigned x:n
00083 #else
00084 #define Bitfield(x,n)   uchar x
00085 #endif
00086 
00087 #ifdef UNWIDENED_PROTOTYPES
00088 # define CHAR_P char
00089 # define SCHAR_P schar
00090 # define UCHAR_P uchar
00091 # define XCHAR_P xchar
00092 # define SHORT_P short
00093 #ifndef SKIP_BOOLEAN
00094 # define BOOLEAN_P boolean
00095 #endif
00096 # define ALIGNTYP_P aligntyp
00097 #else
00098 # ifdef WIDENED_PROTOTYPES
00099 #  define CHAR_P int
00100 #  define SCHAR_P int
00101 #  define UCHAR_P int
00102 #  define XCHAR_P int
00103 #  define SHORT_P int
00104 #  define BOOLEAN_P int
00105 #  define ALIGNTYP_P int
00106 # endif
00107 #endif
00108 #if defined(ULTRIX_PROTO) && !defined(__STDC__)
00109 /* The ultrix 2.0 and 2.1 compilers (on Ultrix 4.0 and 4.2 respectively) can't
00110  * handle "struct obj *" constructs in prototypes.  Their bugs are different,
00111  * but both seem to work if we put "void*" in the prototype instead.  This
00112  * gives us minimal prototype checking but avoids the compiler bugs.
00113  *
00114  * OBJ_P and MONST_P should _only_ be used for declaring function pointers.
00115  */
00116 #define OBJ_P void*
00117 #define MONST_P void*
00118 #else
00119 #define OBJ_P struct obj*
00120 #define MONST_P struct monst*
00121 #endif
00122 
00123 #define SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
00124 
00125 
00126 /* A limit for some NetHack int variables.  It need not, and for comparable
00127  * scoring should not, depend on the actual limit on integers for a
00128  * particular machine, although it is set to the minimum required maximum
00129  * signed integer for C (2^15 -1).
00130  */
00131 #define LARGEST_INT     32767
00132 
00133 
00134 #ifdef REDO
00135 #define Getchar pgetchar
00136 #endif
00137 
00138 
00139 #include "coord.h"
00140 /*
00141  * Automatic inclusions for the subsidiary files.
00142  * Please don't change the order.  It does matter.
00143  */
00144 
00145 #ifdef VMS
00146 #include "vmsconf.h"
00147 #endif
00148 
00149 #ifdef UNIX
00150 #include "unixconf.h"
00151 #endif
00152 
00153 #ifdef OS2
00154 #include "os2conf.h"
00155 #endif
00156 
00157 #ifdef MSDOS
00158 #include "pcconf.h"
00159 #endif
00160 
00161 #ifdef TOS
00162 #include "tosconf.h"
00163 #endif
00164 
00165 #ifdef AMIGA
00166 #include "amiconf.h"
00167 #endif
00168 
00169 #ifdef MAC
00170 #include "macconf.h"
00171 #endif
00172 
00173 #ifdef __BEOS__
00174 #include "beconf.h"
00175 #endif
00176 
00177 #ifdef WIN32
00178 #ifdef WIN_CE
00179 #include "wceconf.h"
00180 #else
00181 #include "ntconf.h"
00182 #endif
00183 #endif
00184 
00185 /* Displayable name of this port; don't redefine if defined in *conf.h */
00186 #ifndef PORT_ID
00187 # ifdef AMIGA
00188 #  define PORT_ID       "Amiga"
00189 # endif
00190 # ifdef MAC
00191 #  define PORT_ID       "Mac"
00192 # endif
00193 # ifdef MSDOS
00194 #  ifdef PC9800
00195 #  define PORT_ID       "PC-9800"
00196 #  else
00197 #  define PORT_ID       "PC"
00198 #  endif
00199 #  ifdef DJGPP
00200 #  define PORT_SUB_ID   "djgpp"
00201 #  else
00202 #   ifdef OVERLAY
00203 #  define PORT_SUB_ID   "overlaid"
00204 #   else
00205 #  define PORT_SUB_ID   "non-overlaid"
00206 #   endif
00207 #  endif
00208 # endif
00209 # ifdef OS2
00210 #  define PORT_ID       "OS/2"
00211 # endif
00212 # ifdef TOS
00213 #  define PORT_ID       "ST"
00214 # endif
00215 # ifdef UNIX
00216 #  define PORT_ID       "Unix"
00217 # endif
00218 # ifdef VMS
00219 #  define PORT_ID       "VMS"
00220 # endif
00221 # ifdef WIN32
00222 #  define PORT_ID       "Windows"
00223 #  ifndef PORT_SUB_ID
00224 #   ifdef MSWIN_GRAPHICS
00225 #    define PORT_SUB_ID "graphical"
00226 #   else
00227 #    define PORT_SUB_ID "tty"
00228 #   endif
00229 #  endif
00230 # endif
00231 #endif
00232 
00233 #if defined(MICRO)
00234 #if !defined(AMIGA) && !defined(TOS) && !defined(OS2_HPFS)
00235 #define SHORT_FILENAMES         /* filenames are 8.3 */
00236 #endif
00237 #endif
00238 
00239 #ifdef VMS
00240 /* vms_exit() (sys/vms/vmsmisc.c) expects the non-VMS EXIT_xxx values below.
00241  * these definitions allow all systems to be treated uniformly, provided
00242  * main() routines do not terminate with return(), whose value is not
00243  * so massaged.
00244  */
00245 # ifdef EXIT_SUCCESS
00246 #  undef EXIT_SUCCESS
00247 # endif
00248 # ifdef EXIT_FAILURE
00249 #  undef EXIT_FAILURE
00250 # endif
00251 #endif
00252 
00253 #ifndef EXIT_SUCCESS
00254 # define EXIT_SUCCESS 0
00255 #endif
00256 #ifndef EXIT_FAILURE
00257 # define EXIT_FAILURE 1
00258 #endif
00259 
00260 #if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) || defined(MSWIN_GRAPHICS)
00261 # ifndef USE_TILES
00262 #  define USE_TILES             /* glyph2tile[] will be available */
00263 # endif
00264 #endif
00265 #if defined(AMII_GRAPHICS) || defined(GEM_GRAPHICS)
00266 # ifndef USE_TILES
00267 #  define USE_TILES
00268 # endif
00269 #endif
00270 
00271 
00272 #define Sprintf  (void) sprintf
00273 #define Strcat   (void) strcat
00274 #define Strcpy   (void) strcpy
00275 #ifdef NEED_VARARGS
00276 #define Vprintf  (void) vprintf
00277 #define Vfprintf (void) vfprintf
00278 #define Vsprintf (void) vsprintf
00279 #endif
00280 
00281 
00282 /* primitive memory leak debugging; see alloc.c */
00283 #ifdef MONITOR_HEAP
00284 extern long *FDECL(nhalloc, (unsigned int,const char *,int));
00285 extern void FDECL(nhfree, (genericptr_t,const char *,int));
00286 # ifndef __FILE__
00287 #  define __FILE__ ""
00288 # endif
00289 # ifndef __LINE__
00290 #  define __LINE__ 0
00291 # endif
00292 # define alloc(a) nhalloc(a,__FILE__,(int)__LINE__)
00293 # define free(a) nhfree(a,__FILE__,(int)__LINE__)
00294 #else   /* !MONITOR_HEAP */
00295 extern long *FDECL(alloc, (unsigned int));              /* alloc.c */
00296 #endif
00297 
00298 /* Used for consistency checks of various data files; declare it here so
00299    that utility programs which include config.h but not hack.h can see it. */
00300 struct version_info {
00301         unsigned long   incarnation;    /* actual version number */
00302         unsigned long   feature_set;    /* bitmask of config settings */
00303         unsigned long   entity_count;   /* # of monsters and objects */
00304         unsigned long   struct_sizes;   /* size of key structs */
00305 };
00306 
00307 
00308 /*
00309  * Configurable internal parameters.
00310  *
00311  * Please be very careful if you are going to change one of these.  Any
00312  * changes in these parameters, unless properly done, can render the
00313  * executable inoperative.
00314  */
00315 
00316 /* size of terminal screen is (at least) (ROWNO+3) by COLNO */
00317 #define COLNO   80
00318 #define ROWNO   21
00319 
00320 /* MAXCO must hold longest uncompressed status line, and must be larger
00321  * than COLNO
00322  *
00323  * longest practical second status line at the moment is
00324  *      Astral Plane $:12345 HP:700(700) Pw:111(111) AC:-127 Xp:30/123456789
00325  *      T:123456 Satiated Conf FoodPois Ill Blind Stun Hallu Overloaded
00326  * -- or somewhat over 130 characters
00327  */
00328 #if COLNO <= 140
00329 #define MAXCO 160
00330 #else
00331 #define MAXCO (COLNO+20)
00332 #endif
00333 
00334 
00335 #define MAXNROFROOMS    40      /* max number of rooms per level */
00336 #define MAX_SUBROOMS    24      /* max # of subrooms in a given room */
00337 #define DOORMAX         120     /* max number of doors per level */
00338 
00339 #define BUFSZ           256     /* for getlin buffers */
00340 #define QBUFSZ          128     /* for building question text */
00341 #define TBUFSZ          300     /* toplines[] buffer max msg: 3 81char names */
00342                                 /* plus longest prefix plus a few extra words */
00343 
00344 #define PL_NSIZ         32      /* name of player, ghost, shopkeeper */
00345 #define PL_CSIZ         32      /* sizeof pl_character */
00346 #define PL_FSIZ         32      /* fruit name */
00347 #define PL_PSIZ         63      /* player-given names for pets, other
00348                                  * monsters, objects */
00349 
00350 #define MAXDUNGEON      16      /* current maximum number of dungeons */
00351 #define MAXLEVEL        32      /* max number of levels in one dungeon */
00352 #define MAXSTAIRS       1       /* max # of special stairways in a dungeon */
00353 #define ALIGNWEIGHT     4       /* generation weight of alignment */
00354 
00355 #define MAXULEV         30      /* max character experience level */
00356 
00357 #define MAXMONNO        120     /* extinct monst after this number created */
00358 #define MHPMAX          500     /* maximum monster hp */
00359 
00360 #endif /* GLOBAL_H */