OSDN Git Service

[Fix] #41430 乗馬がプレイヤーのテレポートを追尾する
[hengband/hengband.git] / src / save / info-writer.c
1 #include "save/info-writer.h"
2 #include "birth/quick-start.h"
3 #include "game-option/cheat-options.h"
4 #include "game-option/option-flags.h"
5 #include "game-option/option-types-table.h"
6 #include "game-option/special-options.h"
7 #include "save/item-writer.h"
8 #include "save/save-util.h"
9 #include "store/store-util.h"
10 #include "system/angband.h"
11 #include "system/object-type-definition.h"
12 #include "world/world.h"
13
14 /*!
15  * @brief セーブデータに店舗情報を書き込む / Write a "store" record
16  * @param store_ptr 店舗情報の参照ポインタ
17  * @return なし
18  */
19 void wr_store(store_type *store_ptr)
20 {
21     wr_u32b(store_ptr->store_open);
22     wr_s16b(store_ptr->insult_cur);
23     wr_byte(store_ptr->owner);
24     wr_s16b(store_ptr->stock_num);
25     wr_s16b(store_ptr->good_buy);
26     wr_s16b(store_ptr->bad_buy);
27     wr_s32b(store_ptr->last_visit);
28     for (int j = 0; j < store_ptr->stock_num; j++)
29         wr_item(&store_ptr->stock[j]);
30 }
31
32 /*!
33  * @brief セーブデータに乱数情報を書き込む / Write RNG state
34  * @param なし
35  * @return なし
36  */
37 void wr_randomizer(void)
38 {
39     wr_u16b(0);
40     wr_u16b(Rand_place);
41     for (int i = 0; i < RAND_DEG; i++)
42         wr_u32b(Rand_state[i]);
43 }
44
45 /*!
46  * @brief ゲームオプション情報を書き込む / Write the "options"
47  * @return なし
48  */
49 void wr_options(void)
50 {
51     for (int i = 0; i < 4; i++)
52         wr_u32b(0L);
53
54     wr_byte(delay_factor);
55     wr_byte(hitpoint_warn);
56     wr_byte(mana_warn);
57
58     /*** Cheating options ***/
59     u16b c = 0;
60     if (current_world_ptr->wizard)
61         c |= 0x0002;
62
63     if (cheat_sight)
64         c |= 0x0040;
65
66     if (cheat_turn)
67         c |= 0x0080;
68
69     if (cheat_peek)
70         c |= 0x0100;
71
72     if (cheat_hear)
73         c |= 0x0200;
74
75     if (cheat_room)
76         c |= 0x0400;
77
78     if (cheat_xtra)
79         c |= 0x0800;
80
81     if (cheat_know)
82         c |= 0x1000;
83
84     if (cheat_live)
85         c |= 0x2000;
86
87     if (cheat_save)
88         c |= 0x4000;
89
90     if (cheat_diary_output)
91         c |= 0x8000;
92
93     wr_u16b(c);
94
95     wr_byte(autosave_l);
96     wr_byte(autosave_t);
97     wr_s16b(autosave_freq);
98
99     for (int i = 0; option_info[i].o_desc; i++) {
100         int os = option_info[i].o_set;
101         int ob = option_info[i].o_bit;
102         if (!option_info[i].o_var)
103             continue;
104
105         if (*option_info[i].o_var)
106             option_flag[os] |= (1L << ob);
107         else
108             option_flag[os] &= ~(1L << ob);
109     }
110
111     for (int i = 0; i < 8; i++)
112         wr_u32b(option_flag[i]);
113
114     for (int i = 0; i < 8; i++)
115         wr_u32b(option_mask[i]);
116
117     for (int i = 0; i < 8; i++)
118         wr_u32b(window_flag[i]);
119
120     for (int i = 0; i < 8; i++)
121         wr_u32b(window_mask[i]);
122 }
123
124 /*!
125  * @brief ダミー情報スキップを書き込む / Hack -- Write the "ghost" info
126  * @return なし
127  */
128 void wr_ghost(void)
129 {
130     wr_string(_("不正なゴースト", "Broken Ghost"));
131     for (int i = 0; i < 60; i++)
132         wr_byte(0);
133 }
134
135 /*!
136  * @brief クイック・スタート情報を書き込む / Save quick start data
137  * @return なし
138  */
139 void save_quick_start(void)
140 {
141     wr_byte(previous_char.psex);
142     wr_byte((byte)previous_char.prace);
143     wr_byte((byte)previous_char.pclass);
144     wr_byte((byte)previous_char.pseikaku);
145     wr_byte((byte)previous_char.realm1);
146     wr_byte((byte)previous_char.realm2);
147
148     wr_s16b(previous_char.age);
149     wr_s16b(previous_char.ht);
150     wr_s16b(previous_char.wt);
151     wr_s16b(previous_char.sc);
152     wr_s32b(previous_char.au);
153
154     for (int i = 0; i < A_MAX; i++)
155         wr_s16b(previous_char.stat_max[i]);
156
157     for (int i = 0; i < A_MAX; i++)
158         wr_s16b(previous_char.stat_max_max[i]);
159
160     for (int i = 0; i < PY_MAX_LEVEL; i++)
161         wr_s16b((s16b)previous_char.player_hp[i]);
162
163     wr_s16b(previous_char.chaos_patron);
164     for (int i = 0; i < 8; i++)
165         wr_s16b(previous_char.vir_types[i]);
166
167     for (int i = 0; i < 4; i++)
168         wr_string(previous_char.history[i]);
169
170     /* UNUSED : Was number of random quests */
171     wr_byte(0);
172     if (current_world_ptr->noscore)
173         previous_char.quick_ok = FALSE;
174
175     wr_byte((byte)previous_char.quick_ok);
176 }