OSDN Git Service

fix #42727
[jnethack/source.git] / include / decl.h
1 /* NetHack 3.6  decl.h  $NHDT-Date: 1573869061 2019/11/16 01:51:01 $  $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.165 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Michael Allison, 2007. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 #ifndef DECL_H
7 #define DECL_H
8
9 #define E extern
10
11 E int NDECL((*occupation));
12 E int NDECL((*afternmv));
13
14 E const char *hname;
15 E int hackpid;
16 #if defined(UNIX) || defined(VMS)
17 E int locknum;
18 #endif
19 #ifdef DEF_PAGER
20 E char *catmore;
21 #endif /* DEF_PAGER */
22
23 E char SAVEF[];
24 #ifdef MICRO
25 E char SAVEP[];
26 #endif
27
28 /* max size of a windowtype option */
29 #define WINTYPELEN 16
30 E char chosen_windowtype[WINTYPELEN];
31
32 E NEARDATA int bases[MAXOCLASSES];
33
34 E NEARDATA int multi;
35 E const char *multi_reason;
36 E NEARDATA int nroom;
37 E NEARDATA int nsubroom;
38 E NEARDATA int occtime;
39
40 #define WARNCOUNT 6 /* number of different warning levels */
41 E nhsym warnsyms[WARNCOUNT];
42 E NEARDATA int warn_obj_cnt; /* count of monsters meeting criteria */
43
44 E int x_maze_max, y_maze_max;
45 E int otg_temp;
46
47 E NEARDATA int in_doagain;
48
49 E struct dgn_topology { /* special dungeon levels for speed */
50     d_level d_oracle_level;
51     d_level d_bigroom_level; /* unused */
52     d_level d_rogue_level;
53     d_level d_medusa_level;
54     d_level d_stronghold_level;
55     d_level d_valley_level;
56     d_level d_wiz1_level;
57     d_level d_wiz2_level;
58     d_level d_wiz3_level;
59     d_level d_juiblex_level;
60     d_level d_orcus_level;
61     d_level d_baalzebub_level; /* unused */
62     d_level d_asmodeus_level;  /* unused */
63     d_level d_portal_level;    /* only in goto_level() [do.c] */
64     d_level d_sanctum_level;
65     d_level d_earth_level;
66     d_level d_water_level;
67     d_level d_fire_level;
68     d_level d_air_level;
69     d_level d_astral_level;
70     xchar d_tower_dnum;
71     xchar d_sokoban_dnum;
72     xchar d_mines_dnum, d_quest_dnum;
73     d_level d_qstart_level, d_qlocate_level, d_nemesis_level;
74     d_level d_knox_level;
75     d_level d_mineend_level;
76     d_level d_sokoend_level;
77 } dungeon_topology;
78 /* macros for accessing the dungeon levels by their old names */
79 /* clang-format off */
80 #define oracle_level            (dungeon_topology.d_oracle_level)
81 #define bigroom_level           (dungeon_topology.d_bigroom_level)
82 #define rogue_level             (dungeon_topology.d_rogue_level)
83 #define medusa_level            (dungeon_topology.d_medusa_level)
84 #define stronghold_level        (dungeon_topology.d_stronghold_level)
85 #define valley_level            (dungeon_topology.d_valley_level)
86 #define wiz1_level              (dungeon_topology.d_wiz1_level)
87 #define wiz2_level              (dungeon_topology.d_wiz2_level)
88 #define wiz3_level              (dungeon_topology.d_wiz3_level)
89 #define juiblex_level           (dungeon_topology.d_juiblex_level)
90 #define orcus_level             (dungeon_topology.d_orcus_level)
91 #define baalzebub_level         (dungeon_topology.d_baalzebub_level)
92 #define asmodeus_level          (dungeon_topology.d_asmodeus_level)
93 #define portal_level            (dungeon_topology.d_portal_level)
94 #define sanctum_level           (dungeon_topology.d_sanctum_level)
95 #define earth_level             (dungeon_topology.d_earth_level)
96 #define water_level             (dungeon_topology.d_water_level)
97 #define fire_level              (dungeon_topology.d_fire_level)
98 #define air_level               (dungeon_topology.d_air_level)
99 #define astral_level            (dungeon_topology.d_astral_level)
100 #define tower_dnum              (dungeon_topology.d_tower_dnum)
101 #define sokoban_dnum            (dungeon_topology.d_sokoban_dnum)
102 #define mines_dnum              (dungeon_topology.d_mines_dnum)
103 #define quest_dnum              (dungeon_topology.d_quest_dnum)
104 #define qstart_level            (dungeon_topology.d_qstart_level)
105 #define qlocate_level           (dungeon_topology.d_qlocate_level)
106 #define nemesis_level           (dungeon_topology.d_nemesis_level)
107 #define knox_level              (dungeon_topology.d_knox_level)
108 #define mineend_level           (dungeon_topology.d_mineend_level)
109 #define sokoend_level           (dungeon_topology.d_sokoend_level)
110 /* clang-format on */
111
112 E NEARDATA stairway dnstair, upstair; /* stairs up and down */
113 #define xdnstair (dnstair.sx)
114 #define ydnstair (dnstair.sy)
115 #define xupstair (upstair.sx)
116 #define yupstair (upstair.sy)
117
118 E NEARDATA stairway dnladder, upladder; /* ladders up and down */
119 #define xdnladder (dnladder.sx)
120 #define ydnladder (dnladder.sy)
121 #define xupladder (upladder.sx)
122 #define yupladder (upladder.sy)
123
124 E NEARDATA stairway sstairs;
125
126 E NEARDATA dest_area updest, dndest; /* level-change destination areas */
127
128 E NEARDATA coord inv_pos;
129 E NEARDATA dungeon dungeons[];
130 E NEARDATA s_level *sp_levchn;
131 #define dunlev_reached(x) (dungeons[(x)->dnum].dunlev_ureached)
132
133 #include "quest.h"
134 E struct q_score quest_status;
135
136 E NEARDATA char pl_character[PL_CSIZ];
137 E NEARDATA char pl_race; /* character's race */
138
139 E NEARDATA char pl_fruit[PL_FSIZ];
140 E NEARDATA struct fruit *ffruit;
141
142 E NEARDATA char tune[6];
143
144 #define MAXLINFO (MAXDUNGEON * MAXLEVEL)
145 E struct linfo level_info[MAXLINFO];
146
147 E NEARDATA struct sinfo {
148     int gameover;  /* self explanatory? */
149     int stopprint; /* inhibit further end of game disclosure */
150 #ifdef HANGUPHANDLING
151     volatile int done_hup; /* SIGHUP or moral equivalent received
152                             * -- no more screen output */
153     int preserve_locks;    /* don't remove level files prior to exit */
154 #endif
155     int something_worth_saving; /* in case of panic */
156     int panicking;              /* `panic' is in progress */
157     int exiting;                /* an exit handler is executing */
158     int in_moveloop;
159     int in_impossible;
160 #ifdef PANICLOG
161     int in_paniclog;
162 #endif
163     int wizkit_wishing;
164 } program_state;
165
166 E boolean restoring;
167 E boolean ransacked;
168
169 E const char quitchars[];
170 E const char vowels[];
171 E const char ynchars[];
172 E const char ynqchars[];
173 E const char ynaqchars[];
174 E const char ynNaqchars[];
175 E NEARDATA long yn_number;
176
177 E const char disclosure_options[];
178
179 E NEARDATA int smeq[];
180 E NEARDATA int doorindex;
181 E NEARDATA char *save_cm;
182
183 E NEARDATA struct kinfo {
184     struct kinfo *next; /* chain of delayed killers */
185     int id;             /* uprop keys to ID a delayed killer */
186     int format;         /* one of the killer formats */
187 #define KILLED_BY_AN 0
188 #define KILLED_BY 1
189 #define NO_KILLER_PREFIX 2
190 #if 1 /*JP*/
191 #define KILLED_SUFFIX    3
192 #endif
193     char name[BUFSZ]; /* actual killer name */
194 } killer;
195
196 E long done_money;
197 E NEARDATA char plname[PL_NSIZ];
198 E NEARDATA char dogname[];
199 E NEARDATA char catname[];
200 E NEARDATA char horsename[];
201 E char preferred_pet;
202 E const char *occtxt; /* defined when occupation != NULL */
203 E const char *nomovemsg;
204 E char lock[];
205
206 E const schar xdir[], ydir[], zdir[];
207
208 E NEARDATA schar tbx, tby; /* set in mthrowu.c */
209
210 E NEARDATA struct multishot {
211     int n, i;
212     short o;
213     boolean s;
214 } m_shot;
215
216 E NEARDATA long moves, monstermoves;
217 E NEARDATA long wailmsg;
218
219 E NEARDATA boolean in_mklev;
220 E NEARDATA boolean stoned;
221 E NEARDATA boolean unweapon;
222 E NEARDATA boolean mrg_to_wielded;
223 E NEARDATA boolean defer_see_monsters;
224
225 E NEARDATA boolean in_steed_dismounting;
226 E NEARDATA boolean has_strong_rngseed;
227
228 E const int shield_static[];
229
230 #include "spell.h"
231 E NEARDATA struct spell spl_book[]; /* sized in decl.c */
232
233 #include "color.h"
234 #ifdef TEXTCOLOR
235 E const int zapcolors[];
236 #endif
237
238 E const struct class_sym def_oc_syms[MAXOCLASSES]; /* default class symbols */
239 E uchar oc_syms[MAXOCLASSES];                      /* current class symbols */
240 E const struct class_sym def_monsyms[MAXMCLASSES]; /* default class symbols */
241 E uchar monsyms[MAXMCLASSES];                      /* current class symbols */
242
243 #include "obj.h"
244 E NEARDATA struct obj *invent, *uarm, *uarmc, *uarmh, *uarms, *uarmg, *uarmf,
245     *uarmu, /* under-wear, so to speak */
246     *uskin, *uamul, *uleft, *uright, *ublindf, *uwep, *uswapwep, *uquiver;
247
248 E NEARDATA struct obj *uchain; /* defined only when punished */
249 E NEARDATA struct obj *uball;
250 E NEARDATA struct obj *migrating_objs;
251 E NEARDATA struct obj *billobjs;
252 E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj;
253
254 E NEARDATA const struct obj zeroobj; /* for init; also, &zeroobj is used
255                                       * as special value */
256
257 E NEARDATA const anything zeroany;   /* init'd and defined in decl.c */
258
259 #include "you.h"
260 E NEARDATA struct you u;
261 E NEARDATA time_t ubirthday;
262 E NEARDATA struct u_realtime urealtime;
263
264 #include "onames.h"
265 #ifndef PM_H /* (pm.h has already been included via youprop.h) */
266 #include "pm.h"
267 #endif
268
269 E NEARDATA const struct monst zeromonst; /* for init of new or temp monsters */
270 E NEARDATA struct monst youmonst; /* monster details when hero is poly'd */
271 E NEARDATA struct monst *mydogs, *migrating_mons;
272
273 E NEARDATA struct mvitals {
274     uchar born;
275     uchar died;
276     uchar mvflags;
277 } mvitals[NUMMONS];
278
279 E NEARDATA long domove_attempting;
280 E NEARDATA long domove_succeeded;
281 #define DOMOVE_WALK         0x00000001
282 #define DOMOVE_RUSH         0x00000002
283
284 E NEARDATA struct c_color_names {
285     const char *const c_black, *const c_amber, *const c_golden,
286         *const c_light_blue, *const c_red, *const c_green, *const c_silver,
287         *const c_blue, *const c_purple, *const c_white, *const c_orange;
288 } c_color_names;
289 #define NH_BLACK c_color_names.c_black
290 #define NH_AMBER c_color_names.c_amber
291 #define NH_GOLDEN c_color_names.c_golden
292 #define NH_LIGHT_BLUE c_color_names.c_light_blue
293 #define NH_RED c_color_names.c_red
294 #define NH_GREEN c_color_names.c_green
295 #define NH_SILVER c_color_names.c_silver
296 #define NH_BLUE c_color_names.c_blue
297 #define NH_PURPLE c_color_names.c_purple
298 #define NH_WHITE c_color_names.c_white
299 #define NH_ORANGE c_color_names.c_orange
300
301 /* The names of the colors used for gems, etc. */
302 E const char *c_obj_colors[];
303
304 E struct c_common_strings {
305     const char *const c_nothing_happens, *const c_thats_enough_tries,
306         *const c_silly_thing_to, *const c_shudder_for_moment,
307         *const c_something, *const c_Something, *const c_You_can_move_again,
308         *const c_Never_mind, *c_vision_clears, *const c_the_your[2],
309         *const c_fakename[2];
310 } c_common_strings;
311 #define nothing_happens c_common_strings.c_nothing_happens
312 #define thats_enough_tries c_common_strings.c_thats_enough_tries
313 #define silly_thing_to c_common_strings.c_silly_thing_to
314 #define shudder_for_moment c_common_strings.c_shudder_for_moment
315 #define something c_common_strings.c_something
316 #define Something c_common_strings.c_Something
317 #define You_can_move_again c_common_strings.c_You_can_move_again
318 #define Never_mind c_common_strings.c_Never_mind
319 #define vision_clears c_common_strings.c_vision_clears
320 #define the_your c_common_strings.c_the_your
321 /* fakename[] used occasionally so vtense() won't be fooled by an assigned
322    name ending in 's' */
323 #define fakename c_common_strings.c_fakename
324
325 /* material strings */
326 E const char *materialnm[];
327
328 /* Monster name articles */
329 #define ARTICLE_NONE 0
330 #define ARTICLE_THE 1
331 #define ARTICLE_A 2
332 #define ARTICLE_YOUR 3
333
334 /* Monster name suppress masks */
335 #define SUPPRESS_IT 0x01
336 #define SUPPRESS_INVISIBLE 0x02
337 #define SUPPRESS_HALLUCINATION 0x04
338 #define SUPPRESS_SADDLE 0x08
339 #define EXACT_NAME 0x0F
340 #define SUPPRESS_NAME 0x10
341
342 /* Vision */
343 E NEARDATA boolean vision_full_recalc; /* TRUE if need vision recalc */
344 E NEARDATA char **viz_array;           /* could see/in sight row pointers */
345
346 /* Window system stuff */
347 E NEARDATA winid WIN_MESSAGE;
348 E NEARDATA winid WIN_STATUS;
349 E NEARDATA winid WIN_MAP, WIN_INVEN;
350
351 /* pline (et al) for a single string argument (suppress compiler warning) */
352 #define pline1(cstr) pline("%s", cstr)
353 #define Your1(cstr) Your("%s", cstr)
354 #define You1(cstr) You("%s", cstr)
355 #define verbalize1(cstr) verbalize("%s", cstr)
356 #define You_hear1(cstr) You_hear("%s", cstr)
357 #define Sprintf1(buf, cstr) Sprintf(buf, "%s", cstr)
358 #define panic1(cstr) panic("%s", cstr)
359
360 E char toplines[];
361 #ifndef TCAP_H
362 E struct tc_gbl_data {   /* also declared in tcap.h */
363     char *tc_AS, *tc_AE; /* graphics start and end (tty font swapping) */
364     int tc_LI, tc_CO;    /* lines and columns */
365 } tc_gbl_data;
366 #define AS tc_gbl_data.tc_AS
367 #define AE tc_gbl_data.tc_AE
368 #define LI tc_gbl_data.tc_LI
369 #define CO tc_gbl_data.tc_CO
370 #endif
371
372 /* xxxexplain[] is in drawing.c */
373 E const char *const monexplain[], invisexplain[], *const oclass_names[];
374
375 /* Some systems want to use full pathnames for some subsets of file names,
376  * rather than assuming that they're all in the current directory.  This
377  * provides all the subclasses that seem reasonable, and sets up for all
378  * prefixes being null.  Port code can set those that it wants.
379  */
380 #define HACKPREFIX 0
381 #define LEVELPREFIX 1
382 #define SAVEPREFIX 2
383 #define BONESPREFIX 3
384 #define DATAPREFIX 4 /* this one must match hardcoded value in dlb.c */
385 #define SCOREPREFIX 5
386 #define LOCKPREFIX 6
387 #define SYSCONFPREFIX 7
388 #define CONFIGPREFIX 8
389 #define TROUBLEPREFIX 9
390 #define PREFIX_COUNT 10
391 /* used in files.c; xxconf.h can override if needed */
392 #ifndef FQN_MAX_FILENAME
393 #define FQN_MAX_FILENAME 512
394 #endif
395
396 #if defined(NOCWD_ASSUMPTIONS) || defined(VAR_PLAYGROUND)
397 /* the bare-bones stuff is unconditional above to simplify coding; for
398  * ports that actually use prefixes, add some more localized things
399  */
400 #define PREFIXES_IN_USE
401 #endif
402
403 E char *fqn_prefix[PREFIX_COUNT];
404 #ifdef WIN32
405 E boolean fqn_prefix_locked[PREFIX_COUNT];
406 #endif
407 #ifdef PREFIXES_IN_USE
408 E const char *fqn_prefix_names[PREFIX_COUNT];
409 #endif
410
411 E NEARDATA struct savefile_info sfcap, sfrestinfo, sfsaveinfo;
412
413 struct opvar {
414     xchar spovartyp; /* one of SPOVAR_foo */
415     union {
416         char *str;
417         long l;
418     } vardata;
419 };
420
421 struct autopickup_exception {
422     struct nhregex *regex;
423     char *pattern;
424     boolean grab;
425     struct autopickup_exception *next;
426 };
427 E struct autopickup_exception *apelist;
428
429 struct plinemsg_type {
430     xchar msgtype;  /* one of MSGTYP_foo */
431     struct nhregex *regex;
432     char *pattern;
433     struct plinemsg_type *next;
434 };
435
436 #define MSGTYP_NORMAL   0
437 #define MSGTYP_NOREP    1
438 #define MSGTYP_NOSHOW   2
439 #define MSGTYP_STOP     3
440 /* bitmask for callers of hide_unhide_msgtypes() */
441 #define MSGTYP_MASK_REP_SHOW ((1 << MSGTYP_NOREP) | (1 << MSGTYP_NOSHOW))
442
443 E struct plinemsg_type *plinemsg_types;
444
445 enum bcargs {override_restriction = -1};
446 struct breadcrumbs {
447     const char *funcnm;
448     int linenum;
449     boolean in_effect;
450 };
451
452 #ifdef PANICTRACE
453 E const char *ARGV0;
454 #endif
455
456 enum earlyarg {ARG_DEBUG, ARG_VERSION, ARG_SHOWPATHS
457 #ifdef WIN32
458     ,ARG_WINDOWS
459 #endif
460 };
461
462 struct early_opt {
463     enum earlyarg e;
464     const char *name;
465     int minlength;
466     boolean valallowed;
467 };
468
469 #if 1 /*JP*/
470 struct trans_verb {
471     const char *en;
472     const char *what;
473     const char *particle;
474     const char *jp;
475 };
476
477 /* hcolor()\82Í\8c`\97e\8e\8c\82ð\95Ô\82·\82Ì\82Å\95\9b\8e\8c\82É\95Ï\8a·\82·\82é */
478 #define hcolor_adv(x) jconj_adj(hcolor((x)))
479 /* \8cÅ\92è\95\8e\9a\97ñ\97pstrncmp */
480 #define STRNCMP2(x, y) strncmp(x, y, strlen(y))
481 #endif
482
483 #undef E
484
485 #endif /* DECL_H */