OSDN Git Service

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