1 #include "save/player-writer.h"
2 #include "cmd-building/cmd-building.h"
3 #include "game-option/birth-options.h"
4 #include "player-base/player-class.h"
5 #include "player/player-skill.h"
6 #include "save/info-writer.h"
7 #include "save/player-class-specific-data-writer.h"
8 #include "save/save-util.h"
9 #include "system/building-type-definition.h"
10 #include "system/dungeon-info.h"
11 #include "system/floor-type-definition.h"
12 #include "system/player-type-definition.h"
13 #include "timed-effect/player-acceleration.h"
14 #include "timed-effect/player-blindness.h"
15 #include "timed-effect/player-confusion.h"
16 #include "timed-effect/player-cut.h"
17 #include "timed-effect/player-deceleration.h"
18 #include "timed-effect/player-fear.h"
19 #include "timed-effect/player-hallucination.h"
20 #include "timed-effect/player-paralysis.h"
21 #include "timed-effect/player-poison.h"
22 #include "timed-effect/player-stun.h"
23 #include "timed-effect/timed-effects.h"
24 #include "world/world.h"
28 * @brief セーブデータに領域情報を書き込む / Write player realms
29 * @param player_ptr プレイヤーへの参照ポインタ
31 static void wr_relams(PlayerType *player_ptr)
33 if (PlayerClass(player_ptr).equals(PlayerClassType::ELEMENTALIST)) {
34 wr_byte((byte)player_ptr->element);
36 wr_byte((byte)player_ptr->realm1);
38 wr_byte((byte)player_ptr->realm2);
42 * @brief セーブデータにプレイヤー情報を書き込む / Write some "player" info
43 * @param player_ptr プレイヤーへの参照ポインタ
45 void wr_player(PlayerType *player_ptr)
47 wr_string(player_ptr->name);
48 wr_string(player_ptr->died_from);
49 wr_string(player_ptr->last_message ? player_ptr->last_message : "");
52 for (int i = 0; i < 4; i++) {
53 wr_string(player_ptr->history[i]);
56 wr_byte((byte)player_ptr->prace);
57 wr_byte((byte)player_ptr->pclass);
58 wr_byte((byte)player_ptr->ppersonality);
59 wr_byte((byte)player_ptr->psex);
60 wr_relams(player_ptr);
63 wr_byte((byte)player_ptr->hitdie);
64 wr_u16b(player_ptr->expfact);
66 wr_s16b(player_ptr->age);
67 wr_s16b(player_ptr->ht);
68 wr_s16b(player_ptr->wt);
70 for (int i = 0; i < A_MAX; ++i) {
71 wr_s16b(player_ptr->stat_max[i]);
74 for (int i = 0; i < A_MAX; ++i) {
75 wr_s16b(player_ptr->stat_max_max[i]);
78 for (int i = 0; i < A_MAX; ++i) {
79 wr_s16b(player_ptr->stat_cur[i]);
82 for (int i = 0; i < 12; ++i) {
86 wr_u32b(player_ptr->au);
87 wr_u32b(player_ptr->max_exp);
88 wr_u32b(player_ptr->max_max_exp);
89 wr_u32b(player_ptr->exp);
90 wr_u32b(player_ptr->exp_frac);
91 wr_s16b(player_ptr->lev);
93 for (int i = 0; i < 64; i++) {
94 wr_s16b(player_ptr->spell_exp[i]);
97 for (auto tval : TV_WEAPON_RANGE) {
98 for (int j = 0; j < 64; j++) {
99 wr_s16b(player_ptr->weapon_exp[tval][j]);
103 for (auto i : PLAYER_SKILL_KIND_TYPE_RANGE) {
104 wr_s16b(player_ptr->skill_exp[i]);
106 for (auto i = 0U; i < MAX_SKILLS - PLAYER_SKILL_KIND_TYPE_RANGE.size(); ++i) {
111 std::visit(PlayerClassSpecificDataWriter(), player_ptr->class_specific_data);
113 wr_byte((byte)player_ptr->start_race);
114 wr_s32b(player_ptr->old_race1);
115 wr_s32b(player_ptr->old_race2);
116 wr_s16b(player_ptr->old_realm);
118 for (const auto &[r_idx, is_achieved] : w_ptr->bounties) {
119 wr_s16b(enum2i(r_idx));
120 wr_bool(is_achieved);
123 for (int i = 0; i < 4; i++) {
124 wr_s16b(enum2i(battle_mon_list[i]));
125 wr_u32b(mon_odds[i]);
128 wr_s16b(player_ptr->town_num);
130 wr_s16b(player_ptr->arena_number);
131 wr_s16b(player_ptr->current_floor_ptr->inside_arena);
132 wr_s16b(enum2i(player_ptr->current_floor_ptr->quest_number));
133 wr_s16b(player_ptr->phase_out);
134 wr_byte(player_ptr->exit_bldg);
135 wr_byte(0); /* Unused */
137 wr_s16b((int16_t)player_ptr->oldpx);
138 wr_s16b((int16_t)player_ptr->oldpy);
141 wr_s32b(player_ptr->mhp);
142 wr_s32b(player_ptr->chp);
143 wr_u32b(player_ptr->chp_frac);
144 wr_s32b(player_ptr->msp);
145 wr_s32b(player_ptr->csp);
146 wr_u32b(player_ptr->csp_frac);
147 wr_s16b(player_ptr->max_plv);
149 byte tmp8u = (byte)dungeons_info.size();
151 for (int i = 0; i < tmp8u; i++) {
152 wr_s16b((int16_t)max_dlv[i]);
159 wr_s16b(player_ptr->sc);
161 auto effects = player_ptr->effects();
162 wr_s16b(0); /* old "rest" */
163 wr_s16b(effects->blindness()->current());
164 wr_s16b(effects->paralysis()->current());
165 wr_s16b(effects->confusion()->current());
166 wr_s16b(player_ptr->food);
167 wr_s16b(0); /* old "food_digested" */
168 wr_s16b(0); /* old "protection" */
169 wr_s16b(player_ptr->energy_need);
170 wr_s16b(player_ptr->enchant_energy_need);
171 wr_s16b(effects->acceleration()->current());
172 wr_s16b(effects->deceleration()->current());
173 wr_s16b(effects->fear()->current());
174 wr_s16b(effects->cut()->current());
175 wr_s16b(effects->stun()->current());
176 wr_s16b(effects->poison()->current());
177 wr_s16b(effects->hallucination()->current());
178 wr_s16b(player_ptr->protevil);
179 wr_s16b(player_ptr->invuln);
180 wr_s16b(player_ptr->ult_res);
181 wr_s16b(player_ptr->hero);
182 wr_s16b(player_ptr->shero);
183 wr_s16b(player_ptr->shield);
184 wr_s16b(player_ptr->blessed);
185 wr_s16b(player_ptr->tim_invis);
186 wr_s16b(player_ptr->word_recall);
187 wr_s16b(player_ptr->recall_dungeon);
188 wr_s16b(player_ptr->alter_reality);
189 wr_s16b(player_ptr->see_infra);
190 wr_s16b(player_ptr->tim_infra);
191 wr_s16b(player_ptr->oppose_fire);
192 wr_s16b(player_ptr->oppose_cold);
193 wr_s16b(player_ptr->oppose_acid);
194 wr_s16b(player_ptr->oppose_elec);
195 wr_s16b(player_ptr->oppose_pois);
196 wr_s16b(player_ptr->tsuyoshi);
197 wr_s16b(player_ptr->tim_esp);
198 wr_s16b(player_ptr->wraith_form);
199 wr_s16b(player_ptr->resist_magic);
200 wr_s16b(player_ptr->tim_regen);
201 wr_s16b(player_ptr->tim_pass_wall);
202 wr_s16b(player_ptr->tim_stealth);
203 wr_s16b(player_ptr->tim_levitation);
204 wr_s16b(player_ptr->tim_sh_touki);
205 wr_s16b(player_ptr->lightspeed);
206 wr_s16b(player_ptr->tsubureru);
207 wr_s16b(player_ptr->magicdef);
208 wr_s16b(player_ptr->tim_res_nether);
209 wr_s16b(player_ptr->tim_res_time);
210 wr_byte((byte)player_ptr->mimic_form);
211 wr_s16b(player_ptr->tim_mimic);
212 wr_s16b(player_ptr->tim_sh_fire);
213 wr_s16b(player_ptr->tim_sh_holy);
214 wr_s16b(player_ptr->tim_eyeeye);
216 wr_s16b(player_ptr->tim_reflect);
217 wr_s16b(player_ptr->multishadow);
218 wr_s16b(player_ptr->dustrobe);
220 wr_s16b(player_ptr->chaos_patron);
221 wr_FlagGroup(player_ptr->muta, wr_byte);
223 for (int i = 0; i < 8; i++) {
224 wr_s16b(player_ptr->virtues[i]);
227 for (int i = 0; i < 8; i++) {
228 wr_s16b(enum2i(player_ptr->vir_types[i]));
231 wr_s16b(player_ptr->ele_attack);
232 wr_u32b(player_ptr->special_attack);
233 wr_s16b(player_ptr->ele_immune);
234 wr_u32b(player_ptr->special_defense);
235 wr_byte(player_ptr->knowledge);
236 wr_bool(player_ptr->autopick_autoregister);
238 wr_byte((byte)player_ptr->action);
240 wr_bool(preserve_mode);
241 wr_bool(player_ptr->wait_report_score);
243 for (int i = 0; i < 12; i++) {
247 /* Ignore some flags */
252 wr_u32b(w_ptr->seed_flavor);
253 wr_u32b(w_ptr->seed_town);
254 wr_u16b(player_ptr->panic_save);
255 wr_u16b(w_ptr->total_winner);
256 wr_u16b(w_ptr->noscore);
257 wr_bool(player_ptr->is_dead);
258 wr_byte(player_ptr->feeling);
259 wr_s32b(player_ptr->current_floor_ptr->generated_turn);
260 wr_s32b(player_ptr->feeling_turn);
261 wr_s32b(w_ptr->game_turn);
262 wr_s32b(w_ptr->dungeon_turn);
263 wr_s32b(w_ptr->arena_start_turn);
264 wr_s16b(enum2i(w_ptr->today_mon));
265 wr_s16b(player_ptr->knows_daily_bounty ? 1 : 0); // 現在bool型だが、かつてモンスター種族IDを保存していた仕様に合わせる
266 wr_s16b(player_ptr->riding);
267 wr_s16b(player_ptr->floor_id);
269 /* Save temporary preserved pets (obsolated) */
271 wr_u32b(w_ptr->play_time);
272 wr_s32b(player_ptr->visit);
273 wr_u32b(player_ptr->count);