OSDN Git Service

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