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