OSDN Git Service

upgrade to 3.6.2
[jnethack/source.git] / include / global.h
1 /* NetHack 3.6  global.h        $NHDT-Date: 1557254325 2019/05/07 18:38:45 $  $NHDT-Branch: NetHack-3.6.2 $:$NHDT-Revision: 1.71 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Michael Allison, 2006. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 #ifndef GLOBAL_H
7 #define GLOBAL_H
8
9 #include <stdio.h>
10
11 /* #define BETA */  /* development or beta testing [MRS] */
12
13 #ifndef DEBUG  /* allow tool chains to define without causing warnings */
14 #define DEBUG
15 #endif
16
17 /*
18  * Files expected to exist in the playground directory.
19  */
20
21 #define RECORD "record"         /* file containing list of topscorers */
22 #define HELP "help"             /* file containing command descriptions */
23 #define SHELP "hh"              /* abbreviated form of the same */
24 #define KEYHELP "keyhelp"       /* explanatory text for 'whatdoes' command */
25 #define DEBUGHELP "wizhelp"     /* file containing debug mode cmds */
26 #define RUMORFILE "rumors"      /* file with fortune cookies */
27 #define ORACLEFILE "oracles"    /* file with oracular information */
28 #define DATAFILE "data"         /* file giving the meaning of symbols used */
29 #define CMDHELPFILE "cmdhelp"   /* file telling what commands do */
30 #define HISTORY "history"       /* file giving nethack's history */
31 #define LICENSE "license"       /* file with license information */
32 #define OPTIONFILE "opthelp"    /* file explaining runtime options */
33 #define OPTIONS_USED "options"  /* compile-time options, for #version */
34 #define SYMBOLS "symbols"       /* replacement symbol sets */
35 #define EPITAPHFILE "epitaph"   /* random epitaphs on graves */
36 #define ENGRAVEFILE "engrave"   /* random engravings on the floor */
37 #define BOGUSMONFILE "bogusmon" /* hallucinatory monsters */
38 #define TRIBUTEFILE "tribute"   /* 3.6 tribute to Terry Pratchett */
39 #define LEV_EXT ".lev"          /* extension for special level files */
40
41 /* Assorted definitions that may depend on selections in config.h. */
42
43 /*
44  * for DUMB preprocessor and compiler, e.g., cpp and pcc supplied
45  * with Microport SysV/AT, which have small symbol tables;
46  * DUMB if needed is defined in CFLAGS
47  */
48 #ifdef DUMB
49 #ifdef BITFIELDS
50 #undef BITFIELDS
51 #endif
52 #ifndef STUPID
53 #define STUPID
54 #endif
55 #endif /* DUMB */
56
57 /*
58  * type xchar: small integers in the range 0 - 127, usually coordinates
59  * although they are nonnegative they must not be declared unsigned
60  * since otherwise comparisons with signed quantities are done incorrectly
61  */
62 typedef schar xchar;
63 #if defined(__GNUC__) && defined(WIN32) && defined(__cplusplus)
64 /* Resolve conflict with Qt 5 and MinGW-w32 */
65 typedef uchar boolean; /* 0 or 1 */
66 #else
67 #ifndef SKIP_BOOLEAN
68 typedef xchar boolean; /* 0 or 1 */
69 #endif
70 #endif
71
72 #ifndef TRUE /* defined in some systems' native include files */
73 #define TRUE ((boolean) 1)
74 #define FALSE ((boolean) 0)
75 #endif
76
77 /*
78  * type nhsym: loadable symbols go into this type
79  */
80 typedef uchar nhsym;
81
82 #ifndef STRNCMPI
83 #ifndef __SASC_60 /* SAS/C already shifts to stricmp */
84 #define strcmpi(a, b) strncmpi((a), (b), -1)
85 #endif
86 #endif
87
88 /* comment out to test effects of each #define -- these will probably
89  * disappear eventually
90  */
91 #ifdef INTERNAL_COMP
92 #define RLECOMP  /* run-length compression of levl array - JLee */
93 #define ZEROCOMP /* zero-run compression of everything - Olaf Seibert */
94 #endif
95
96 /* #define SPECIALIZATION */ /* do "specialized" version of new topology */
97
98 #ifdef BITFIELDS
99 #define Bitfield(x, n) unsigned x : n
100 #else
101 #define Bitfield(x, n) uchar x
102 #endif
103
104 #define SIZE(x) (int)(sizeof(x) / sizeof(x[0]))
105
106 /* A limit for some NetHack int variables.  It need not, and for comparable
107  * scoring should not, depend on the actual limit on integers for a
108  * particular machine, although it is set to the minimum required maximum
109  * signed integer for C (2^15 -1).
110  */
111 #define LARGEST_INT 32767
112
113 #include "coord.h"
114 /*
115  * Automatic inclusions for the subsidiary files.
116  * Please don't change the order.  It does matter.
117  */
118
119 #ifdef VMS
120 #include "vmsconf.h"
121 #endif
122
123 #ifdef UNIX
124 #include "unixconf.h"
125 #endif
126
127 #ifdef OS2
128 #include "os2conf.h"
129 #endif
130
131 #ifdef MSDOS
132 #include "pcconf.h"
133 #endif
134
135 #ifdef TOS
136 #include "tosconf.h"
137 #endif
138
139 #ifdef AMIGA
140 #include "amiconf.h"
141 #endif
142
143 #ifdef MAC
144 #include "macconf.h"
145 #endif
146
147 #ifdef __BEOS__
148 #include "beconf.h"
149 #endif
150
151 #ifdef WIN32
152 #ifdef WIN_CE
153 #include "wceconf.h"
154 #else
155 #include "ntconf.h"
156 #endif
157 #endif
158
159 /* Displayable name of this port; don't redefine if defined in *conf.h */
160 #ifndef PORT_ID
161 #ifdef AMIGA
162 #define PORT_ID "Amiga"
163 #endif
164 #ifdef MAC
165 #define PORT_ID "Mac"
166 #endif
167 #ifdef __APPLE__
168 #define PORT_ID "MacOSX"
169 #endif
170 #ifdef MSDOS
171 #ifdef PC9800
172 #define PORT_ID "PC-9800"
173 #else
174 #define PORT_ID "PC"
175 #endif
176 #ifdef DJGPP
177 #define PORT_SUB_ID "djgpp"
178 #else
179 #ifdef OVERLAY
180 #define PORT_SUB_ID "overlaid"
181 #else
182 #define PORT_SUB_ID "non-overlaid"
183 #endif
184 #endif
185 #endif
186 #ifdef OS2
187 #define PORT_ID "OS/2"
188 #endif
189 #ifdef TOS
190 #define PORT_ID "ST"
191 #endif
192 /* Check again in case something more specific has been defined above. */
193 #ifndef PORT_ID
194 #ifdef UNIX
195 #define PORT_ID "Unix"
196 #endif
197 #endif
198 #ifdef VMS
199 #define PORT_ID "VMS"
200 #endif
201 #ifdef WIN32
202 #define PORT_ID "Windows"
203 #endif
204 #endif
205
206 #if defined(MICRO)
207 #if !defined(AMIGA) && !defined(TOS) && !defined(OS2_HPFS)
208 #define SHORT_FILENAMES /* filenames are 8.3 */
209 #endif
210 #endif
211
212 #ifdef VMS
213 /* vms_exit() (sys/vms/vmsmisc.c) expects the non-VMS EXIT_xxx values below.
214  * these definitions allow all systems to be treated uniformly, provided
215  * main() routines do not terminate with return(), whose value is not
216  * so massaged.
217  */
218 #ifdef EXIT_SUCCESS
219 #undef EXIT_SUCCESS
220 #endif
221 #ifdef EXIT_FAILURE
222 #undef EXIT_FAILURE
223 #endif
224 #endif
225
226 #ifndef EXIT_SUCCESS
227 #define EXIT_SUCCESS 0
228 #endif
229 #ifndef EXIT_FAILURE
230 #define EXIT_FAILURE 1
231 #endif
232
233 #if defined(X11_GRAPHICS) || defined(QT_GRAPHICS) || defined(GNOME_GRAPHICS) \
234     || defined(WIN32)
235 #ifndef USE_TILES
236 #define USE_TILES /* glyph2tile[] will be available */
237 #endif
238 #endif
239 #if defined(AMII_GRAPHICS) || defined(GEM_GRAPHICS)
240 #ifndef USE_TILES
241 #define USE_TILES
242 #endif
243 #endif
244
245 #if defined(UNIX) || defined(VMS) || defined(__EMX__) || defined(WIN32)
246 #define HANGUPHANDLING
247 #endif
248 #if defined(SAFERHANGUP) \
249     && (defined(NOSAVEONHANGUP) || !defined(HANGUPHANDLING))
250 #undef SAFERHANGUP
251 #endif
252
253 #define Sprintf (void) sprintf
254 #define Strcat (void) strcat
255 #define Strcpy (void) strcpy
256 #ifdef NEED_VARARGS
257 #define Vprintf (void) vprintf
258 #define Vfprintf (void) vfprintf
259 #define Vsprintf (void) vsprintf
260 #endif
261
262 /* primitive memory leak debugging; see alloc.c */
263 #ifdef MONITOR_HEAP
264 extern long *FDECL(nhalloc, (unsigned int, const char *, int));
265 extern void FDECL(nhfree, (genericptr_t, const char *, int));
266 extern char *FDECL(nhdupstr, (const char *, const char *, int));
267 #ifndef __FILE__
268 #define __FILE__ ""
269 #endif
270 #ifndef __LINE__
271 #define __LINE__ 0
272 #endif
273 #define alloc(a) nhalloc(a, __FILE__, (int) __LINE__)
274 #define free(a) nhfree(a, __FILE__, (int) __LINE__)
275 #define dupstr(s) nhdupstr(s, __FILE__, (int) __LINE__)
276 #else /* !MONITOR_HEAP */
277 extern long *FDECL(alloc, (unsigned int));  /* alloc.c */
278 extern char *FDECL(dupstr, (const char *)); /* ditto */
279 #endif
280
281 /* Used for consistency checks of various data files; declare it here so
282    that utility programs which include config.h but not hack.h can see it. */
283 struct version_info {
284     unsigned long incarnation;   /* actual version number */
285     unsigned long feature_set;   /* bitmask of config settings */
286     unsigned long entity_count;  /* # of monsters and objects */
287     unsigned long struct_sizes1; /* size of key structs */
288     unsigned long struct_sizes2; /* size of more key structs */
289 };
290
291 struct savefile_info {
292     unsigned long sfi1; /* compression etc. */
293     unsigned long sfi2; /* miscellaneous */
294     unsigned long sfi3; /* thirdparty */
295 };
296 #ifdef NHSTDC
297 #define SFI1_EXTERNALCOMP (1UL)
298 #define SFI1_RLECOMP (1UL << 1)
299 #define SFI1_ZEROCOMP (1UL << 2)
300 #else
301 #define SFI1_EXTERNALCOMP (1L)
302 #define SFI1_RLECOMP (1L << 1)
303 #define SFI1_ZEROCOMP (1L << 2)
304 #endif
305
306 /*
307  * Configurable internal parameters.
308  *
309  * Please be very careful if you are going to change one of these.  Any
310  * changes in these parameters, unless properly done, can render the
311  * executable inoperative.
312  */
313
314 /* size of terminal screen is (at least) (ROWNO+3) by COLNO */
315 #define COLNO 80
316 #define ROWNO 21
317
318 #define MAXNROFROOMS 40 /* max number of rooms per level */
319 #define MAX_SUBROOMS 24 /* max # of subrooms in a given room */
320 #define DOORMAX 120     /* max number of doors per level */
321
322 #define BUFSZ 256  /* for getlin buffers */
323 #define QBUFSZ 128 /* for building question text */
324 #define TBUFSZ 300 /* toplines[] buffer max msg: 3 81char names */
325 /* plus longest prefix plus a few extra words */
326
327 #define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
328 #define PL_CSIZ 32 /* sizeof pl_character */
329 #define PL_FSIZ 32 /* fruit name */
330 #define PL_PSIZ 63 /* player-given names for pets, other monsters, objects */
331
332 #define MAXDUNGEON 16 /* current maximum number of dungeons */
333 #define MAXLEVEL 32   /* max number of levels in one dungeon */
334 #define MAXSTAIRS 1   /* max # of special stairways in a dungeon */
335 #define ALIGNWEIGHT 4 /* generation weight of alignment */
336
337 #define MAXULEV 30 /* max character experience level */
338
339 #define MAXMONNO 120 /* extinct monst after this number created */
340 #define MHPMAX 500   /* maximum monster hp */
341
342 /* PANICTRACE: Always defined for BETA but only for supported platforms. */
343 #ifdef UNIX
344 #ifdef BETA
345 /* see end.c */
346 #ifndef PANICTRACE
347 #define PANICTRACE
348 #endif
349 #endif
350 #endif
351 /* The following are meaningless if PANICTRACE is not defined: */
352 #if defined(__linux__) && defined(__GLIBC__) && (__GLIBC__ >= 2)
353 #define PANICTRACE_LIBC
354 #endif
355 #if defined(MACOSX)
356 #define PANICTRACE_LIBC
357 #endif
358 #ifdef UNIX
359 #define PANICTRACE_GDB
360 #endif
361
362 /* Supply nethack_enter macro if not supplied by port */
363 #ifndef nethack_enter
364 #define nethack_enter(argc, argv) ((void) 0)
365 #endif
366
367
368 #endif /* GLOBAL_H */