(98ad00fa2) v0.9.1.0

This commit is contained in:
Joonas Rikkonen
2019-07-10 13:52:12 +03:00
parent 2a791887ed
commit afa2137bd2
104 changed files with 3041 additions and 3134 deletions
@@ -297,6 +297,12 @@ namespace Barotrauma
}
}
public bool IsFileCorrupted
{
get;
private set;
}
//constructors & generation ----------------------------------------------------
public Submarine(string filePath, string hash = "", bool tryLoad = true) : base(null)
@@ -322,12 +328,17 @@ namespace Barotrauma
int maxLoadRetries = 4;
for (int i = 0; i <= maxLoadRetries; i++)
{
doc = OpenFile(filePath);
doc = OpenFile(filePath, out Exception e);
if (e != null && !(e is IOException)) { break; }
if (doc != null || i == maxLoadRetries || !File.Exists(filePath)) { break; }
DebugConsole.NewMessage("Opening submarine file \"" + filePath + "\" failed, retrying in 250 ms...");
Thread.Sleep(250);
}
if (doc == null || doc.Root == null) { return; }
if (doc == null || doc.Root == null)
{
IsFileCorrupted = true;
return;
}
if (doc != null && doc.Root != null)
{
@@ -1139,7 +1150,11 @@ namespace Barotrauma
savedSubmarines[i].Dispose();
}
}
savedSubmarines.Add(new Submarine(filePath));
var sub = new Submarine(filePath);
if (!sub.IsFileCorrupted)
{
savedSubmarines.Add(sub);
}
savedSubmarines = savedSubmarines.OrderBy(s => s.filePath ?? "").ToList();
}
@@ -1193,16 +1208,26 @@ namespace Barotrauma
foreach (string path in filePaths)
{
savedSubmarines.Add(new Submarine(path));
var sub = new Submarine(path);
if (!sub.IsFileCorrupted)
{
savedSubmarines.Add(sub);
}
}
}
static readonly string TempFolder = Path.Combine("Submarine", "Temp");
public static XDocument OpenFile(string file)
{
return OpenFile(file, out _);
}
public static XDocument OpenFile(string file, out Exception exception)
{
XDocument doc = null;
string extension = "";
exception = null;
try
{
@@ -1229,6 +1254,7 @@ namespace Barotrauma
}
catch (Exception e)
{
exception = e;
DebugConsole.ThrowError("Loading submarine \"" + file + "\" failed!", e);
return null;
}
@@ -1243,6 +1269,7 @@ namespace Barotrauma
catch (Exception e)
{
exception = e;
DebugConsole.ThrowError("Loading submarine \"" + file + "\" failed! (" + e.Message + ")");
return null;
}
@@ -1257,6 +1284,7 @@ namespace Barotrauma
catch (Exception e)
{
exception = e;
DebugConsole.ThrowError("Loading submarine \"" + file + "\" failed! (" + e.Message + ")");
return null;
}