OSDN Git Service

[Refactor] #37353 floor-town.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 /*!
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 bool invoking_midnight_curse; /*!< 悪夢モード時の真夜中太古の呪い発生処理フラグ */
105
106 GAME_TURN old_battle;
107
108 bool use_sound;                 /* The "sound" mode is enabled */
109 bool use_music;                 /* The "music" mode is enabled */
110 bool use_graphics;              /* The "graphics" mode is enabled */
111 bool use_bigtile = FALSE;
112
113 s16b signal_count;              /* Hack -- Count interupts */
114
115 bool inkey_base;                /* See the "inkey()" function */
116 bool inkey_xtra;                /* See the "inkey()" function */
117 bool inkey_scan;                /* See the "inkey()" function */
118 bool inkey_flag;                /* See the "inkey()" function */
119 bool get_com_no_macros = FALSE; /* Expand macros in "get_com" or not */
120
121 OBJECT_SUBTYPE_VALUE coin_type; /* Hack -- force coin type */
122
123 bool opening_chest;             /* Hack -- prevent chest generation */
124
125 bool shimmer_monsters;  /* Hack -- optimize multi-hued monsters */
126 bool shimmer_objects;   /* Hack -- optimize multi-hued objects */
127
128 bool repair_monsters;   /* Hack -- optimize detect monsters */
129 bool repair_objects;    /* Hack -- optimize detect objects */
130
131 bool is_loading_now;    /*!< ロード直後にcalc_bonus()時の徳変化、及びsanity_blast()による異常を抑止する */
132
133 MONSTER_IDX hack_m_idx = 0;     /* Hack -- see "process_monsters()" */
134 MONSTER_IDX hack_m_idx_ii = 0;
135
136 bool multi_rew = FALSE;
137 char summon_kin_type;   /* Hack, by Julian Lighton: summon 'relatives' */
138
139 int total_friends = 0;
140 int leaving_quest = 0;
141 bool reinit_wilderness = FALSE;
142
143 /*
144  * Dungeon size info
145  */
146
147 POSITION panel_row_min, panel_row_max;
148 POSITION panel_col_min, panel_col_max;
149 POSITION panel_col_prt, panel_row_prt;
150
151
152 /*
153  * Targetting variables
154  */
155 MONSTER_IDX target_who;
156 POSITION target_col;
157 POSITION target_row;
158
159
160 /*
161  * User info
162  */
163 int player_uid;
164 int player_euid;
165 int player_egid;
166
167 /*
168  * Stripped version of "player_name"
169  */
170 char player_base[32];
171
172
173 /*
174  * Buffer to hold the current savefile name
175  * 'savefile' holds full path name. 'savefile_base' holds only base name.
176  */
177 char savefile[1024];
178 char savefile_base[40];
179
180
181 pos_list tmp_pos;
182
183
184 /*
185  * Number of active macros.
186  */
187 s16b macro__num;
188
189 /*
190  * Array of macro patterns [MACRO_MAX]
191  */
192 concptr *macro__pat;
193
194 /*
195  * Array of macro actions [MACRO_MAX]
196  */
197 concptr *macro__act;
198
199 /*
200  * Array of macro types [MACRO_MAX]
201  */
202 bool *macro__cmd;
203
204 /*
205  * Current macro action [1024]
206  */
207 char *macro__buf;
208
209
210 /*
211  * The number of quarks
212  */
213 STR_OFFSET quark__num;
214
215 /*
216  * The pointers to the quarks [QUARK_MAX]
217  */
218 concptr *quark__str;
219
220
221 /*
222  * The next "free" index to use
223  */
224 u32b message__next;
225
226 /*
227  * The index of the oldest message (none yet)
228  */
229 u32b message__last;
230
231 /*
232  * The next "free" offset
233  */
234 u32b message__head;
235
236 /*
237  * The offset to the oldest used char (none yet)
238  */
239 u32b message__tail;
240
241 /*
242  * The array of offsets, by index [MESSAGE_MAX]
243  */
244 u32b *message__ptr;
245
246 /*
247  * The array of chars, by offset [MESSAGE_BUF]
248  */
249 char *message__buf;
250
251 BIT_FLAGS option_flag[8]; //!< The array of normal options
252 BIT_FLAGS option_mask[8]; //!< The array of normal options
253 BIT_FLAGS window_flag[8]; //!< The array of window options
254 BIT_FLAGS window_mask[8]; //!< The array of window options
255
256 /*
257  * The array of window pointers
258  */
259 term *angband_term[8];
260
261 /*
262  * Standard window names
263  */
264 const char angband_term_name[8][16] =
265 {
266         "Hengband",
267         "Term-1",
268         "Term-2",
269         "Term-3",
270         "Term-4",
271         "Term-5",
272         "Term-6",
273         "Term-7"
274 };
275
276
277 /*
278  * Global table of color definitions
279  */
280 byte angband_color_table[256][4] =
281 {
282         {0x00, 0x00, 0x00, 0x00},       /* TERM_DARK */
283         {0x00, 0xFF, 0xFF, 0xFF},       /* TERM_WHITE */
284         {0x00, 0x80, 0x80, 0x80},       /* TERM_SLATE */
285         {0x00, 0xFF, 0x80, 0x00},       /* TERM_ORANGE */
286         {0x00, 0xC0, 0x00, 0x00},       /* TERM_RED */
287         {0x00, 0x00, 0x80, 0x40},       /* TERM_GREEN */
288         {0x00, 0x00, 0x00, 0xFF},       /* TERM_BLUE */
289         {0x00, 0x80, 0x40, 0x00},       /* TERM_UMBER */
290         {0x00, 0x40, 0x40, 0x40},       /* TERM_L_DARK */
291         {0x00, 0xC0, 0xC0, 0xC0},       /* TERM_L_WHITE */
292         {0x00, 0xFF, 0x00, 0xFF},       /* TERM_VIOLET */
293         {0x00, 0xFF, 0xFF, 0x00},       /* TERM_YELLOW */
294         {0x00, 0xFF, 0x00, 0x00},       /* TERM_L_RED */
295         {0x00, 0x00, 0xFF, 0x00},       /* TERM_L_GREEN */
296         {0x00, 0x00, 0xFF, 0xFF},       /* TERM_L_BLUE */
297         {0x00, 0xC0, 0x80, 0x40}        /* TERM_L_UMBER */
298 };
299
300
301 /*
302  * Standard sound names
303  */
304 const concptr angband_sound_name[SOUND_MAX] =
305 {
306         "dummy",
307         "hit",
308         "miss",
309         "flee",
310         "drop",
311         "kill",
312         "level",
313         "death",
314         "study",
315         "teleport",
316         "shoot",
317         "quaff",
318         "zap",
319         "walk",
320         "tpother",
321         "hitwall",
322         "eat",
323         "store1",
324         "store2",
325         "store3",
326         "store4",
327         "dig",
328         "opendoor",
329         "shutdoor",
330         "tplevel",
331         "scroll",
332         "buy",
333         "sell",
334         "warn",
335         "rocket",
336         "n_kill",
337         "u_kill",
338         "quest",
339         "heal",
340         "x_heal",
341         "bite",
342         "claw",
343         "m_spell",
344         "summon",
345         "breath",
346         "ball",
347         "m_heal",
348         "atkspell",
349         "evil",
350         "touch",
351         "sting",
352         "crush",
353         "slime",
354         "wail",
355         "winner",
356         "fire",
357         "acid",
358         "elec",
359         "cold",
360         "illegal",
361         "fail",
362         "wakeup",
363         "invuln",
364         "fall",
365         "pain",
366         "destitem",
367         "moan",
368         "show",
369         "unused",
370         "explode",
371         "glass",
372         "reflect",
373 };
374
375 /*
376  * Standard music names
377  */
378 const concptr angband_music_basic_name[MUSIC_BASIC_MAX] =
379 {
380         "default",
381         "gameover",
382         "exit",
383         "town",
384         "field1",
385         "field2",
386         "field3",
387         "dun_low",
388         "dun_med",
389         "dun_high",
390         "feel1",
391         "feel2",
392         "winner",
393         "build",
394         "wild",
395         "quest",
396         "arena",
397         "battle",
398         "quest_clear",
399         "final_quest_clear",
400         "ambush",
401 };
402
403
404 /*
405  * Number of floor_id used from birth
406  */
407 FLOOR_IDX max_floor_id;
408
409 /*
410  * Sign for current process used in temporal files.
411  * Actually it is the start time of current process.
412  */
413 u32b saved_floor_file_sign;
414
415 /*
416  * The size of "alloc_kind_table" (at most max_k_idx * 4)
417  */
418 s16b alloc_kind_size;
419
420 /*
421  * The entries in the "kind allocator table"
422  */
423 alloc_entry *alloc_kind_table;
424
425
426 /*
427  * The size of "alloc_race_table" (at most max_r_idx)
428  */
429 s16b alloc_race_size;
430
431 /*
432  * The entries in the "race allocator table"
433  */
434 alloc_entry *alloc_race_table;
435
436
437 /*
438  * Specify attr/char pairs for visual special effects
439  * Be sure to use "index & 0x7F" to avoid illegal access
440  */
441 TERM_COLOR misc_to_attr[256];
442 SYMBOL_CODE misc_to_char[256];
443
444
445 /*
446  * Specify attr/char pairs for p_ptr->inventory_list items (by tval)
447  * Be sure to use "index & 0x7F" to avoid illegal access
448  */
449 TERM_COLOR tval_to_attr[128];
450 SYMBOL_CODE tval_to_char[128];
451
452
453 /*
454  * Keymaps for each "mode" associated with each keypress.
455  */
456 concptr keymap_act[KEYMAP_MODES][256];
457
458
459
460 /*** Player information ***/
461
462 /*
463  * Static player info record
464  */
465 player_type p_body;
466
467 /*
468  * Pointer to the player info
469  */
470 player_type *p_ptr = &p_body;
471
472 /*
473  * Pointer to the player tables
474  * (sex, race, class, magic)
475  */
476 const player_sex *sp_ptr;
477 const player_race *rp_ptr;
478 const player_seikaku *ap_ptr;
479
480
481 /*
482  * The last character rolled,
483  * holded for quick start
484  */
485 birther previous_char;
486
487 concptr ANGBAND_SYS = "xxx"; //!< Hack -- The special Angband "System Suffix" This variable is used to choose an appropriate "pref-xxx" file
488
489
490 #ifdef JP
491 concptr ANGBAND_KEYBOARD = "JAPAN"; //!< Hack -- The special Angband "Keyboard Suffix" This variable is used to choose an appropriate macro-trigger definition
492 #else
493 concptr ANGBAND_KEYBOARD = "0";
494 #endif
495
496 concptr ANGBAND_GRAF = "ascii"; //!< Hack -- The special Angband "Graphics Suffix" This variable is used to choose an appropriate "graf-xxx" file
497 concptr ANGBAND_DIR; //!< Path name: The main "lib" directory This variable is not actually used anywhere in the code
498 concptr ANGBAND_DIR_APEX; //!< High score files (binary) These files may be portable between platforms
499 concptr ANGBAND_DIR_BONE; //!< Bone files for player ghosts (ascii) These files are portable between platforms
500 concptr ANGBAND_DIR_DATA; //!< Binary image files for the "*_info" arrays (binary) These files are not portable between platforms
501 concptr ANGBAND_DIR_EDIT; //!< Textual template files for the "*_info" arrays (ascii) These files are portable between platforms
502 concptr ANGBAND_DIR_SCRIPT; //!< Script files These files are portable between platforms.
503 concptr ANGBAND_DIR_FILE; //!< Various extra files (ascii) These files may be portable between platforms
504 concptr ANGBAND_DIR_HELP; //!< Help files (normal) for the online help (ascii) These files are portable between platforms
505 concptr ANGBAND_DIR_INFO; //!< Help files (spoilers) for the online help (ascii) These files are portable between platforms
506 concptr ANGBAND_DIR_PREF; //!< Default user "preference" files (ascii) These files are rarely portable between platforms
507 concptr ANGBAND_DIR_SAVE; //!< Savefiles for current characters (binary)
508 concptr ANGBAND_DIR_USER; //!< User "preference" files (ascii) These files are rarely portable between platforms
509 concptr ANGBAND_DIR_XTRA; //!< Various extra files (binary) These files are rarely portable between platforms
510
511
512 /*
513  * Here is a "pseudo-hook" used during calls to "get_item()" and
514  * "show_inven()" and "show_equip()", and the choice window routines.
515  */
516 OBJECT_TYPE_VALUE item_tester_tval;
517
518
519 /*
520  * Here is a "hook" used during calls to "get_item()" and
521  * "show_inven()" and "show_equip()", and the choice window routines.
522  */
523 bool (*item_tester_hook)(object_type*);
524
525
526
527
528 /*
529  * Hack -- function hooks to restrict "get_mon_num_prep()" function
530  */
531 monsterrace_hook_type get_mon_num_hook;
532 monsterrace_hook_type get_mon_num2_hook;
533
534
535 /*
536  * Hack -- function hook to restrict "get_obj_num_prep()" function
537  */
538 bool (*get_obj_num_hook)(KIND_OBJECT_IDX k_idx);
539
540 /*
541  * Maximum number of quests
542  */
543 QUEST_IDX max_q_idx;
544
545 /*
546  * Maximum number of monsters in r_info.txt
547  */
548 MONRACE_IDX max_r_idx;
549
550 /*
551  * Maximum number of items in k_info.txt
552  */
553 KIND_OBJECT_IDX max_k_idx;
554
555 /*
556  * Maximum number of vaults in v_info.txt
557  */
558 VAULT_IDX max_v_idx;
559
560 /*
561  * Maximum number of terrain features in f_info.txt
562  */
563 FEAT_IDX max_f_idx;
564
565 /*
566  * Maximum number of artifacts in a_info.txt
567  */
568 ARTIFACT_IDX max_a_idx;
569
570 /*
571  * Maximum number of ego-items in e_info.txt
572  */
573 EGO_IDX max_e_idx;
574
575 /*
576  * Maximum number of dungeon in e_info.txt
577  */
578 DUNGEON_IDX max_d_idx;
579
580
581 /*
582  * Quest text
583  */
584 char quest_text[10][80];
585
586 /*
587  * Current line of the quest text
588  */
589 int quest_text_line;
590
591 /*
592  * Flags for initialization
593  */
594 int init_flags;
595
596
597 /*
598  * The "highscore" file descriptor, if available.
599  */
600 int highscore_fd = -1;
601
602 bool can_save = FALSE;        /* Game can be saved */
603
604
605 int cap_mon;
606 int cap_mspeed;
607 HIT_POINT cap_hp;
608 HIT_POINT cap_maxhp;
609 STR_OFFSET cap_nickname;
610
611 MONRACE_IDX battle_mon[4];
612 int sel_monster;
613 int battle_odds;
614 PRICE kakekin;
615 u32b mon_odds[4];
616
617 MONSTER_IDX pet_t_m_idx;
618 MONSTER_IDX riding_t_m_idx;
619
620 MONSTER_IDX today_mon;
621
622 bool write_level;
623
624 u32b start_time;
625
626 bool sukekaku;
627 bool new_mane;
628
629 bool mon_fight;
630
631 bool generate_encounter;
632
633 concptr screen_dump = NULL;
634
635
636 /*
637  * Which dungeon ?
638  */
639 DEPTH *max_dlv;
640
641 FEAT_IDX feat_wall_outer;
642 FEAT_IDX feat_wall_inner;
643 FEAT_IDX feat_wall_solid;
644 FEAT_IDX feat_ground_type[100], feat_wall_type[100];
645
646 COMMAND_CODE now_message;
647 bool use_menu;
648
649 #ifdef CHUUKEI
650 bool chuukei_server;
651 bool chuukei_client;
652 char *server_name;
653 int server_port;
654 #endif
655
656 /* for movie */
657 bool browsing_movie;
658
659
660 /* for snipers */
661 bool reset_concent = FALSE;   /* Concentration reset flag */
662 bool is_fired = FALSE;
663