diff --git a/SaveFileMapping/Program.cs b/SaveFileMapping/Program.cs index 6ea5d93b2..c3c75d88f 100644 --- a/SaveFileMapping/Program.cs +++ b/SaveFileMapping/Program.cs @@ -85,66 +85,73 @@ static void UpdateHashes(Type fieldType, HashSet> data) static void Main(string[] args) { - var main_data = new Dictionary(); - Type s = typeof(libMBIN.NMS.GameComponents.GcPlayerStateData); - var data = new HashSet>(); - UpdateHashes(s, data); + var save_mapping = new HashSet>(); + UpdateHashes(typeof(libMBIN.NMS.GameComponents.GcPlayerStateData), save_mapping); // Add some other values we need: // Added Keys: - data.Add(new Tuple(HashName("Version"), "Version")); - data.Add(new Tuple(HashName("Platform"), "Platform")); - data.Add(new Tuple(HashName("ActiveContext"), "ActiveContext")); - data.Add(new Tuple(HashName("GameMode"), "GameMode")); - data.Add(new Tuple(HashName("ReserveStore"), "ReserveStore")); - data.Add(new Tuple(HashName("ReserveManaged"), "ReserveManaged")); + save_mapping.Add(new Tuple(HashName("Version"), "Version")); + save_mapping.Add(new Tuple(HashName("Platform"), "Platform")); + save_mapping.Add(new Tuple(HashName("ActiveContext"), "ActiveContext")); + save_mapping.Add(new Tuple(HashName("GameMode"), "GameMode")); + save_mapping.Add(new Tuple(HashName("ReserveStore"), "ReserveStore")); + save_mapping.Add(new Tuple(HashName("ReserveManaged"), "ReserveManaged")); // Open Objects: - data.Add(new Tuple(HashName("CommonStateData"), "CommonStateData")); + save_mapping.Add(new Tuple(HashName("CommonStateData"), "CommonStateData")); // CommonStateData is of type GcPlayerCommonStateData - UpdateHashes(typeof(libMBIN.NMS.GameComponents.GcPlayerCommonStateData), data); - data.Add(new Tuple(HashName("BaseContext"), "BaseContext")); - data.Add(new Tuple(HashName("ExpeditionContext"), "ExpeditionContext")); - data.Add(new Tuple(HashName("PlayerStateData"), "PlayerStateData")); - data.Add(new Tuple(HashName("SpawnStateData"), "SpawnStateData")); - data.Add(new Tuple(HashName("GameKnowledgeData"), "GameKnowledgeData")); - data.Add(new Tuple(HashName("DiscoveryManagerData"), "DiscoveryManagerData")); - data.Add(new Tuple(HashName("DiscoveryData-v1"), "DiscoveryData-v1")); + UpdateHashes(typeof(libMBIN.NMS.GameComponents.GcPlayerCommonStateData), save_mapping); + save_mapping.Add(new Tuple(HashName("BaseContext"), "BaseContext")); + save_mapping.Add(new Tuple(HashName("ExpeditionContext"), "ExpeditionContext")); + save_mapping.Add(new Tuple(HashName("PlayerStateData"), "PlayerStateData")); + save_mapping.Add(new Tuple(HashName("SpawnStateData"), "SpawnStateData")); + save_mapping.Add(new Tuple(HashName("GameKnowledgeData"), "GameKnowledgeData")); + save_mapping.Add(new Tuple(HashName("DiscoveryManagerData"), "DiscoveryManagerData")); + save_mapping.Add(new Tuple(HashName("DiscoveryData-v1"), "DiscoveryData-v1")); // Open Arrays: - data.Add(new Tuple(HashName("MultiTool"), "MultiTool")); - data.Add(new Tuple(HashName("Waypoints"), "Waypoints")); + save_mapping.Add(new Tuple(HashName("MultiTool"), "MultiTool")); + save_mapping.Add(new Tuple(HashName("Waypoints"), "Waypoints")); // Waypoints is a list of GcGalaxyWaypoint's: - UpdateHashes(typeof(libMBIN.NMS.GameComponents.GcGalaxyWaypoint), data); + UpdateHashes(typeof(libMBIN.NMS.GameComponents.GcGalaxyWaypoint), save_mapping); // Session::SavePersistent - data.Add(new Tuple(HashName("Store"), "Store")); - data.Add(new Tuple(HashName("Record"), "Record")); - data.Add(new Tuple(HashName("TSrec"), "TSrec")); - data.Add(new Tuple(HashName("Available"), "Available")); - data.Add(new Tuple(HashName("Enqueued"), "Enqueued")); + save_mapping.Add(new Tuple(HashName("Store"), "Store")); + save_mapping.Add(new Tuple(HashName("Record"), "Record")); + save_mapping.Add(new Tuple(HashName("TSrec"), "TSrec")); + save_mapping.Add(new Tuple(HashName("Available"), "Available")); + save_mapping.Add(new Tuple(HashName("Enqueued"), "Enqueued")); // Not sure if these are still used, but kept for any kind of backward compatibility. - data.Add(new Tuple(HashName("OWS"), "OWS")); - data.Add(new Tuple(HashName("LID"), "LID")); - data.Add(new Tuple(HashName("UID"), "UID")); - data.Add(new Tuple(HashName("DM"), "DM")); - data.Add(new Tuple(HashName("CN"), "CN")); - data.Add(new Tuple(HashName("FL"), "FL")); - data.Add(new Tuple(HashName("RID"), "RID")); - data.Add(new Tuple(HashName("PTK"), "PTK")); - data.Add(new Tuple(HashName("H"), "H")); - data.Add(new Tuple(HashName("R"), "R")); - data.Add(new Tuple(HashName("C"), "C")); - data.Add(new Tuple(HashName("U"), "U")); - data.Add(new Tuple(HashName("F"), "F")); - data.Add(new Tuple(HashName("DD"), "DD")); - data.Add(new Tuple(HashName("UA"), "UA")); - data.Add(new Tuple(HashName("DT"), "DT")); - data.Add(new Tuple(HashName("VP"), "VP")); - data.Add(new Tuple(HashName("TS"), "TS")); - data.Add(new Tuple(HashName("USN"), "USN")); + save_mapping.Add(new Tuple(HashName("OWS"), "OWS")); + save_mapping.Add(new Tuple(HashName("LID"), "LID")); + save_mapping.Add(new Tuple(HashName("UID"), "UID")); + save_mapping.Add(new Tuple(HashName("DM"), "DM")); + save_mapping.Add(new Tuple(HashName("CN"), "CN")); + save_mapping.Add(new Tuple(HashName("FL"), "FL")); + save_mapping.Add(new Tuple(HashName("RID"), "RID")); + save_mapping.Add(new Tuple(HashName("PTK"), "PTK")); + save_mapping.Add(new Tuple(HashName("H"), "H")); + save_mapping.Add(new Tuple(HashName("R"), "R")); + save_mapping.Add(new Tuple(HashName("C"), "C")); + save_mapping.Add(new Tuple(HashName("U"), "U")); + save_mapping.Add(new Tuple(HashName("F"), "F")); + save_mapping.Add(new Tuple(HashName("DD"), "DD")); + save_mapping.Add(new Tuple(HashName("UA"), "UA")); + save_mapping.Add(new Tuple(HashName("DT"), "DT")); + save_mapping.Add(new Tuple(HashName("VP"), "VP")); + save_mapping.Add(new Tuple(HashName("TS"), "TS")); + save_mapping.Add(new Tuple(HashName("USN"), "USN")); + // Also add the GcUserSettingsData class - data.Add(new Tuple(HashName("UserSettingsData"), "UserSettingsData")); - UpdateHashes(typeof(libMBIN.NMS.GameComponents.GcUserSettingsData), data); + var account_mapping = new HashSet>(); + // Add UserSettingsData first as it marks the start of this chunk of data + account_mapping.Add(new Tuple(HashName("UserSettingsData"), "UserSettingsData")); + UpdateHashes(typeof(libMBIN.NMS.GameComponents.GcUserSettingsData), account_mapping); + // Add some other values we need (again): + account_mapping.Add(new Tuple(HashName("Version"), "Version")); + var main_data = new Dictionary(); main_data["libMBIN_version"] = libMBIN.Version.AssemblyVersion.ToString(); - main_data["Mapping"] = data; + main_data["Mapping"] = save_mapping.ToList().Concat(account_mapping.ToList()); + // main_data["Mapping_save"] = save_mapping; // alternatively split mapping in 2 + // main_data["Mapping_account"] = account_mapping; + var options = new JsonSerializerOptions { PropertyNamingPolicy = new MappingPolicy(),