OSDN Git Service

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