Refactor switches and variables
Variable values are signed
Don't presize. Switches and Vars array grows
dynamically as the game writes values
Do reserve, to get deterministic performance in Player.
variable and switch sizes are count fields
MODIFY
generator/csv/fields.csv
generator/csv/fields.csv
@@ -710,10 +710,10 @@ SaveSystem,frame_count,f,Int32,0x0B,0,0,0,
SaveSystem,graphics_name,f,String,0x15,'',0,0,string
SaveSystem,message_stretch,f,Int32,0x16,-1,0,0,Integer
SaveSystem,font_id,f,Int32,0x17,0,0,0,Integer
-SaveSystem,switches_size,f,Int32,0x1F,0,0,0,
+SaveSystem,switches,t,Count<Boolean>,0x1F,0,0,0,
SaveSystem,switches,f,Vector<Boolean>,0x20,,1,0,
-SaveSystem,variables_size,f,Int32,0x21,0,0,0,
-SaveSystem,variables,f,Vector<UInt32>,0x22,,1,0,
+SaveSystem,variables,t,Count<Int32>,0x21,0,0,0,
+SaveSystem,variables,f,Vector<Int32>,0x22,,1,0,
SaveSystem,message_transparent,f,Int32,0x29,0,0,0,
SaveSystem,message_position,f,Int32,0x2A,2,0,0,
SaveSystem,message_prevent_overlap,f,Int32,0x2B,1,0,0,

MODIFY
src/generated/lsd_savesystem.cpp
src/generated/lsd_savesystem.cpp
Binary files a/src/generated/lsd_savesystem.cpp and b/src/generated/lsd_savesystem.cpp 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/rpg_fixup.cpp
src/rpg_fixup.cpp
@@ -58,12 +58,8 @@ void RPG::SaveSystem::Fixup() {
if (graphics_name.empty()) {
graphics_name = system.system_name;
}
- if (switches.size() < Data::switches.size()) {
- switches.resize(Data::switches.size());
- }
- if (variables.size() < Data::variables.size()) {
- variables.resize(Data::variables.size());
- }
+ switches.reserve(Data::switches.size());
+ variables.reserve(Data::variables.size());
if (battle_music.name.empty()) {
battle_music = system.battle_music;
}

MODIFY
src/rpg_setup.cpp
src/rpg_setup.cpp
@@ -100,12 +100,6 @@ void RPG::SaveSystem::Setup() {
screen = 0;
frame_count = 0;
graphics_name = system.system_name;
- switches_size = Data::switches.size();
- switches.clear();
- switches.resize(switches_size);
- variables_size = Data::variables.size();
- variables.clear();
- variables.resize(variables_size);
face_name = "";
face_id = -1;
face_right = false;

Refactor switches and variables

- Variable values are signed
- Don't presize. Switches and Vars array grows
  dynamically as the game writes values
- Do reserve, to get deterministic performance in Player.
- variable and switch sizes are count fields