Add LSD_Reader::ClearDefaults
For clearing default values from save games
MODIFY
generator/csv/setup.csv
generator/csv/setup.csv
@@ -4,14 +4,18 @@ Chipset,void Init(),
Save,void Setup(),
SaveActor,void Setup(int actor_id),
SaveActor,void Fixup(int actor_id),
+SaveActor,void UnFixup(),
SaveInventory,void Setup(),
SaveMapEvent,void Setup(const RPG::Event& event),"rpg_event.h"
SaveMapEvent,void Fixup(const RPG::EventPage& page),
+SaveMapEvent,void UnFixup(const RPG::EventPage& page),
SaveMapInfo,void Setup(),
SaveMapInfo,void Setup(const RPG::Map& map),"rpg_map.h"
SaveMapInfo,void Setup(const RPG::MapInfo& map_info),"rpg_mapinfo.h"
SaveMapInfo,void Fixup(const RPG::Map& map),
+SaveMapInfo,void UnFixup(const RPG::Map& map),
SaveSystem,void Setup(),
SaveSystem,void Fixup(),
+SaveSystem,void UnFixup(),
Parameters,void Setup(int final_level),
System,void Init(),

MODIFY
src/generated/rpg_saveactor.h
src/generated/rpg_saveactor.h
Binary files a/src/generated/rpg_saveactor.h and b/src/generated/rpg_saveactor.h differ

MODIFY
src/generated/rpg_savemapevent.h
src/generated/rpg_savemapevent.h
Binary files a/src/generated/rpg_savemapevent.h and b/src/generated/rpg_savemapevent.h differ

MODIFY
src/generated/rpg_savemapinfo.h
src/generated/rpg_savemapinfo.h
Binary files a/src/generated/rpg_savemapinfo.h and b/src/generated/rpg_savemapinfo.h differ

MODIFY
src/generated/rpg_savesystem.h
src/generated/rpg_savesystem.h
Binary files a/src/generated/rpg_savesystem.h and b/src/generated/rpg_savesystem.h differ

MODIFY
src/lsd_reader.cpp
src/lsd_reader.cpp
@@ -133,3 +133,15 @@ std::unique_ptr<RPG::Save> LSD_Reader::LoadXml(std::istream& filestream) {
reader.Parse();
return std::unique_ptr<RPG::Save>(save);
}
+
+RPG::Save LSD_Reader::ClearDefaults(const RPG::Save& save_in, const RPG::Map& map) {
+ auto save = save_in;
+
+ save.system.UnFixup();
+ for (auto& actor: save.actors) {
+ actor.UnFixup();
+ }
+ save.map_info.UnFixup(map);
+
+ return save;
+}

