aboutsummaryrefslogtreecommitdiff
path: root/TimeHACK.Main
diff options
context:
space:
mode:
authorRogueAI42 <[email protected]>2017-07-23 22:09:41 +1000
committerRogueAI42 <[email protected]>2017-07-23 22:09:41 +1000
commitbc9623bbdf635cc16cc95f8a86a241a6933a8fdd (patch)
treeb9e2c5f7861799b7b5f209046f97052493565734 /TimeHACK.Main
parentc446a76e0c5b7b35638f1e223ad167b46f30941e (diff)
downloadhistacom2-bc9623bbdf635cc16cc95f8a86a241a6933a8fdd.tar.gz
histacom2-bc9623bbdf635cc16cc95f8a86a241a6933a8fdd.tar.bz2
histacom2-bc9623bbdf635cc16cc95f8a86a241a6933a8fdd.zip
i goofed
This reverts commit c446a76e0c5b7b35638f1e223ad167b46f30941e.
Diffstat (limited to 'TimeHACK.Main')
-rw-r--r--TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs27
1 files changed, 12 insertions, 15 deletions
diff --git a/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
index 410d2d6..5ec84be 100644
--- a/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
+++ b/TimeHACK.Main/SaveDialogs/SaveFileTroubleShooter.cs
@@ -15,7 +15,7 @@ namespace TimeHACK.SaveDialogs
public partial class SaveFileTroubleShooter : Form
{
public string log;
- Save savedata;
+ Save savedata = new Save();
string json;
public SaveFileTroubleShooter()
{
@@ -43,9 +43,7 @@ namespace TimeHACK.SaveDialogs
// Check if the main.save file exists
- string savefile = Path.Combine(SaveSystem.ProfileDirectory, "main.save");
-
- if (!File.Exists(savefile))
+ if (!File.Exists(Path.Combine(SaveSystem.ProfileDirectory, "main.save")))
{
WriteToLog("ISSUE FOUND! File main.save doesn't exist");
@@ -60,9 +58,12 @@ namespace TimeHACK.SaveDialogs
} else {
WriteToLog("File main.save does exist - checking contents");
+ // Read the main.save file
+ json = File.ReadAllText(Path.Combine(SaveSystem.ProfileDirectory, "main.save"));
+
try
{
- savedata = SaveSystem.ReadSave(savefile);
+ savedata = Newtonsoft.Json.JsonConvert.DeserializeObject<Save>(json);
} catch
{
@@ -70,18 +71,16 @@ namespace TimeHACK.SaveDialogs
WriteToLog("Sorry, there is no repairing it easily, your data will be lost");
- string backupfile = Path.Combine(SaveSystem.ProfileDirectory, "main.backup");
+ if (Directory.Exists(Path.Combine(SaveSystem.ProfileDirectory, "main.backup"))) Directory.Delete(Path.Combine(SaveSystem.ProfileDirectory, "main.backup"));
- if (Directory.Exists(backupfile)) Directory.Delete(backupfile);
-
- File.Copy(savefile, backupfile);
+ File.Copy(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), Path.Combine(SaveSystem.ProfileDirectory, "main.backup"));
SaveSystem.NewGame();
// Make sure the username is set
SaveSystem.CurrentSave.Username = SaveSystem.ProfileName;
- WriteToLog($"The corrupt file has been stored in {backupfile}");
+ WriteToLog($"The corrupt file has been stored in {Path.Combine(SaveSystem.ProfileDirectory, "main.backup")}");
EndScan(true);
}
@@ -109,12 +108,10 @@ namespace TimeHACK.SaveDialogs
}
}
- string folderspath = Path.Combine(SaveSystem.ProfileDirectory, "folders");
-
- if (!Directory.Exists(folderspath))
+ if (!Directory.Exists(Path.Combine(SaveSystem.ProfileDirectory, "folders")))
{
WriteToLog("ISSUE FOUND! Directory 'folders' doesn't exist! Creating one...");
- Directory.CreateDirectory(folderspath);
+ Directory.CreateDirectory(Path.Combine(SaveSystem.ProfileDirectory, "folders"));
SaveSystem.CheckFiles();
}
@@ -133,7 +130,7 @@ namespace TimeHACK.SaveDialogs
// Set the main.save file to the resolved one
- SaveSystem.WriteSave(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), savedata);
+ File.WriteAllText(Path.Combine(SaveSystem.ProfileDirectory, "main.save"), Newtonsoft.Json.JsonConvert.SerializeObject(savedata, Newtonsoft.Json.Formatting.Indented));
textBox1.Text = log;
} else {