diff --git a/SaveGameFixer.cs b/SaveGameFixer.cs index 42d22d83..62f7b7af 100644 --- a/SaveGameFixer.cs +++ b/SaveGameFixer.cs @@ -65,8 +65,12 @@ internal void Awake() // So at this point we know we have won the election, and will be using the class versions as in this assembly. - // Disabled for now since .24 fix the module loading order. - // UpdateSaves(); + UpdateSaves(); + + char ds = Path.DirectorySeparatorChar; + + UpdateCraftDir(Path.Combine(KSPUtil.ApplicationRootPath, string.Format("Ships{0}VAB", ds)), KSPUtil.ApplicationRootPath); + UpdateCraftDir(Path.Combine(KSPUtil.ApplicationRootPath, string.Format("Ships{0}VAB", ds)), KSPUtil.ApplicationRootPath); } catch (Exception ex) { @@ -145,7 +149,7 @@ private void UpdateSaveDir(string saveDir) } } - private void UpdateCraftDir(string dir) + private void UpdateCraftDir(string dir, string rootDir) { string[] files; try @@ -158,14 +162,19 @@ private void UpdateCraftDir(string dir) } foreach (string vabCraft in files) if (vabCraft.EndsWith(".craft")) - UpdateCraft(vabCraft); + UpdateCraft(vabCraft, rootDir); } - private void UpdateCraft(string vabCraft) + private void UpdateCraftDir(string dir) + { + UpdateCraftDir(dir, savesRoot); + } + + private void UpdateCraft(string vabCraft, string rootDir) { try { - PushLogContext("Craft file: " + vabCraft.Substring(savesRoot.Length, vabCraft.Length-savesRoot.Length)); + PushLogContext("Craft file: " + vabCraft.Substring(rootDir.Length, vabCraft.Length-rootDir.Length)); ConfigNode craft = ConfigNode.Load(vabCraft); needsBackup = false; needsSave = false; partMissing = false; @@ -180,7 +189,7 @@ private void UpdateCraft(string vabCraft) WriteDebugMessage("Delete the craft to get rid of this message."); } - BackupAndReplace(vabCraft, craft); + BackupAndReplace(vabCraft, rootDir, craft); } @@ -190,6 +199,11 @@ private void UpdateCraft(string vabCraft) } } + private void UpdateCraft(string vabCraft) + { + UpdateCraft(vabCraft, savesRoot); + } + private void UpdateSFS(string sfsFile) { ConfigNode sfs = ConfigNode.Load(sfsFile); @@ -471,14 +485,14 @@ private void CreateBackupDir() } } - private void BackupAndReplace(string file, ConfigNode config) + private void BackupAndReplace(string file, string rootDir, ConfigNode config) { if (needsBackup) { CreateBackupDir(); - string relPath = file.Substring(savesRoot.Length, file.Length - savesRoot.Length); + string relPath = file.Substring(rootDir.Length, file.Length - rootDir.Length); string backupTo = Path.Combine(backupDir, relPath); // ReSharper disable once AssignNullToNotNullAttribute @@ -493,6 +507,11 @@ private void BackupAndReplace(string file, ConfigNode config) config.Save(file); } + private void BackupAndReplace(string File, ConfigNode config) + { + BackupAndReplace(File, savesRoot, config); + } + #endregion }