Skip to content

Commit

Permalink
Fixed directory checks
Browse files Browse the repository at this point in the history
  • Loading branch information
John committed Mar 31, 2020
1 parent 3c6fef0 commit 6d26fef
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 24 deletions.
1 change: 0 additions & 1 deletion DoomEternal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public class DoomEternal
public const int SteamGameID = 782330;
public static string SteamSavePath = Path.Combine(Utilities.GetSteamPath(), "userdata");
public static string BnetSavePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Saved Games", "id Software", "DOOMEternal", "base", "savegame");
public static string BnetSavePathUnencrypted = Path.Combine(BnetSavePath, "savegame.unencrypted", Environment.UserName);

public static DoomEternalSavePathCollection Saves;

Expand Down
2 changes: 2 additions & 0 deletions DoomEternalSavePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public DoomEternalSavePath(string id, DoomEternalSavePlatform platform, bool enc

public string[] GetRelativePaths() => GetAbsolutePaths().Select(single => single.Replace(FullPath, "").Substring(1)).ToArray();

public bool Exists() => Directory.Exists(FullPath);

public void Zip(string filename) {
using (var fsOut = File.Create(filename))
using (var zs = new ZipOutputStream(fsOut)) {
Expand Down
2 changes: 1 addition & 1 deletion Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public Form1() {
private void Form1_Load(object sender, EventArgs e) {
DoomEternal.EnumerateSaves();

if(!Directory.Exists(DoomEternal.BnetSavePath) && !Directory.Exists(DoomEternal.BnetSavePathUnencrypted) && !Directory.Exists(DoomEternal.SteamSavePath)) {
if(!Directory.Exists(DoomEternal.BnetSavePath) && !Directory.Exists(DoomEternal.SteamSavePath) && !DoomEternal.Saves.GetSave("savegame.unencrypted").Exists()) {
MessageBox.Show("DOOM Eternal wasn't found on your computer!\r\nThe program will now exit...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
Application.Exit();
}
Expand Down
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.0.2")]
[assembly: AssemblyFileVersion("1.3.0.2")]
[assembly: AssemblyVersion("1.3.0.3")]
[assembly: AssemblyFileVersion("1.3.0.3")]
26 changes: 6 additions & 20 deletions TransferForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,14 @@ private void transferOkBtn_Click(object sender, EventArgs e) {
return;
}

if(SrcSave.Platform == DoomEternalSavePlatform.BethesdaNet) {
if (!Directory.Exists(Path.Combine(DoomEternal.BnetSavePath, SrcSave.Identifier)) && !Directory.Exists(Path.Combine(DoomEternal.BnetSavePathUnencrypted, SrcSave.Identifier))) {
MessageBox.Show("Source directory doesn't exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
} else if(SrcSave.Platform == DoomEternalSavePlatform.Steam) {
if (!Directory.Exists(Utilities.GetSavePathForId64(ulong.Parse(SrcSave.Identifier)))) {
MessageBox.Show("Source directory doesn't exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!SrcSave.Exists()) {
MessageBox.Show("Source directory doesn't exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

if (DstSave.Platform == DoomEternalSavePlatform.BethesdaNet) {
if (!Directory.Exists(Path.Combine(DoomEternal.BnetSavePath, DstSave.Identifier)) && !Directory.Exists(Path.Combine(DoomEternal.BnetSavePathUnencrypted, DstSave.Identifier))) {
MessageBox.Show("Destination directory doesn't exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
} else if (DstSave.Platform == DoomEternalSavePlatform.Steam) {
if (!Directory.Exists(Utilities.GetSavePathForId64(ulong.Parse(DstSave.Identifier)))) {
MessageBox.Show("Destination directory doesn't exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (!DstSave.Exists()) {
MessageBox.Show("Destination directory doesn't exist!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}

DialogResult = DialogResult.OK;
Expand Down

0 comments on commit 6d26fef

Please sign in to comment.