(c590657d2) Don't retry decompressing save files or loading sub files if the file doesn't exist

This commit is contained in:
Joonas Rikkonen
2019-03-26 17:10:06 +02:00
parent 93f2dfb185
commit 555d91a3d5
2 changed files with 5 additions and 5 deletions
@@ -323,7 +323,7 @@ namespace Barotrauma
for (int i = 0; i <= maxLoadRetries; i++) for (int i = 0; i <= maxLoadRetries; i++)
{ {
doc = OpenFile(filePath); doc = OpenFile(filePath);
if (doc != null || i == maxLoadRetries) { break; } if (doc != null || i == maxLoadRetries || !File.Exists(filePath)) { break; }
DebugConsole.NewMessage("Opening submarine file \"" + filePath + "\" failed, retrying in 250 ms..."); DebugConsole.NewMessage("Opening submarine file \"" + filePath + "\" failed, retrying in 250 ms...");
Thread.Sleep(250); Thread.Sleep(250);
} }
@@ -1192,7 +1192,7 @@ namespace Barotrauma
for (int i = 0; i <= maxLoadRetries; i++) for (int i = 0; i <= maxLoadRetries; i++)
{ {
doc = OpenFile(filePath); doc = OpenFile(filePath);
if (doc != null || i == maxLoadRetries) { break; } if (doc != null || i == maxLoadRetries || !File.Exists(filePath)) { break; }
DebugConsole.NewMessage("Loading the submarine \"" + Name + "\" failed, retrying in 250 ms..."); DebugConsole.NewMessage("Loading the submarine \"" + Name + "\" failed, retrying in 250 ms...");
Thread.Sleep(250); Thread.Sleep(250);
} }
@@ -169,7 +169,7 @@ namespace Barotrauma
if (!Directory.Exists(folder)) if (!Directory.Exists(folder))
{ {
DebugConsole.Log("Save folder \"" + folder + " not found! Attempting to create a new folder"); DebugConsole.Log("Save folder \"" + folder + " not found! Attempting to create a new folder...");
try try
{ {
Directory.CreateDirectory(folder); Directory.CreateDirectory(folder);
@@ -358,8 +358,8 @@ namespace Barotrauma
} }
catch (IOException e) catch (IOException e)
{ {
if (i >= maxRetries) { throw; } if (i >= maxRetries || !File.Exists(sCompressedFile)) { throw; }
DebugConsole.NewMessage("Failed to initiate a file transfer {" + e.Message + "}, retrying in 250 ms...", Color.Red); DebugConsole.NewMessage("Failed decompress file \"" + sCompressedFile + "\" {" + e.Message + "}, retrying in 250 ms...", Color.Red);
Thread.Sleep(250); Thread.Sleep(250);
} }
} }