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.
15 */
16
17#define RECORD	      "record"	/* file containing list of topscorers */
18#define HELP	      "help"	/* file containing command descriptions */
19#define SHELP	      "hh"	/* abbreviated form of the same */
20#define DEBUGHELP     "wizhelp" /* file containing debug mode cmds */
21#define RUMORFILE     "rumors"	/* file with fortune cookies */
22#define ORACLEFILE    "oracles" /* file with oracular information */
23#define DATAFILE      "data"	/* file giving the meaning of symbols used */
24#define CMDHELPFILE   "cmdhelp" /* file telling what commands do */
25#define HISTORY       "history" /* file giving nethack's history */
26#define LICENSE       "license" /* file with license information */
27#define OPTIONFILE    "opthelp" /* file explaining runtime options */
28#define OPTIONS_USED  "options" /* compile-time options, for #version */
29
30#define LEV_EXT ".lev"		/* extension for special level files */
31
32
33/* Assorted definitions that may depend on selections in config.h. */
34
35/*
36 * for DUMB preprocessor and compiler, e.g., cpp and pcc supplied
37 * with Microport SysV/AT, which have small symbol tables;
38 * DUMB if needed is defined in CFLAGS
39 */
40#ifdef DUMB
41#ifdef BITFIELDS
42#undef BITFIELDS
43#endif
44#ifndef STUPID
45#define STUPID
46#endif
47#endif	/* DUMB */
48
49/*
50 * type xchar: small integers in the range 0 - 127, usually coordinates
51 * although they are nonnegative they must not be declared unsigned
52 * since otherwise comparisons with signed quantities are done incorrectly
53 */
54typedef schar	xchar;
55#ifndef SKIP_BOOLEAN
56typedef xchar	boolean;		/* 0 or 1 */
57#endif
58
59#ifndef TRUE		/* defined in some systems' native include files */
60#define TRUE	((boolean)1)
61#define FALSE	((boolean)0)
62#endif
63
64#ifndef STRNCMPI
65# ifndef __SASC_60		/* SAS/C already shifts to stricmp */
66#  define strcmpi(a,b) strncmpi((a),(b),-1)
67# endif
68#endif
69
70/* comment out to test effects of each #define -- these will probably
71 * disappear eventually
72 */
73#ifdef INTERNAL_COMP
74# define RLECOMP	/* run-length compression of levl array - JLee */
75# define ZEROCOMP	/* zero-run compression of everything - Olaf Seibert */
76#endif
77
78/* #define SPECIALIZATION */	/* do "specialized" version of new topology */
79
80
81#ifdef BITFIELDS
82#define Bitfield(x,n)	unsigned x:n
83#else
84#define Bitfield(x,n)	uchar x
85#endif
86
87#ifdef UNWIDENED_PROTOTYPES
88# define CHAR_P char
89# define SCHAR_P schar
90# define UCHAR_P uchar
91# define XCHAR_P xchar
92# define SHORT_P short
93#ifndef SKIP_BOOLEAN
94# define BOOLEAN_P boolean
95#endif
96# define ALIGNTYP_P aligntyp
97#else
98# ifdef WIDENED_PROTOTYPES
99#  define CHAR_P int
100#  define SCHAR_P int
101#  define UCHAR_P int
102#  define XCHAR_P int
103#  define SHORT_P int
104#  define BOOLEAN_P int
105#  define ALIGNTYP_P int
106# endif
107#endif
108#if defined(ULTRIX_PROTO) && !defined(__STDC__)
109/* The ultrix 2.0 and 2.1 compilers (on Ultrix 4.0 and 4.2 respectively) can't
110 * handle "struct obj *" constructs in prototypes.  Their bugs are different,
111 * but both seem to work if we put "void*" in the prototype instead.  This
112 * gives us minimal prototype checking but avoids the compiler bugs.
113 *
114 * OBJ_P and MONST_P should _only_ be used for declaring function pointers.
115 */
116#define OBJ_P void*
117#define MONST_P void*
118#else
119#define OBJ_P struct obj*
120#define MONST_P struct monst*
121#endif
122
123#define SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
124
125
126/* A limit for some NetHack int variables.  It need not, and for comparable
127 * scoring should not, depend on the actual limit on integers for a
128 * particular machine, although it is set to the minimum required maximum
129 * signed integer for C (2^15 -1).
130 */
131#define LARGEST_INT	32767
132
133
134#ifdef REDO
135#define Getchar pgetchar
136#endif
137
138
139#include "coord.h"
140/*
141 * Automatic inclusions for the subsidiary files.
142 * Please don't change the order.  It does matter.
143 */
144
145#ifdef VMS
146#include "vmsconf.h"
147#endif
148
149#ifdef UNIX
150#include "unixconf.h"
151#endif
152
153#ifdef OS2
154#include "os2conf.h"
155#endif
156
157#ifdef MSDOS
158#include "pcconf.h"
159#endif
160
161#ifdef TOS
162#include "tosconf.h"
163#endif
164
165#ifdef AMIGA
166#include "amiconf.h"
167#endif
168
169#ifdef MAC
170#include "macconf.h"
171#endif
172
173#ifdef __BEOS__
174#include "beconf.h"
175#endif
176
177#ifdef WIN32
178#ifdef WIN_CE
179#include "wceconf.h"
180#else
181#include "ntconf.h"
182#endif
183#endif
184
185/* Displayable name of this port; don't redefine if defined in *conf.h */
186#ifndef PORT_ID
187# ifdef AMIGA
188#  define PORT_ID	"Amiga"
189# endif
190# ifdef MAC
191#  define PORT_ID	"Mac"
192# endif
193# ifdef MSDOS
194#  ifdef PC9800
195#  define PORT_ID	"PC-9800"
196#  else
197#  define PORT_ID	"PC"
198#  endif
199#  ifdef DJGPP
200#  define PORT_SUB_ID	"djgpp"
201#  else
202#   ifdef OVERLAY
203#  define PORT_SUB_ID	"overlaid"
204#   else
205#  define PORT_SUB_ID	"non-overlaid"
206#   endif
207#  endif
208# endif
209# ifdef OS2
210#  define PORT_ID	"OS/2"
211# endif
212# ifdef TOS
213#  define PORT_ID	"ST"
214# endif
215# ifdef UNIX
216#  define PORT_ID	"Unix"
217# endif
218# ifdef VMS
219#  define PORT_ID	"VMS"
220# endif
221# ifdef WIN32
222#  define PORT_ID	"Windows"
223#  ifndef PORT_SUB_ID
224#   ifdef MSWIN_GRAPHICS
225#    define PORT_SUB_ID	"graphical"
226#   else
227#    define PORT_SUB_ID	"tty"
228#   endif
229#  endif
230# endif
231#endif
232
233#if defined(MICRO)
234#if !defined(AMIGA) && !defined(TOS) && !defined(OS2_HPFS)
235#define SHORT_FILENAMES		/* filenames are 8.3 */
236#endif
237#endif
238
239#ifdef VMS
240/* vms_exit() (sys/vms/vmsmisc.c) expects the non-VMS EXIT_xxx values below.
241 * these definitions allow all systems to be treated uniformly, provided
242 * main() routines do not terminate with return(), whose value is not
243 * so massaged.
244 */
245# ifdef EXIT_SUCCESS
246#  undef EXIT_SUCCESS
247# endif
248# ifdef EXIT_FAILURE
249#  undef EXIT_FAILURE
250# endif
251#endif
252
253#ifndef EXIT_SUCCESS
254# define EXIT_SUCCESS 0
255#endif
256#ifndef EXIT_FAILURE
257# define EXIT_FAILURE 1
258#endif
259
260#if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) || defined(MSWIN_GRAPHICS)
261# ifndef USE_TILES
262#  define USE_TILES		/* glyph2tile[] will be available */
263# endif
264#endif
265#if defined(AMII_GRAPHICS) || defined(GEM_GRAPHICS)
266# ifndef USE_TILES
267#  define USE_TILES
268# endif
269#endif
270
271
272#define Sprintf  (void) sprintf
273#define Strcat   (void) strcat
274#define Strcpy   (void) strcpy
275#ifdef NEED_VARARGS
276#define Vprintf  (void) vprintf
277#define Vfprintf (void) vfprintf
278#define Vsprintf (void) vsprintf
279#endif
280
281
282/* primitive memory leak debugging; see alloc.c */
283#ifdef MONITOR_HEAP
284extern long *FDECL(nhalloc, (unsigned int,const char *,int));
285extern void FDECL(nhfree, (genericptr_t,const char *,int));
286# ifndef __FILE__
287#  define __FILE__ ""
288# endif
289# ifndef __LINE__
290#  define __LINE__ 0
291# endif
292# define alloc(a) nhalloc(a,__FILE__,(int)__LINE__)
293# define free(a) nhfree(a,__FILE__,(int)__LINE__)
294#else	/* !MONITOR_HEAP */
295extern long *FDECL(alloc, (unsigned int));		/* alloc.c */
296#endif
297
298/* Used for consistency checks of various data files; declare it here so
299   that utility programs which include config.h but not hack.h can see it. */
300struct version_info {
301	unsigned long	incarnation;	/* actual version number */
302	unsigned long	feature_set;	/* bitmask of config settings */
303	unsigned long	entity_count;	/* # of monsters and objects */
304	unsigned long	struct_sizes;	/* size of key structs */
305};
306
307
308/*
309 * Configurable internal parameters.
310 *
311 * Please be very careful if you are going to change one of these.  Any
312 * changes in these parameters, unless properly done, can render the
313 * executable inoperative.
314 */
315
316/* size of terminal screen is (at least) (ROWNO+3) by COLNO */
317#define COLNO	80
318#define ROWNO	21
319
320#define MAXNROFROOMS	40	/* max number of rooms per level */
321#define MAX_SUBROOMS	24	/* max # of subrooms in a given room */
322#define DOORMAX		120	/* max number of doors per level */
323
324#define BUFSZ		256	/* for getlin buffers */
325#define QBUFSZ		128	/* for building question text */
326#define TBUFSZ		300	/* toplines[] buffer max msg: 3 81char names */
327				/* plus longest prefix plus a few extra words */
328
329#define PL_NSIZ		32	/* name of player, ghost, shopkeeper */
330#define PL_CSIZ		32	/* sizeof pl_character */
331#define PL_FSIZ		32	/* fruit name */
332#define PL_PSIZ		63	/* player-given names for pets, other
333				 * monsters, objects */
334
335#define MAXDUNGEON	16	/* current maximum number of dungeons */
336#define MAXLEVEL	32	/* max number of levels in one dungeon */
337#define MAXSTAIRS	1	/* max # of special stairways in a dungeon */
338#define ALIGNWEIGHT	4	/* generation weight of alignment */
339
340#define MAXULEV		30	/* max character experience level */
341
342#define MAXMONNO	120	/* extinct monst after this number created */
343#define MHPMAX		500	/* maximum monster hp */
344
345#endif /* GLOBAL_H */
346