From ad3b41dfa334274009d7294c24b49ac04bef0a34 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Mon, 14 Mar 2016 15:24:33 +0100 Subject: [PATCH] Fix the --png command trying to use OpenRA's virtual file system --- OpenRA.Game/Graphics/SpriteLoader.cs | 19 ++++++++++++++----- .../ConvertSpriteToPngCommand.cs | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/OpenRA.Game/Graphics/SpriteLoader.cs b/OpenRA.Game/Graphics/SpriteLoader.cs index 56701b85eb..df00bc1531 100644 --- a/OpenRA.Game/Graphics/SpriteLoader.cs +++ b/OpenRA.Game/Graphics/SpriteLoader.cs @@ -78,13 +78,22 @@ namespace OpenRA.Graphics { using (var stream = fileSystem.Open(filename)) { - ISpriteFrame[] frames; - foreach (var loader in loaders) - if (loader.TryParseSprite(stream, out frames)) - return frames; + var spriteFrames = GetFrames(stream, loaders); + if (spriteFrames == null) + throw new InvalidDataException(filename + " is not a valid sprite file!"); - throw new InvalidDataException(filename + " is not a valid sprite file!"); + return spriteFrames; } } + + public static ISpriteFrame[] GetFrames(Stream stream, ISpriteLoader[] loaders) + { + ISpriteFrame[] frames; + foreach (var loader in loaders) + if (loader.TryParseSprite(stream, out frames)) + return frames; + + return null; + } } } diff --git a/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs index b126876a34..01e7ec034d 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ConvertSpriteToPngCommand.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var palette = new ImmutablePalette(args[2], shadowIndex); - var frames = SpriteLoader.GetFrames(modData.DefaultFileSystem, src, modData.SpriteLoaders); + var frames = SpriteLoader.GetFrames(File.OpenRead(src), modData.SpriteLoaders); var usePadding = !args.Contains("--nopadding"); var count = 0;