(99feac023) Unstable 0.9.704.0
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
@@ -283,16 +284,23 @@ namespace Barotrauma
|
||||
Removed = true;
|
||||
}
|
||||
|
||||
public static void DumpIds(int count)
|
||||
public static void DumpIds(int count, string filename)
|
||||
{
|
||||
List<Entity> entities = dictionary.Values.OrderByDescending(e => e.id).ToList();
|
||||
|
||||
count = Math.Min(entities.Count, count);
|
||||
|
||||
List<string> lines = new List<string>();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
lines.Add(entities[i].id + ": " + entities[i].ToString());
|
||||
DebugConsole.ThrowError(entities[i].id + ": " + entities[i].ToString());
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
File.WriteAllLines(filename, lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SaveToCache(string filename, long? time=null)
|
||||
public void SaveToCache(string filename, long? time = null)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
@@ -191,9 +191,26 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public static string GetShortHash(string fullHash)
|
||||
{
|
||||
{
|
||||
if (string.IsNullOrEmpty(fullHash)) { return ""; }
|
||||
return fullHash.Length < 7 ? fullHash : fullHash.Substring(0, 7);
|
||||
}
|
||||
|
||||
public static bool RemoveFromCache(string filename)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(filename))
|
||||
{
|
||||
filename = filename.CleanUpPath();
|
||||
lock (cache)
|
||||
{
|
||||
if (cache.ContainsKey(filename))
|
||||
{
|
||||
cache.Remove(filename);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,6 +173,7 @@ namespace Barotrauma
|
||||
XDocument doc = OpenFile(filePath);
|
||||
StartHashDocTask(doc);
|
||||
hashTask.Wait();
|
||||
hashTask = null;
|
||||
}
|
||||
|
||||
return hash;
|
||||
@@ -343,7 +344,10 @@ namespace Barotrauma
|
||||
public Submarine(string filePath, string hash = "", bool tryLoad = true) : base(null)
|
||||
{
|
||||
this.filePath = filePath;
|
||||
LastModifiedTime = File.GetLastWriteTime(filePath);
|
||||
if (!string.IsNullOrEmpty(filePath) && File.Exists(filePath))
|
||||
{
|
||||
LastModifiedTime = File.GetLastWriteTime(filePath);
|
||||
}
|
||||
try
|
||||
{
|
||||
name = displayName = Path.GetFileNameWithoutExtension(filePath);
|
||||
@@ -1631,6 +1635,10 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
hash = null;
|
||||
hashTask = null;
|
||||
Md5Hash.RemoveFromCache(filePath);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user