OSDN Git Service

upgrade to 3.6.2
[jnethack/source.git] / src / decl.c
1 /* NetHack 3.6  decl.c  $NHDT-Date: 1547025164 2019/01/09 09:12:44 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.141 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /*-Copyright (c) Michael Allison, 2009. */
4 /* NetHack may be freely redistributed.  See license for details. */
5
6 #include "hack.h"
7
8 int NDECL((*afternmv));
9 int NDECL((*occupation));
10
11 /* from xxxmain.c */
12 const char *hname = 0; /* name of the game (argv[0] of main) */
13 int hackpid = 0;       /* current process id */
14 #if defined(UNIX) || defined(VMS)
15 int locknum = 0; /* max num of simultaneous users */
16 #endif
17 #ifdef DEF_PAGER
18 char *catmore = 0; /* default pager */
19 #endif
20 char chosen_windowtype[WINTYPELEN];
21
22 NEARDATA int bases[MAXOCLASSES] = DUMMY;
23
24 NEARDATA int multi = 0;
25 const char *multi_reason = NULL;
26 NEARDATA int nroom = 0;
27 NEARDATA int nsubroom = 0;
28 NEARDATA int occtime = 0;
29
30 /* maze limits must be even; masking off lowest bit guarantees that */
31 int x_maze_max = (COLNO - 1) & ~1, y_maze_max = (ROWNO - 1) & ~1;
32
33 int otg_temp; /* used by object_to_glyph() [otg] */
34
35 NEARDATA int in_doagain = 0;
36
37 /*
38  *      The following structure will be initialized at startup time with
39  *      the level numbers of some "important" things in the game.
40  */
41 struct dgn_topology dungeon_topology = { DUMMY };
42
43 struct q_score quest_status = DUMMY;
44
45 NEARDATA int warn_obj_cnt = 0;
46 NEARDATA int smeq[MAXNROFROOMS + 1] = DUMMY;
47 NEARDATA int doorindex = 0;
48 NEARDATA char *save_cm = 0;
49
50 NEARDATA struct kinfo killer = DUMMY;
51 NEARDATA long done_money = 0;
52 const char *nomovemsg = 0;
53 NEARDATA char plname[PL_NSIZ] = DUMMY; /* player name */
54 NEARDATA char pl_character[PL_CSIZ] = DUMMY;
55 NEARDATA char pl_race = '\0';
56
57 NEARDATA char pl_fruit[PL_FSIZ] = DUMMY;
58 NEARDATA struct fruit *ffruit = (struct fruit *) 0;
59
60 NEARDATA char tune[6] = DUMMY;
61 NEARDATA boolean ransacked = 0;
62
63 const char *occtxt = DUMMY;
64 const char quitchars[] = " \r\n\033";
65 const char vowels[] = "aeiouAEIOU";
66 const char ynchars[] = "yn";
67 const char ynqchars[] = "ynq";
68 const char ynaqchars[] = "ynaq";
69 const char ynNaqchars[] = "yn#aq";
70 NEARDATA long yn_number = 0L;
71
72 const char disclosure_options[] = "iavgco";
73
74 #if defined(MICRO) || defined(WIN32)
75 char hackdir[PATHLEN]; /* where rumors, help, record are */
76 #ifdef MICRO
77 char levels[PATHLEN]; /* where levels are */
78 #endif
79 #endif /* MICRO || WIN32 */
80
81 #ifdef MFLOPPY
82 char permbones[PATHLEN]; /* where permanent copy of bones go */
83 int ramdisk = FALSE;     /* whether to copy bones to levels or not */
84 int saveprompt = TRUE;
85 const char *alllevels = "levels.*";
86 const char *allbones = "bones*.*";
87 #endif
88
89 struct linfo level_info[MAXLINFO];
90
91 NEARDATA struct sinfo program_state;
92
93 /* x/y/z deltas for the 10 movement directions (8 compass pts, 2 up/down) */
94 const schar xdir[10] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 };
95 const schar ydir[10] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 };
96 const schar zdir[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, -1 };
97
98 NEARDATA schar tbx = 0, tby = 0; /* mthrowu: target */
99
100 /* for xname handling of multiple shot missile volleys:
101    number of shots, index of current one, validity check, shoot vs throw */
102 NEARDATA struct multishot m_shot = { 0, 0, STRANGE_OBJECT, FALSE };
103
104 NEARDATA dungeon dungeons[MAXDUNGEON]; /* ini'ed by init_dungeon() */
105 NEARDATA s_level *sp_levchn;
106 NEARDATA stairway upstair = { 0, 0, { 0, 0 }, 0 },
107                   dnstair = { 0, 0, { 0, 0 }, 0 };
108 NEARDATA stairway upladder = { 0, 0, { 0, 0 }, 0 },
109                   dnladder = { 0, 0, { 0, 0 }, 0 };
110 NEARDATA stairway sstairs = { 0, 0, { 0, 0 }, 0 };
111 NEARDATA dest_area updest = { 0, 0, 0, 0, 0, 0, 0, 0 };
112 NEARDATA dest_area dndest = { 0, 0, 0, 0, 0, 0, 0, 0 };
113 NEARDATA coord inv_pos = { 0, 0 };
114
115 NEARDATA boolean defer_see_monsters = FALSE;
116 NEARDATA boolean in_mklev = FALSE;
117 NEARDATA boolean stoned = FALSE; /* done to monsters hit by 'c' */
118 NEARDATA boolean unweapon = FALSE;
119 NEARDATA boolean mrg_to_wielded = FALSE;
120 /* weapon picked is merged with wielded one */
121
122 NEARDATA boolean in_steed_dismounting = FALSE;
123 NEARDATA boolean has_strong_rngseed = FALSE;
124
125 NEARDATA coord bhitpos = DUMMY;
126 NEARDATA coord doors[DOORMAX] = { DUMMY };
127
128 NEARDATA struct mkroom rooms[(MAXNROFROOMS + 1) * 2] = { DUMMY };
129 NEARDATA struct mkroom *subrooms = &rooms[MAXNROFROOMS + 1];
130 struct mkroom *upstairs_room, *dnstairs_room, *sstairs_room;
131
132 dlevel_t level; /* level map */
133 struct trap *ftrap = (struct trap *) 0;
134 NEARDATA struct monst youmonst = DUMMY;
135 NEARDATA struct context_info context = DUMMY;
136 NEARDATA struct flag flags = DUMMY;
137 #ifdef SYSFLAGS
138 NEARDATA struct sysflag sysflags = DUMMY;
139 #endif
140 NEARDATA struct instance_flags iflags = DUMMY;
141 NEARDATA struct you u = DUMMY;
142 NEARDATA time_t ubirthday = DUMMY;
143 NEARDATA struct u_realtime urealtime = DUMMY;
144
145 schar lastseentyp[COLNO][ROWNO] = {
146     DUMMY
147 }; /* last seen/touched dungeon typ */
148
149 NEARDATA struct obj
150     *invent = (struct obj *) 0,
151     *uwep = (struct obj *) 0, *uarm = (struct obj *) 0,
152     *uswapwep = (struct obj *) 0,
153     *uquiver = (struct obj *) 0,       /* quiver */
154         *uarmu = (struct obj *) 0,     /* under-wear, so to speak */
155             *uskin = (struct obj *) 0, /* dragon armor, if a dragon */
156                 *uarmc = (struct obj *) 0, *uarmh = (struct obj *) 0,
157     *uarms = (struct obj *) 0, *uarmg = (struct obj *) 0,
158     *uarmf = (struct obj *) 0, *uamul = (struct obj *) 0,
159     *uright = (struct obj *) 0, *uleft = (struct obj *) 0,
160     *ublindf = (struct obj *) 0, *uchain = (struct obj *) 0,
161     *uball = (struct obj *) 0;
162 /* some objects need special handling during destruction or placement */
163 NEARDATA struct obj
164     *current_wand = 0,  /* wand currently zapped/applied */
165     *thrownobj = 0,     /* object in flight due to throwing */
166     *kickedobj = 0;     /* object in flight due to kicking */
167
168 #ifdef TEXTCOLOR
169 /*
170  *  This must be the same order as used for buzz() in zap.c.
171  */
172 const int zapcolors[NUM_ZAP] = {
173     HI_ZAP,     /* 0 - missile */
174     CLR_ORANGE, /* 1 - fire */
175     CLR_WHITE,  /* 2 - frost */
176     HI_ZAP,     /* 3 - sleep */
177     CLR_BLACK,  /* 4 - death */
178     CLR_WHITE,  /* 5 - lightning */
179     CLR_YELLOW, /* 6 - poison gas */
180     CLR_GREEN,  /* 7 - acid */
181 };
182 #endif /* text color */
183
184 const int shield_static[SHIELD_COUNT] = {
185     S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4, /* 7 per row */
186     S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
187     S_ss1, S_ss2, S_ss3, S_ss2, S_ss1, S_ss2, S_ss4,
188 };
189
190 NEARDATA struct spell spl_book[MAXSPELL + 1] = { DUMMY };
191
192 NEARDATA long moves = 1L, monstermoves = 1L;
193 /* These diverge when player is Fast */
194 NEARDATA long wailmsg = 0L;
195
196 /* objects that are moving to another dungeon level */
197 NEARDATA struct obj *migrating_objs = (struct obj *) 0;
198 /* objects not yet paid for */
199 NEARDATA struct obj *billobjs = (struct obj *) 0;
200
201 /* used to zero all elements of a struct obj and a struct monst */
202 NEARDATA const struct obj zeroobj = DUMMY;
203 NEARDATA const struct monst zeromonst = DUMMY;
204 /* used to zero out union any; initializer deliberately omitted */
205 NEARDATA const anything zeroany;
206
207 /* originally from dog.c */
208 NEARDATA char dogname[PL_PSIZ] = DUMMY;
209 NEARDATA char catname[PL_PSIZ] = DUMMY;
210 NEARDATA char horsename[PL_PSIZ] = DUMMY;
211 char preferred_pet; /* '\0', 'c', 'd', 'n' (none) */
212 /* monsters that went down/up together with @ */
213 NEARDATA struct monst *mydogs = (struct monst *) 0;
214 /* monsters that are moving to another dungeon level */
215 NEARDATA struct monst *migrating_mons = (struct monst *) 0;
216
217 NEARDATA struct mvitals mvitals[NUMMONS];
218 NEARDATA long domove_attempting = 0L;
219 NEARDATA long domove_succeeded = 0L;
220
221 #if 0 /*JP*/
222 NEARDATA struct c_color_names c_color_names = {
223     "black",  "amber", "golden", "light blue", "red",   "green",
224     "silver", "blue",  "purple", "white",      "orange"
225 };
226 #else
227 NEARDATA struct c_color_names c_color_names = {
228     "\8d\95\82¢",   "àæàß\90F\82Ì", "\8bà\90F\82Ì", "\90\85\90F\82Ì", "\90Ô\82¢", "\97Î\90F\82Ì",
229     "\8bâ\90F\82Ì", "\90Â\82¢",     "\8e\87\90F\82Ì", "\94\92\82¢",   "\9eò\90F\82Ì"
230 };
231 #endif
232
233 struct menucoloring *menu_colorings = NULL;
234
235 const char *c_obj_colors[] = {
236 #if 0 /*JP*/
237     "black",          /* CLR_BLACK */
238     "red",            /* CLR_RED */
239     "green",          /* CLR_GREEN */
240     "brown",          /* CLR_BROWN */
241     "blue",           /* CLR_BLUE */
242     "magenta",        /* CLR_MAGENTA */
243     "cyan",           /* CLR_CYAN */
244     "gray",           /* CLR_GRAY */
245     "transparent",    /* no_color */
246     "orange",         /* CLR_ORANGE */
247     "bright green",   /* CLR_BRIGHT_GREEN */
248     "yellow",         /* CLR_YELLOW */
249     "bright blue",    /* CLR_BRIGHT_BLUE */
250     "bright magenta", /* CLR_BRIGHT_MAGENTA */
251     "bright cyan",    /* CLR_BRIGHT_CYAN */
252     "white",          /* CLR_WHITE */
253 #else
254     "\8d\95\82¢",           /* CLR_BLACK */
255     "\90Ô\82¢",           /* CLR_RED */
256     "\97Î\90F\82Ì",         /* CLR_GREEN */
257     "\92\83\90F\82Ì",         /* CLR_BROWN */
258     "\90Â\82¢",           /* CLR_BLUE */
259     "\83}\83[\83\93\83^\90F\82Ì",   /* CLR_MAGENTA */
260     "\83V\83A\83\93\90F\82Ì",     /* CLR_CYAN */
261     "\8aD\90F\82Ì",         /* CLR_GRAY */
262     "\93§\96¾\82È",         /* no_color */
263     "\9eò\90F\82Ì",         /* CLR_ORANGE */
264     "\96¾\82é\82¢\97Î\90F\82Ì",   /* CLR_BRIGHT_GREEN */
265     "\89©\90F\82Ì",         /* CLR_YELLOW */
266     "\96¾\82é\82¢\90Â\90F\82Ì",   /* CLR_BRIGHT_BLUE */
267     "\96¾\82é\82¢\83}\83[\83\93\83^\90F\82Ì", /* CLR_BRIGHT_MAGENTA */
268     "\96¾\82é\82¢\83V\83A\83\93\90F\82Ì", /* CLR_BRIGHT_CYAN */
269     "\94\92\82¢",           /* CLR_WHITE */
270 #endif
271 };
272
273 #if 0 /*JP*/
274 struct c_common_strings c_common_strings = { "Nothing happens.",
275                                              "That's enough tries!",
276                                              "That is a silly thing to %s.",
277                                              "shudder for a moment.",
278                                              "something",
279                                              "Something",
280                                              "You can move again.",
281                                              "Never mind.",
282                                              "vision quickly clears.",
283                                              { "the", "your" } };
284 #else
285 struct c_common_strings c_common_strings = { "\89½\82à\8bN\82«\82È\82©\82Á\82½\81D",
286                                              "\82¢\82¢\89Á\8c¸\82É\82µ\82ë\81I",
287                                              "%s\81H\82»\82è\82á\82Î\82©\82°\82Ä\82¢\82é\81D",
288                                              "\88ê\8fu\90k\82¦\82½\81D",
289                                              "\89½\82©",
290                                              "\89½\82©",
291                                              "\82Ü\82½\93®\82¯\82é\82æ\82¤\82É\82È\82Á\82½\81D",
292                                              "\82¦\81H",
293                                              "\8e\8b\8aE\82ª\82Í\82Á\82«\82è\82µ\82½\81D",
294                                              { "", "\82 \82È\82½\82Ì" } };
295 #endif
296
297 /* NOTE: the order of these words exactly corresponds to the
298    order of oc_material values #define'd in objclass.h. */
299 #if 0 /*JP*/
300 const char *materialnm[] = { "mysterious", "liquid",  "wax",        "organic",
301                              "flesh",      "paper",   "cloth",      "leather",
302                              "wooden",     "bone",    "dragonhide", "iron",
303                              "metal",      "copper",  "silver",     "gold",
304                              "platinum",   "mithril", "plastic",    "glass",
305                              "gemstone",   "stone" };
306 #else
307 const char *materialnm[] = { "\90_\94é", "\89t\8fó", "\98X",   "\97L\8b@",
308                              "\93÷",   "\8e\86",   "\95z",   "\8av",
309                              "\96Ø",   "\8d\9c",   "\97³\94ç", "\93S",
310                              "\8bà\91®", "\93º",   "\94\92\8bâ", "\8bà",
311                              "\83v\83\89\83`\83i", "\83~\83X\83\8a\83\8b", "\83v\83\89\83X\83`\83b\83N", "\83K\83\89\83X",
312                              "\95ó\90Î", "\90Î" };
313 #endif
314
315 /* Vision */
316 NEARDATA boolean vision_full_recalc = 0;
317 NEARDATA char **viz_array = 0; /* used in cansee() and couldsee() macros */
318
319 /* Global windowing data, defined here for multi-window-system support */
320 NEARDATA winid WIN_MESSAGE = WIN_ERR;
321 NEARDATA winid WIN_STATUS = WIN_ERR;
322 NEARDATA winid WIN_MAP = WIN_ERR, WIN_INVEN = WIN_ERR;
323 char toplines[TBUFSZ];
324 /* Windowing stuff that's really tty oriented, but present for all ports */
325 struct tc_gbl_data tc_gbl_data = { 0, 0, 0, 0 }; /* AS,AE, LI,CO */
326
327 char *fqn_prefix[PREFIX_COUNT] = { (char *) 0, (char *) 0, (char *) 0,
328                                    (char *) 0, (char *) 0, (char *) 0,
329                                    (char *) 0, (char *) 0, (char *) 0,
330                                    (char *) 0 };
331                                    
332 #ifdef PREFIXES_IN_USE
333 char *fqn_prefix_names[PREFIX_COUNT] = {
334     "hackdir",  "leveldir", "savedir",    "bonesdir",  "datadir",
335     "scoredir", "lockdir",  "sysconfdir", "configdir", "troubledir"
336 };
337 #endif
338
339 NEARDATA struct savefile_info sfcap = {
340 #ifdef NHSTDC
341     0x00000000UL
342 #else
343     0x00000000L
344 #endif
345 #if defined(COMPRESS) || defined(ZLIB_COMP)
346         | SFI1_EXTERNALCOMP
347 #endif
348 #if defined(ZEROCOMP)
349         | SFI1_ZEROCOMP
350 #endif
351 #if defined(RLECOMP)
352         | SFI1_RLECOMP
353 #endif
354     ,
355 #ifdef NHSTDC
356     0x00000000UL, 0x00000000UL
357 #else
358     0x00000000L, 0x00000000L
359 #endif
360 };
361
362 NEARDATA struct savefile_info sfrestinfo, sfsaveinfo = {
363 #ifdef NHSTDC
364     0x00000000UL
365 #else
366     0x00000000L
367 #endif
368 #if defined(COMPRESS) || defined(ZLIB_COMP)
369         | SFI1_EXTERNALCOMP
370 #endif
371 #if defined(ZEROCOMP)
372         | SFI1_ZEROCOMP
373 #endif
374 #if defined(RLECOMP)
375         | SFI1_RLECOMP
376 #endif
377     ,
378 #ifdef NHSTDC
379     0x00000000UL, 0x00000000UL
380 #else
381     0x00000000L, 0x00000000L
382 #endif
383 };
384
385 struct plinemsg_type *plinemsg_types = (struct plinemsg_type *) 0;
386
387 #ifdef PANICTRACE
388 const char *ARGV0;
389 #endif
390
391 /* support for lint.h */
392 unsigned nhUse_dummy = 0;
393
394 /* dummy routine used to force linkage */
395 void
396 decl_init()
397 {
398     return;
399 }
400
401 /*decl.c*/