OSDN Git Service

[Refactor] #37353 コピーライト情報 を core.c/h へ移動.
[hengband/hengband.git] / src / variable.c
1 /*!
2  * @file variable.c
3  * @brief グローバル変数定義 / Angband variables
4  * @date 2014/10/05
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke<br>
7  * <br>
8  * This software may be copied and distributed for educational, research,<br>
9  * and not for profit purposes provided that this copyright and statement<br>
10  * are included in all such copies.  Other copyrights may also apply.<br>
11  */
12
13 #include "angband.h"
14 #include "geometry.h"
15
16 int max_macrotrigger = 0; /*!< 現在登録中のマクロ(トリガー)の数 */
17 concptr macro_template = NULL; /*!< Angband設定ファイルのT: タグ情報から読み込んだ長いTコードを処理するために利用する文字列ポインタ */
18 concptr macro_modifier_chr; /*!< &x# で指定されるマクロトリガーに関する情報を記録する文字列ポインタ */
19 concptr macro_modifier_name[MAX_MACRO_MOD]; /*!< マクロ上で取り扱う特殊キーを文字列上で表現するためのフォーマットを記録した文字列ポインタ配列 */
20 concptr macro_trigger_name[MAX_MACRO_TRIG]; /*!< マクロのトリガーコード */
21 concptr macro_trigger_keycode[2][MAX_MACRO_TRIG];  /*!< マクロの内容 */
22
23 int level_up = 0; /*!< レベルアップの際に遅延してcalc_mana()関数上で上昇量を表示するかどうかの判定フラグ */
24
25 /*
26  * Various things
27  */
28 bool character_generated;       /* The character exists */
29 bool character_dungeon;         /* The character has a dungeon */
30 bool character_loaded;          /* The character was loaded from a savefile */
31 bool character_saved;           /* The character was just saved to a savefile */
32
33 bool character_icky;            /* The game is in an icky full screen mode */
34 bool character_xtra;            /* The game is in an icky startup mode */
35
36 bool creating_savefile;         /* New savefile is currently created */
37
38 s16b command_cmd;               /* Current "Angband Command" */
39
40 COMMAND_ARG command_arg;        /*!< 各種コマンドの汎用的な引数として扱う / Gives argument of current command */
41 COMMAND_NUM command_rep;        /*!< 各種コマンドの汎用的なリピート数として扱う / Gives repetition of current command */
42 DIRECTION command_dir;          /*!< 各種コマンドの汎用的な方向値処理として扱う/ Gives direction of current command */
43
44 s16b command_see;               /* See "object1.c" */
45 s16b command_wrk;               /* See "object1.c" */
46
47 TERM_LEN command_gap = 999;         /* See "object1.c" */
48
49 s16b command_new;               /* Command chaining from inven/equip view */
50
51 bool msg_flag;                  /* Used in msg_print() for "buffering" */
52
53 s16b running;                   /* Current counter for running, if any */
54
55 GAME_TURN old_battle;
56
57 s16b signal_count;              /* Hack -- Count interupts */
58
59 bool inkey_base;                /* See the "inkey()" function */
60 bool inkey_xtra;                /* See the "inkey()" function */
61 bool inkey_scan;                /* See the "inkey()" function */
62 bool inkey_flag;                /* See the "inkey()" function */
63 bool get_com_no_macros = FALSE; /* Expand macros in "get_com" or not */
64
65 OBJECT_SUBTYPE_VALUE coin_type; /* Hack -- force coin type */
66
67 bool opening_chest;             /* Hack -- prevent chest generation */
68
69 bool shimmer_monsters;  /* Hack -- optimize multi-hued monsters */
70 bool shimmer_objects;   /* Hack -- optimize multi-hued objects */
71
72 bool repair_monsters;   /* Hack -- optimize detect monsters */
73 bool repair_objects;    /* Hack -- optimize detect objects */
74
75 MONSTER_IDX hack_m_idx = 0;     /* Hack -- see "process_monsters()" */
76 MONSTER_IDX hack_m_idx_ii = 0;
77
78 bool multi_rew = FALSE;
79
80 int total_friends = 0;
81 int leaving_quest = 0;
82 bool reinit_wilderness = FALSE;
83
84 /*
85  * Dungeon size info
86  */
87
88 POSITION panel_row_min, panel_row_max;
89 POSITION panel_col_min, panel_col_max;
90 POSITION panel_col_prt, panel_row_prt;
91
92
93 /*
94  * Targetting variables
95  */
96 MONSTER_IDX target_who;
97 POSITION target_col;
98 POSITION target_row;
99
100
101 /*
102  * User info
103  */
104 int player_uid;
105 int player_euid;
106 int player_egid;
107
108 /*
109  * Stripped version of "player_name"
110  */
111 char player_base[32];
112
113
114 /*
115  * Buffer to hold the current savefile name
116  * 'savefile' holds full path name. 'savefile_base' holds only base name.
117  */
118 char savefile[1024];
119 char savefile_base[40];
120
121
122 pos_list tmp_pos;
123
124
125 /*
126  * Number of active macros.
127  */
128 s16b macro__num;
129
130 /*
131  * Array of macro patterns [MACRO_MAX]
132  */
133 concptr *macro__pat;
134
135 /*
136  * Array of macro actions [MACRO_MAX]
137  */
138 concptr *macro__act;
139
140 /*
141  * Array of macro types [MACRO_MAX]
142  */
143 bool *macro__cmd;
144
145 /*
146  * Current macro action [1024]
147  */
148 char *macro__buf;
149
150
151 /*
152  * The number of quarks
153  */
154 STR_OFFSET quark__num;
155
156 /*
157  * The pointers to the quarks [QUARK_MAX]
158  */
159 concptr *quark__str;
160
161 BIT_FLAGS option_flag[8]; //!< The array of normal options
162 BIT_FLAGS option_mask[8]; //!< The array of normal options
163 BIT_FLAGS window_flag[8]; //!< The array of window options
164 BIT_FLAGS window_mask[8]; //!< The array of window options
165
166 /*
167  * The array of window pointers
168  */
169 term *angband_term[8];
170
171 /*
172  * Standard window names
173  */
174 const char angband_term_name[8][16] =
175 {
176         "Hengband",
177         "Term-1",
178         "Term-2",
179         "Term-3",
180         "Term-4",
181         "Term-5",
182         "Term-6",
183         "Term-7"
184 };
185
186
187 /*
188  * Global table of color definitions
189  */
190 byte angband_color_table[256][4] =
191 {
192         {0x00, 0x00, 0x00, 0x00},       /* TERM_DARK */
193         {0x00, 0xFF, 0xFF, 0xFF},       /* TERM_WHITE */
194         {0x00, 0x80, 0x80, 0x80},       /* TERM_SLATE */
195         {0x00, 0xFF, 0x80, 0x00},       /* TERM_ORANGE */
196         {0x00, 0xC0, 0x00, 0x00},       /* TERM_RED */
197         {0x00, 0x00, 0x80, 0x40},       /* TERM_GREEN */
198         {0x00, 0x00, 0x00, 0xFF},       /* TERM_BLUE */
199         {0x00, 0x80, 0x40, 0x00},       /* TERM_UMBER */
200         {0x00, 0x40, 0x40, 0x40},       /* TERM_L_DARK */
201         {0x00, 0xC0, 0xC0, 0xC0},       /* TERM_L_WHITE */
202         {0x00, 0xFF, 0x00, 0xFF},       /* TERM_VIOLET */
203         {0x00, 0xFF, 0xFF, 0x00},       /* TERM_YELLOW */
204         {0x00, 0xFF, 0x00, 0x00},       /* TERM_L_RED */
205         {0x00, 0x00, 0xFF, 0x00},       /* TERM_L_GREEN */
206         {0x00, 0x00, 0xFF, 0xFF},       /* TERM_L_BLUE */
207         {0x00, 0xC0, 0x80, 0x40}        /* TERM_L_UMBER */
208 };
209
210
211 /*
212  * Standard sound names
213  */
214 const concptr angband_sound_name[SOUND_MAX] =
215 {
216         "dummy",
217         "hit",
218         "miss",
219         "flee",
220         "drop",
221         "kill",
222         "level",
223         "death",
224         "study",
225         "teleport",
226         "shoot",
227         "quaff",
228         "zap",
229         "walk",
230         "tpother",
231         "hitwall",
232         "eat",
233         "store1",
234         "store2",
235         "store3",
236         "store4",
237         "dig",
238         "opendoor",
239         "shutdoor",
240         "tplevel",
241         "scroll",
242         "buy",
243         "sell",
244         "warn",
245         "rocket",
246         "n_kill",
247         "u_kill",
248         "quest",
249         "heal",
250         "x_heal",
251         "bite",
252         "claw",
253         "m_spell",
254         "summon",
255         "breath",
256         "ball",
257         "m_heal",
258         "atkspell",
259         "evil",
260         "touch",
261         "sting",
262         "crush",
263         "slime",
264         "wail",
265         "winner",
266         "fire",
267         "acid",
268         "elec",
269         "cold",
270         "illegal",
271         "fail",
272         "wakeup",
273         "invuln",
274         "fall",
275         "pain",
276         "destitem",
277         "moan",
278         "show",
279         "unused",
280         "explode",
281         "glass",
282         "reflect",
283 };
284
285 /*
286  * Standard music names
287  */
288 const concptr angband_music_basic_name[MUSIC_BASIC_MAX] =
289 {
290         "default",
291         "gameover",
292         "exit",
293         "town",
294         "field1",
295         "field2",
296         "field3",
297         "dun_low",
298         "dun_med",
299         "dun_high",
300         "feel1",
301         "feel2",
302         "winner",
303         "build",
304         "wild",
305         "quest",
306         "arena",
307         "battle",
308         "quest_clear",
309         "final_quest_clear",
310         "ambush",
311 };
312
313
314 /*
315  * Number of floor_id used from birth
316  */
317 FLOOR_IDX max_floor_id;
318
319 /*
320  * Sign for current process used in temporal files.
321  * Actually it is the start time of current process.
322  */
323 u32b saved_floor_file_sign;
324
325
326 /*
327  * Keymaps for each "mode" associated with each keypress.
328  */
329 concptr keymap_act[KEYMAP_MODES][256];
330
331
332
333 /*** Player information ***/
334
335 /*
336  * Static player info record
337  */
338 player_type p_body;
339
340 /*
341  * Pointer to the player info
342  */
343 player_type *p_ptr = &p_body;
344
345
346 /*
347  * Here is a "pseudo-hook" used during calls to "get_item()" and
348  * "show_inven()" and "show_equip()", and the choice window routines.
349  */
350 OBJECT_TYPE_VALUE item_tester_tval;
351
352
353 /*
354  * Here is a "hook" used during calls to "get_item()" and
355  * "show_inven()" and "show_equip()", and the choice window routines.
356  */
357 bool (*item_tester_hook)(object_type*);
358
359
360
361
362 /*
363  * Hack -- function hooks to restrict "get_mon_num_prep()" function
364  */
365 monsterrace_hook_type get_mon_num_hook;
366 monsterrace_hook_type get_mon_num2_hook;
367
368
369 /*
370  * Hack -- function hook to restrict "get_obj_num_prep()" function
371  */
372 bool (*get_obj_num_hook)(KIND_OBJECT_IDX k_idx);
373
374 /*
375  * Maximum number of vaults in v_info.txt
376  */
377 VAULT_IDX max_v_idx;
378
379 /*
380  * Maximum number of terrain features in f_info.txt
381  */
382 FEAT_IDX max_f_idx;
383
384 /*
385  * Maximum number of ego-items in e_info.txt
386  */
387 EGO_IDX max_e_idx;
388
389 /*
390  * Maximum number of dungeon in e_info.txt
391  */
392 DUNGEON_IDX max_d_idx;
393
394 /*
395  * Flags for initialization
396  */
397 int init_flags;
398
399
400 /*
401  * The "highscore" file descriptor, if available.
402  */
403 int highscore_fd = -1;
404
405 bool can_save = FALSE;        /* Game can be saved */
406
407
408 int cap_mon;
409 int cap_mspeed;
410 HIT_POINT cap_hp;
411 HIT_POINT cap_maxhp;
412 STR_OFFSET cap_nickname;
413
414 MONRACE_IDX battle_mon[4];
415 int sel_monster;
416 int battle_odds;
417 PRICE kakekin;
418 u32b mon_odds[4];
419
420 MONSTER_IDX pet_t_m_idx;
421 MONSTER_IDX riding_t_m_idx;
422
423 MONSTER_IDX today_mon;
424
425 bool write_level;
426
427 u32b start_time;
428
429 bool sukekaku;
430 bool new_mane;
431
432 bool mon_fight;
433
434 bool generate_encounter;
435
436 concptr screen_dump = NULL;
437
438
439 /*
440  * Which dungeon ?
441  */
442 DEPTH *max_dlv;
443
444 COMMAND_CODE now_message;
445 bool use_menu;
446
447 #ifdef CHUUKEI
448 bool chuukei_server;
449 bool chuukei_client;
450 char *server_name;
451 int server_port;
452 #endif
453
454 /* for movie */
455 bool browsing_movie;
456
457
458 /* for snipers */
459 bool reset_concent = FALSE;   /* Concentration reset flag */
460 bool is_fired = FALSE;
461