OSDN Git Service

Merge pull request #41491 (taotao/hengband/fix-impure_calc_num_blow into develop).
[hengband/hengband.git] / src / load / option-loader.c
1 #include "load/option-loader.h"
2 #include "cmd-io/cmd-gameoption.h"
3 #include "game-option/cheat-options.h"
4 #include "game-option/option-flags.h"
5 #include "game-option/special-options.h"
6 #include "load/angband-version-comparer.h"
7 #include "load/load-util.h"
8 #include "load/load-zangband.h"
9 #include "system/angband.h"
10 #include "world/world.h"
11
12 /*!
13  * @brief ゲームオプションを読み込む / Read options (ignore most pre-2.8.0 options)
14  * @return なし
15  * @details
16  * Note that the normal options are now stored as a set of 256 bit flags,
17  * plus a set of 256 bit masks to indicate which bit flags were defined
18  * at the time the savefile was created.  This will allow new options
19  * to be added, and old options to be removed, at any time, without
20  * hurting old savefiles.
21  *
22  * The window options are stored in the same way, but note that each
23  * window gets 32 options, and their order is fixed by certain defines.
24  */
25 void rd_options(void)
26 {
27     strip_bytes(16);
28
29     byte b;
30     rd_byte(&b);
31     delay_factor = b;
32
33     rd_byte(&b);
34     hitpoint_warn = b;
35
36     if (h_older_than(1, 7, 0, 0)) {
37         mana_warn = 2;
38     } else {
39         rd_byte(&b);
40         mana_warn = b;
41     }
42
43     u16b c;
44     rd_u16b(&c);
45
46     if (c & 0x0002)
47         current_world_ptr->wizard = TRUE;
48
49     cheat_peek = (c & 0x0100) ? TRUE : FALSE;
50     cheat_hear = (c & 0x0200) ? TRUE : FALSE;
51     cheat_room = (c & 0x0400) ? TRUE : FALSE;
52     cheat_xtra = (c & 0x0800) ? TRUE : FALSE;
53     cheat_know = (c & 0x1000) ? TRUE : FALSE;
54     cheat_live = (c & 0x2000) ? TRUE : FALSE;
55     cheat_save = (c & 0x4000) ? TRUE : FALSE;
56     cheat_diary_output = (c & 0x8000) ? TRUE : FALSE;
57     cheat_turn = (c & 0x0080) ? TRUE : FALSE;
58     cheat_sight = (c & 0x0040) ? TRUE : FALSE;
59
60     rd_byte((byte *)&autosave_l);
61     rd_byte((byte *)&autosave_t);
62     rd_s16b(&autosave_freq);
63
64     BIT_FLAGS flag[8];
65     for (int n = 0; n < 8; n++)
66         rd_u32b(&flag[n]);
67
68     BIT_FLAGS mask[8];
69     for (int n = 0; n < 8; n++)
70         rd_u32b(&mask[n]);
71
72     for (int n = 0; n < 8; n++) {
73         for (int i = 0; i < 32; i++) {
74             if (!(mask[n] & (1L << i)))
75                 continue;
76             if (!(option_mask[n] & (1L << i)))
77                 continue;
78
79             if (flag[n] & (1L << i)) {
80                 option_flag[n] |= (1L << i);
81             } else {
82                 option_flag[n] &= ~(1L << i);
83             }
84         }
85     }
86
87     if (z_older_than(10, 4, 5))
88         load_zangband_options();
89
90     extract_option_vars();
91     for (int n = 0; n < 8; n++)
92         rd_u32b(&flag[n]);
93
94     for (int n = 0; n < 8; n++)
95         rd_u32b(&mask[n]);
96
97     for (int n = 0; n < 8; n++) {
98         for (int i = 0; i < 32; i++) {
99             if (!(mask[n] & (1L << i)))
100                 continue;
101             if (!(window_mask[n] & (1L << i)))
102                 continue;
103
104             if (flag[n] & (1L << i)) {
105                 window_flag[n] |= (1L << i);
106             } else {
107                 window_flag[n] &= ~(1L << i);
108             }
109         }
110     }
111 }