Preload sequences and fix #5382

This commit is contained in:
Pavlos Touboulidis
2014-05-21 22:56:59 +03:00
parent df0d1360dd
commit 531338a955
3 changed files with 41 additions and 8 deletions

View File

@@ -58,6 +58,21 @@ namespace OpenRA.Graphics
return unitSeq.Value.Keys;
}
public void Preload()
{
foreach (var unitSeq in sequences.Value.Values)
{
try
{
foreach (var seq in unitSeq.Value.Values);
}
catch (FileNotFoundException ex)
{
Log.Write("debug", ex.Message);
}
}
}
}
public class SequenceCache
@@ -100,8 +115,11 @@ namespace OpenRA.Graphics
else
{
t = Exts.Lazy(() => (IReadOnlyDictionary<string, Sequence>)new ReadOnlyDictionary<string, Sequence>(
node.Value.NodesDict.ToDictionary(x => x.Key, x =>
new Sequence(spriteLoader.Value, node.Key, x.Key, x.Value))));
node.Value.NodesDict.ToDictionary(x => x.Key, x =>
{
using (new Support.PerfTimer("new Sequence(\"{0}\")".F(node.Key), 20))
return new Sequence(spriteLoader.Value, node.Key, x.Key, x.Value);
})));
sequenceCache.Add(key, t);
items.Add(node.Key, t);
}