OSDN Git Service

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