OSDN Git Service

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