Source:NetHack 3.4.3/include/global.h

From NetHackWiki
Jump to: navigation, search

Below is the full text to include/global.h from NetHack 3.4.3. To link to a particular line, write [[global.h#line123]], for example.

  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. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

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

Note that you *can* change COLNO and ROWNO in order to produce a NetHack that generates larger levels than normal. However, it is bones- and save- incompatible in a way that is NOT detected properly and will crash your game; and the panning mechanism which lets you play ordinary 80x21 games on a smaller screen does not work, so you will need an actually larger screen.

  1. /* size of terminal screen is (at least) (ROWNO+3) by COLNO */
  2. #define COLNO	80
  3. #define ROWNO	21
  4.  
  5. #define MAXNROFROOMS	40	/* max number of rooms per level */
  6. #define MAX_SUBROOMS	24	/* max # of subrooms in a given room */
  7. #define DOORMAX		120	/* max number of doors per level */
  8.  
  9. #define BUFSZ		256	/* for getlin buffers */
  10. #define QBUFSZ		128	/* for building question text */
  11. #define TBUFSZ		300	/* toplines[] buffer max msg: 3 81char names */
  12. 				/* plus longest prefix plus a few extra words */
  13.  
  14. #define PL_NSIZ		32	/* name of player, ghost, shopkeeper */
  15. #define PL_CSIZ		32	/* sizeof pl_character */
  16. #define PL_FSIZ		32	/* fruit name */
  17. #define PL_PSIZ		63	/* player-given names for pets, other
  18. 				 * monsters, objects */
  19.  
  20. #define MAXDUNGEON	16	/* current maximum number of dungeons */
  21. #define MAXLEVEL	32	/* max number of levels in one dungeon */
  22. #define MAXSTAIRS	1	/* max # of special stairways in a dungeon */
  23. #define ALIGNWEIGHT	4	/* generation weight of alignment */
  24.  
  25. #define MAXULEV		30	/* max character experience level */
  26.  
  27. #define MAXMONNO	120	/* extinct monst after this number created */
  28. #define MHPMAX		500	/* maximum monster hp */
  29.  
  30. #endif /* GLOBAL_H */