1 #include "save/player-class-specific-data-writer.h"
2 #include "player-info/bard-data-type.h"
3 #include "player-info/bluemage-data-type.h"
4 #include "player-info/force-trainer-data-type.h"
5 #include "player-info/magic-eater-data-type.h"
6 #include "player-info/mane-data-type.h"
7 #include "player-info/smith-data-type.h"
8 #include "player-info/spell-hex-data-type.h"
9 #include "save/save-util.h"
10 #include "util/enum-converter.h"
12 void PlayerClassSpecificDataWriter::operator()(const std::shared_ptr<smith_data_type> &smith_data) const
14 for (auto [essence, amount] : smith_data->essences) {
16 wr_s16b(enum2i(essence));
24 void PlayerClassSpecificDataWriter::operator()(const std::shared_ptr<force_trainer_data_type> &force_trainer_data) const
26 wr_s32b(force_trainer_data->ki);
29 void PlayerClassSpecificDataWriter::operator()(const std::shared_ptr<bluemage_data_type> &bluemage_data) const
31 wr_FlagGroup(bluemage_data->learnt_blue_magics, wr_byte);
34 void PlayerClassSpecificDataWriter::operator()(const std::shared_ptr<magic_eater_data_type> &magic_eater_data) const
36 auto write_item_group = [](const auto &item_group) {
37 wr_u16b(static_cast<uint16_t>(item_group.size()));
38 for (const auto &item : item_group) {
43 write_item_group(magic_eater_data->staves);
44 write_item_group(magic_eater_data->wands);
45 write_item_group(magic_eater_data->rods);
48 void PlayerClassSpecificDataWriter::operator()(const std::shared_ptr<bard_data_type> &bird_data) const
50 wr_s32b(enum2i(bird_data->singing_song));
51 wr_s32b(enum2i(bird_data->interrputing_song));
52 wr_s32b(bird_data->singing_duration);
53 wr_byte(bird_data->singing_song_spell_idx);
56 void PlayerClassSpecificDataWriter::operator()(const std::shared_ptr<mane_data_type> &mane_data) const
58 wr_s16b(static_cast<int16_t>(mane_data->mane_list.size()));
60 for (const auto &mane : mane_data->mane_list) {
61 wr_s16b(static_cast<int16_t>(mane.spell));
62 wr_s16b(static_cast<int16_t>(mane.damage));
66 void PlayerClassSpecificDataWriter::operator()(const std::shared_ptr<spell_hex_data_type> &spell_hex_data) const
68 wr_FlagGroup(spell_hex_data->casting_spells, wr_byte);
69 wr_s32b(spell_hex_data->revenge_power);
70 wr_byte(enum2i(spell_hex_data->revenge_type));
71 wr_byte(spell_hex_data->revenge_turn);