OSDN Git Service

[Refactor] #37353 a_info と artifact_type 構造体を artifact.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  * 自動拾い/破壊設定のリストに関する変数 / List for auto-picker/destroyer entries
41  */
42 int max_autopick = 0; /*!< 現在登録している自動拾い/破壊設定の数 */
43 int max_max_autopick = 0; /*!< 自動拾い/破壊設定の限界数 */
44 autopick_type *autopick_list = NULL; /*!< 自動拾い/破壊設定構造体のポインタ配列 */
45
46 /*
47  * Savefile version
48  */
49 byte h_ver_major; /* Savefile version for Hengband 1.1.1 and later */
50 byte h_ver_minor;
51 byte h_ver_patch;
52 byte h_ver_extra;
53
54 byte sf_extra;          /* Savefile's encoding key */
55
56 byte z_major;           /* Savefile version for Hengband */
57 byte z_minor;
58 byte z_patch;
59
60 /*
61  * Savefile information
62  */
63 u32b sf_system;                 /* Operating system info */
64 u32b sf_when;                   /* Time when savefile created */
65 u16b sf_lives;                  /* Number of past "lives" with this file */
66 u16b sf_saves;                  /* Number of "saves" during this life */
67
68 /*
69  * Run-time arguments
70  */
71 bool arg_fiddle;                        /* Command arg -- Request fiddle mode */
72 bool arg_wizard;                        /* Command arg -- Request wizard mode */
73 bool arg_sound;                         /* Command arg -- Request special sounds */
74 bool arg_music;                         /* Command arg -- Request special musics */
75 byte arg_graphics;                      /* Command arg -- Request graphics mode */
76 bool arg_monochrome;            /* Command arg -- Request monochrome mode */
77 bool arg_force_original;        /* Command arg -- Request original keyset */
78 bool arg_force_roguelike;       /* Command arg -- Request roguelike keyset */
79 bool arg_bigtile = FALSE;       /* Command arg -- Request big tile mode */
80
81 /*
82  * Various things
83  */
84 bool character_generated;       /* The character exists */
85 bool character_dungeon;         /* The character has a dungeon */
86 bool character_loaded;          /* The character was loaded from a savefile */
87 bool character_saved;           /* The character was just saved to a savefile */
88
89 bool character_icky;            /* The game is in an icky full screen mode */
90 bool character_xtra;            /* The game is in an icky startup mode */
91
92 bool creating_savefile;         /* New savefile is currently created */
93
94 u32b seed_flavor;               /* Hack -- consistent object colors */
95 u32b seed_town;                 /* Hack -- consistent town layout */
96
97 s16b command_cmd;               /* Current "Angband Command" */
98
99 COMMAND_ARG command_arg;        /*!< 各種コマンドの汎用的な引数として扱う / Gives argument of current command */
100 COMMAND_NUM command_rep;        /*!< 各種コマンドの汎用的なリピート数として扱う / Gives repetition of current command */
101 DIRECTION command_dir;          /*!< 各種コマンドの汎用的な方向値処理として扱う/ Gives direction of current command */
102
103 s16b command_see;               /* See "object1.c" */
104 s16b command_wrk;               /* See "object1.c" */
105
106 TERM_LEN command_gap = 999;         /* See "object1.c" */
107
108 s16b command_new;               /* Command chaining from inven/equip view */
109
110 bool msg_flag;                  /* Used in msg_print() for "buffering" */
111
112 s16b running;                   /* Current counter for running, if any */
113
114 bool invoking_midnight_curse; /*!< 悪夢モード時の真夜中太古の呪い発生処理フラグ */
115
116 GAME_TURN old_battle;
117
118 bool use_sound;                 /* The "sound" mode is enabled */
119 bool use_music;                 /* The "music" mode is enabled */
120 bool use_graphics;              /* The "graphics" mode is enabled */
121 bool use_bigtile = FALSE;
122
123 s16b signal_count;              /* Hack -- Count interupts */
124
125 bool inkey_base;                /* See the "inkey()" function */
126 bool inkey_xtra;                /* See the "inkey()" function */
127 bool inkey_scan;                /* See the "inkey()" function */
128 bool inkey_flag;                /* See the "inkey()" function */
129 bool get_com_no_macros = FALSE; /* Expand macros in "get_com" or not */
130
131 OBJECT_SUBTYPE_VALUE coin_type; /* Hack -- force coin type */
132
133 bool opening_chest;             /* Hack -- prevent chest generation */
134
135 bool shimmer_monsters;  /* Hack -- optimize multi-hued monsters */
136 bool shimmer_objects;   /* Hack -- optimize multi-hued objects */
137
138 bool repair_monsters;   /* Hack -- optimize detect monsters */
139 bool repair_objects;    /* Hack -- optimize detect objects */
140
141 bool is_loading_now;    /*!< ロード直後にcalc_bonus()時の徳変化、及びsanity_blast()による異常を抑止する */
142 bool hack_mutation;
143
144 s16b inven_cnt; /* Number of items in inventory */
145 s16b equip_cnt; /* Number of items in equipment */
146
147 OBJECT_IDX o_max = 1; /* Number of allocated objects */
148 OBJECT_IDX o_cnt = 0; /* Number of live objects */
149
150 MONSTER_IDX m_max = 1; /* Number of allocated monsters */
151 MONSTER_IDX m_cnt = 0; /* Number of live monsters */
152
153 MONSTER_IDX hack_m_idx = 0;     /* Hack -- see "process_monsters()" */
154 MONSTER_IDX hack_m_idx_ii = 0;
155
156 bool multi_rew = FALSE;
157 char summon_kin_type;   /* Hack, by Julian Lighton: summon 'relatives' */
158
159 int total_friends = 0;
160 int leaving_quest = 0;
161 bool reinit_wilderness = FALSE;
162
163
164
165 /*
166  * Dungeon variables
167  */
168
169 bool closing_flag;              /* Dungeon is closing */
170
171
172 /*
173  * Dungeon size info
174  */
175
176 POSITION panel_row_min, panel_row_max;
177 POSITION panel_col_min, panel_col_max;
178 POSITION panel_col_prt, panel_row_prt;
179
180
181 /*
182  * Targetting variables
183  */
184 MONSTER_IDX target_who;
185 POSITION target_col;
186 POSITION target_row;
187
188
189 /*
190  * User info
191  */
192 int player_uid;
193 int player_euid;
194 int player_egid;
195
196 /*
197  * Stripped version of "player_name"
198  */
199 char player_base[32];
200
201
202 /*
203  * Buffer to hold the current savefile name
204  * 'savefile' holds full path name. 'savefile_base' holds only base name.
205  */
206 char savefile[1024];
207 char savefile_base[40];
208
209
210 pos_list tmp_pos;
211
212
213 /*
214  * Number of active macros.
215  */
216 s16b macro__num;
217
218 /*
219  * Array of macro patterns [MACRO_MAX]
220  */
221 concptr *macro__pat;
222
223 /*
224  * Array of macro actions [MACRO_MAX]
225  */
226 concptr *macro__act;
227
228 /*
229  * Array of macro types [MACRO_MAX]
230  */
231 bool *macro__cmd;
232
233 /*
234  * Current macro action [1024]
235  */
236 char *macro__buf;
237
238
239 /*
240  * The number of quarks
241  */
242 STR_OFFSET quark__num;
243
244 /*
245  * The pointers to the quarks [QUARK_MAX]
246  */
247 concptr *quark__str;
248
249
250 /*
251  * The next "free" index to use
252  */
253 u32b message__next;
254
255 /*
256  * The index of the oldest message (none yet)
257  */
258 u32b message__last;
259
260 /*
261  * The next "free" offset
262  */
263 u32b message__head;
264
265 /*
266  * The offset to the oldest used char (none yet)
267  */
268 u32b message__tail;
269
270 /*
271  * The array of offsets, by index [MESSAGE_MAX]
272  */
273 u32b *message__ptr;
274
275 /*
276  * The array of chars, by offset [MESSAGE_BUF]
277  */
278 char *message__buf;
279
280 BIT_FLAGS option_flag[8]; //!< The array of normal options
281 BIT_FLAGS option_mask[8]; //!< The array of normal options
282 BIT_FLAGS window_flag[8]; //!< The array of window options
283 BIT_FLAGS window_mask[8]; //!< The array of window options
284
285 /*
286  * The array of window pointers
287  */
288 term *angband_term[8];
289
290 /*
291  * Standard window names
292  */
293 const char angband_term_name[8][16] =
294 {
295         "Hengband",
296         "Term-1",
297         "Term-2",
298         "Term-3",
299         "Term-4",
300         "Term-5",
301         "Term-6",
302         "Term-7"
303 };
304
305
306 /*
307  * Global table of color definitions
308  */
309 byte angband_color_table[256][4] =
310 {
311         {0x00, 0x00, 0x00, 0x00},       /* TERM_DARK */
312         {0x00, 0xFF, 0xFF, 0xFF},       /* TERM_WHITE */
313         {0x00, 0x80, 0x80, 0x80},       /* TERM_SLATE */
314         {0x00, 0xFF, 0x80, 0x00},       /* TERM_ORANGE */
315         {0x00, 0xC0, 0x00, 0x00},       /* TERM_RED */
316         {0x00, 0x00, 0x80, 0x40},       /* TERM_GREEN */
317         {0x00, 0x00, 0x00, 0xFF},       /* TERM_BLUE */
318         {0x00, 0x80, 0x40, 0x00},       /* TERM_UMBER */
319         {0x00, 0x40, 0x40, 0x40},       /* TERM_L_DARK */
320         {0x00, 0xC0, 0xC0, 0xC0},       /* TERM_L_WHITE */
321         {0x00, 0xFF, 0x00, 0xFF},       /* TERM_VIOLET */
322         {0x00, 0xFF, 0xFF, 0x00},       /* TERM_YELLOW */
323         {0x00, 0xFF, 0x00, 0x00},       /* TERM_L_RED */
324         {0x00, 0x00, 0xFF, 0x00},       /* TERM_L_GREEN */
325         {0x00, 0x00, 0xFF, 0xFF},       /* TERM_L_BLUE */
326         {0x00, 0xC0, 0x80, 0x40}        /* TERM_L_UMBER */
327 };
328
329
330 /*
331  * Standard sound names
332  */
333 const concptr angband_sound_name[SOUND_MAX] =
334 {
335         "dummy",
336         "hit",
337         "miss",
338         "flee",
339         "drop",
340         "kill",
341         "level",
342         "death",
343         "study",
344         "teleport",
345         "shoot",
346         "quaff",
347         "zap",
348         "walk",
349         "tpother",
350         "hitwall",
351         "eat",
352         "store1",
353         "store2",
354         "store3",
355         "store4",
356         "dig",
357         "opendoor",
358         "shutdoor",
359         "tplevel",
360         "scroll",
361         "buy",
362         "sell",
363         "warn",
364         "rocket",
365         "n_kill",
366         "u_kill",
367         "quest",
368         "heal",
369         "x_heal",
370         "bite",
371         "claw",
372         "m_spell",
373         "summon",
374         "breath",
375         "ball",
376         "m_heal",
377         "atkspell",
378         "evil",
379         "touch",
380         "sting",
381         "crush",
382         "slime",
383         "wail",
384         "winner",
385         "fire",
386         "acid",
387         "elec",
388         "cold",
389         "illegal",
390         "fail",
391         "wakeup",
392         "invuln",
393         "fall",
394         "pain",
395         "destitem",
396         "moan",
397         "show",
398         "unused",
399         "explode",
400         "glass",
401         "reflect",
402 };
403
404 /*
405  * Standard music names
406  */
407 const concptr angband_music_basic_name[MUSIC_BASIC_MAX] =
408 {
409         "default",
410         "gameover",
411         "exit",
412         "town",
413         "field1",
414         "field2",
415         "field3",
416         "dun_low",
417         "dun_med",
418         "dun_high",
419         "feel1",
420         "feel2",
421         "winner",
422         "build",
423         "wild",
424         "quest",
425         "arena",
426         "battle",
427         "quest_clear",
428         "final_quest_clear",
429         "ambush",
430 };
431
432 /*
433  * The array of saved floors
434  */
435 saved_floor_type saved_floors[MAX_SAVED_FLOORS];
436
437 /*
438  * Number of floor_id used from birth
439  */
440 FLOOR_IDX max_floor_id;
441
442 world_type world;
443 world_type *current_world_ptr = &world;
444
445 /*
446  * Sign for current process used in temporal files.
447  * Actually it is the start time of current process.
448  */
449 u32b saved_floor_file_sign;
450
451 /*
452  * Maximum number of towns
453  */
454 TOWN_IDX max_towns;
455
456 /*
457  * The towns [max_towns]
458  */
459 town_type *town_info;
460
461
462 /*
463  * The player's inventory [INVEN_TOTAL]
464  */
465 object_type *inventory;
466
467
468 /*
469  * The size of "alloc_kind_table" (at most max_k_idx * 4)
470  */
471 s16b alloc_kind_size;
472
473 /*
474  * The entries in the "kind allocator table"
475  */
476 alloc_entry *alloc_kind_table;
477
478
479 /*
480  * The size of "alloc_race_table" (at most max_r_idx)
481  */
482 s16b alloc_race_size;
483
484 /*
485  * The entries in the "race allocator table"
486  */
487 alloc_entry *alloc_race_table;
488
489
490 /*
491  * Specify attr/char pairs for visual special effects
492  * Be sure to use "index & 0x7F" to avoid illegal access
493  */
494 TERM_COLOR misc_to_attr[256];
495 SYMBOL_CODE misc_to_char[256];
496
497
498 /*
499  * Specify attr/char pairs for inventory items (by tval)
500  * Be sure to use "index & 0x7F" to avoid illegal access
501  */
502 TERM_COLOR tval_to_attr[128];
503 SYMBOL_CODE tval_to_char[128];
504
505
506 /*
507  * Keymaps for each "mode" associated with each keypress.
508  */
509 concptr keymap_act[KEYMAP_MODES][256];
510
511
512
513 /*** Player information ***/
514
515 /*
516  * Static player info record
517  */
518 player_type p_body;
519
520 /*
521  * Pointer to the player info
522  */
523 player_type *p_ptr = &p_body;
524
525 /*
526  * Pointer to the player tables
527  * (sex, race, class, magic)
528  */
529 const player_sex *sp_ptr;
530 const player_race *rp_ptr;
531 const player_class *cp_ptr;
532 const player_seikaku *ap_ptr;
533 const player_magic *mp_ptr;
534
535
536 /*
537  * The last character rolled,
538  * holded for quick start
539  */
540 birther previous_char;
541
542
543 /*
544  * The vault generation arrays
545  */
546 vault_type *v_info;
547 char *v_name;
548 char *v_text;
549
550 /*
551  * The skill table
552  */
553 skill_table *s_info;
554
555 /*
556  * The magic info
557  */
558 player_magic *m_info;
559
560 /*
561  * The object kind arrays
562  */
563 object_kind *k_info;
564 char *k_name;
565 char *k_text;
566
567 /*
568  * The ego-item arrays
569  */
570 ego_item_type *e_info;
571 char *e_name;
572 char *e_text;
573
574
575 /*
576  * The monster race arrays
577  */
578 monster_race *r_info;
579 char *r_name;
580 char *r_text;
581
582
583 /*
584  * The dungeon arrays
585  */
586 dungeon_type *d_info;
587 char *d_name;
588 char *d_text;
589
590
591 concptr ANGBAND_SYS = "xxx"; //!< Hack -- The special Angband "System Suffix" This variable is used to choose an appropriate "pref-xxx" file
592
593
594 #ifdef JP
595 concptr ANGBAND_KEYBOARD = "JAPAN"; //!< Hack -- The special Angband "Keyboard Suffix" This variable is used to choose an appropriate macro-trigger definition
596 #else
597 concptr ANGBAND_KEYBOARD = "0";
598 #endif
599
600 concptr ANGBAND_GRAF = "ascii"; //!< Hack -- The special Angband "Graphics Suffix" This variable is used to choose an appropriate "graf-xxx" file
601 concptr ANGBAND_DIR; //!< Path name: The main "lib" directory This variable is not actually used anywhere in the code
602 concptr ANGBAND_DIR_APEX; //!< High score files (binary) These files may be portable between platforms
603 concptr ANGBAND_DIR_BONE; //!< Bone files for player ghosts (ascii) These files are portable between platforms
604 concptr ANGBAND_DIR_DATA; //!< Binary image files for the "*_info" arrays (binary) These files are not portable between platforms
605 concptr ANGBAND_DIR_EDIT; //!< Textual template files for the "*_info" arrays (ascii) These files are portable between platforms
606 concptr ANGBAND_DIR_SCRIPT; //!< Script files These files are portable between platforms.
607 concptr ANGBAND_DIR_FILE; //!< Various extra files (ascii) These files may be portable between platforms
608 concptr ANGBAND_DIR_HELP; //!< Help files (normal) for the online help (ascii) These files are portable between platforms
609 concptr ANGBAND_DIR_INFO; //!< Help files (spoilers) for the online help (ascii) These files are portable between platforms
610 concptr ANGBAND_DIR_PREF; //!< Default user "preference" files (ascii) These files are rarely portable between platforms
611 concptr ANGBAND_DIR_SAVE; //!< Savefiles for current characters (binary)
612 concptr ANGBAND_DIR_USER; //!< User "preference" files (ascii) These files are rarely portable between platforms
613 concptr ANGBAND_DIR_XTRA; //!< Various extra files (binary) These files are rarely portable between platforms
614
615
616 /*
617  * Here is a "pseudo-hook" used during calls to "get_item()" and
618  * "show_inven()" and "show_equip()", and the choice window routines.
619  */
620 OBJECT_TYPE_VALUE item_tester_tval;
621
622
623 /*
624  * Here is a "hook" used during calls to "get_item()" and
625  * "show_inven()" and "show_equip()", and the choice window routines.
626  */
627 bool (*item_tester_hook)(object_type*);
628
629
630
631
632 /*
633  * Hack -- function hooks to restrict "get_mon_num_prep()" function
634  */
635 monsterrace_hook_type get_mon_num_hook;
636 monsterrace_hook_type get_mon_num2_hook;
637
638
639 /*
640  * Hack -- function hook to restrict "get_obj_num_prep()" function
641  */
642 bool (*get_obj_num_hook)(KIND_OBJECT_IDX k_idx);
643
644 /*
645  * Buildings
646  */
647 building_type building[MAX_BLDG];
648
649
650 /*
651  * Maximum number of quests
652  */
653 QUEST_IDX max_q_idx;
654
655 /*
656  * Maximum number of monsters in r_info.txt
657  */
658 MONRACE_IDX max_r_idx;
659
660 /*
661  * Maximum number of items in k_info.txt
662  */
663 KIND_OBJECT_IDX max_k_idx;
664
665 /*
666  * Maximum number of vaults in v_info.txt
667  */
668 VAULT_IDX max_v_idx;
669
670 /*
671  * Maximum number of terrain features in f_info.txt
672  */
673 FEAT_IDX max_f_idx;
674
675 /*
676  * Maximum number of artifacts in a_info.txt
677  */
678 ARTIFACT_IDX max_a_idx;
679
680 /*
681  * Maximum number of ego-items in e_info.txt
682  */
683 EGO_IDX max_e_idx;
684
685 /*
686  * Maximum number of dungeon in e_info.txt
687  */
688 DUNGEON_IDX max_d_idx;
689
690
691 /*
692  * Quest text
693  */
694 char quest_text[10][80];
695
696 /*
697  * Current line of the quest text
698  */
699 int quest_text_line;
700
701 /*
702  * Flags for initialization
703  */
704 int init_flags;
705
706
707 /*
708  * The "highscore" file descriptor, if available.
709  */
710 int highscore_fd = -1;
711
712 bool can_save = FALSE;        /* Game can be saved */
713
714
715 int cap_mon;
716 int cap_mspeed;
717 HIT_POINT cap_hp;
718 HIT_POINT cap_maxhp;
719 STR_OFFSET cap_nickname;
720
721 MONRACE_IDX battle_mon[4];
722 int sel_monster;
723 int battle_odds;
724 PRICE kakekin;
725 u32b mon_odds[4];
726
727 MONSTER_IDX pet_t_m_idx;
728 MONSTER_IDX riding_t_m_idx;
729
730 MONSTER_IDX today_mon;
731
732 bool write_level;
733
734 u32b start_time;
735
736 bool sukekaku;
737 bool new_mane;
738
739 bool mon_fight;
740
741 bool generate_encounter;
742
743 concptr screen_dump = NULL;
744
745
746 /*
747  * Which dungeon ?
748  */
749 DEPTH *max_dlv;
750
751 FEAT_IDX feat_wall_outer;
752 FEAT_IDX feat_wall_inner;
753 FEAT_IDX feat_wall_solid;
754 FEAT_IDX feat_ground_type[100], feat_wall_type[100];
755
756 COMMAND_CODE now_message;
757 bool use_menu;
758
759 #ifdef CHUUKEI
760 bool chuukei_server;
761 bool chuukei_client;
762 char *server_name;
763 int server_port;
764 #endif
765
766 /* for movie */
767 bool browsing_movie;
768
769 #ifdef TRAVEL
770 /* for travel */
771 travel_type travel;
772 #endif
773
774 /* for snipers */
775 bool reset_concent = FALSE;   /* Concentration reset flag */
776 bool is_fired = FALSE;
777