MODIFY
src/lsd_reader.h
src/lsd_reader.h
@@ -41,6 +41,11 @@ namespace LSD_Reader {
*/
void PrepareSave(RPG::Save& save);
+ /**
+ * Returns a copy of the save data with defaults cleared.
+ */
+ RPG::Save ClearDefaults(const RPG::Save& save, const RPG::Map& map);
+
/**
* Loads Savegame.
*/

MODIFY
src/rpg_fixup.cpp
src/rpg_fixup.cpp
@@ -37,6 +37,30 @@ void RPG::SaveActor::Fixup(int actor_id) {
}
}
+void RPG::SaveActor::UnFixup() {
+ const RPG::Actor& actor = Data::actors[ID - 1];
+
+ if (name == actor.name) {
+ name = "\x1";
+ }
+ if (title == actor.title) {
+ title = "\x1";
+ }
+ if (sprite_name == actor.character_name
+ && sprite_id == actor.character_index
+ && sprite_flags == (actor.transparent ? 3 : 0)) {
+ sprite_name.clear();
+ sprite_id = 0;
+ sprite_flags = 0;
+ }
+ if (face_name == actor.face_name && face_id == actor.face_index) {
+ face_name.clear();
+ face_id = 0;
+ }
+}
+
+
+
void RPG::SaveMapEvent::Fixup(const RPG::EventPage& page) {
if (move_frequency == -1) {
move_frequency = page.move_frequency;
@@ -52,6 +76,21 @@ void RPG::SaveMapEvent::Fixup(const RPG::EventPage& page) {
}
}
+void RPG::SaveMapEvent::UnFixup(const RPG::EventPage& page) {
+ if (move_frequency == page.move_frequency) {
+ move_frequency = -1;
+ }
+ if (move_speed == page.move_speed) {
+ move_speed = -1;
+ }
+ if (sprite_name == page.character_name) {
+ sprite_name.clear();
+ }
+ if (sprite_id == page.character_index) {
+ sprite_id = -1;
+ }
+}
+
void RPG::SaveSystem::Fixup() {
const RPG::System& system = Data::system;
@@ -129,8 +168,99 @@ void RPG::SaveSystem::Fixup() {
}
}
+void RPG::SaveSystem::UnFixup() {
+ const RPG::System& system = Data::system;
+
+ //TODO: Should be a C++14 polymorphic lambda
+ auto reset_se = [](RPG::Sound& s) {
+ s = {};
+ s.name.clear();
+ };
+
+ auto reset_bgm = [](RPG::Music& s) {
+ s = {};
+ s.name.clear();
+ };
+
+ if (graphics_name == system.system_name) {
+ graphics_name.clear();
+ }
+
+ if (battle_music == system.battle_music) {
+ reset_bgm(battle_music);
+ }
+ if (battle_end_music == system.battle_end_music) {
+ reset_bgm(battle_end_music);
+ }
+ if (inn_music == system.inn_music) {
+ reset_bgm(inn_music);
+ }
+ if (title_music == system.title_music) {
+ reset_bgm(title_music);
+ }
+ if (boat_music == system.boat_music) {
+ reset_bgm(boat_music);
+ }
+ if (ship_music == system.ship_music) {
+ reset_bgm(ship_music);
+ }
+ if (airship_music == system.airship_music) {
+ reset_bgm(airship_music);
+ }
+ if (gameover_music == system.gameover_music) {
+ reset_bgm(gameover_music);
+ }
+ if (cursor_se == system.cursor_se) {
+ reset_se(cursor_se);
+ }
+ if (decision_se == system.decision_se) {
+ reset_se(decision_se);
+ }
+ if (cancel_se == system.cancel_se) {
+ reset_se(cancel_se);
+ }
+ if (buzzer_se == system.buzzer_se) {
+ reset_se(buzzer_se);
+ }
+ if (battle_se == system.battle_se) {
+ reset_se(battle_se);
+ }
+ if (escape_se == system.escape_se) {
+ reset_se(escape_se);
+ }
+ if (enemy_attack_se == system.enemy_attack_se) {
+ reset_se(enemy_attack_se);
+ }
+ if (enemy_damaged_se == system.enemy_damaged_se) {
+ reset_se(enemy_damaged_se);
+ }
+ if (actor_damaged_se == system.actor_damaged_se) {
+ reset_se(actor_damaged_se);
+ }
+ if (dodge_se == system.dodge_se) {
+ reset_se(dodge_se);
+ }
+ if (enemy_death_se == system.enemy_death_se) {
+ reset_se(enemy_death_se);
+ }
+ if (item_se == system.item_se) {
+ reset_se(item_se);
+ }
+ if (message_stretch == system.message_stretch) {
+ message_stretch = -1;
+ }
+}
+
+
void RPG::SaveMapInfo::Fixup(const RPG::Map& map) {
if (chipset_id <= 0) {
chipset_id = map.chipset_id;
}
}
+
+
+void RPG::SaveMapInfo::UnFixup(const RPG::Map& map) {
+ if (chipset_id == map.chipset_id) {
+ chipset_id = -1;
+ }
+}

Add LSD_Reader::ClearDefaults

For clearing default values from save games