Fix a crash in --clear-invalid-mod-registrations
This commit is contained in:
committed by
Matthias Mailänder
parent
f86d96794d
commit
5fa1dec6d8
@@ -59,6 +59,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
public ExternalMods()
|
public ExternalMods()
|
||||||
{
|
{
|
||||||
|
// Don't try to load mod icons if we don't have a texture to put them in
|
||||||
|
if (Game.Renderer != null)
|
||||||
sheetBuilder = new SheetBuilder(SheetType.BGRA, CreateSheet);
|
sheetBuilder = new SheetBuilder(SheetType.BGRA, CreateSheet);
|
||||||
|
|
||||||
// Several types of support directory types are available, depending on
|
// Several types of support directory types are available, depending on
|
||||||
@@ -94,6 +96,9 @@ namespace OpenRA
|
|||||||
void LoadMod(MiniYaml yaml, string path = null, bool forceRegistration = false)
|
void LoadMod(MiniYaml yaml, string path = null, bool forceRegistration = false)
|
||||||
{
|
{
|
||||||
var mod = FieldLoader.Load<ExternalMod>(yaml);
|
var mod = FieldLoader.Load<ExternalMod>(yaml);
|
||||||
|
|
||||||
|
if (sheetBuilder != null)
|
||||||
|
{
|
||||||
var iconNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Icon");
|
var iconNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Icon");
|
||||||
if (iconNode != null && !string.IsNullOrEmpty(iconNode.Value.Value))
|
if (iconNode != null && !string.IsNullOrEmpty(iconNode.Value.Value))
|
||||||
using (var stream = new MemoryStream(Convert.FromBase64String(iconNode.Value.Value)))
|
using (var stream = new MemoryStream(Convert.FromBase64String(iconNode.Value.Value)))
|
||||||
@@ -108,6 +113,7 @@ namespace OpenRA
|
|||||||
if (icon3xNode != null && !string.IsNullOrEmpty(icon3xNode.Value.Value))
|
if (icon3xNode != null && !string.IsNullOrEmpty(icon3xNode.Value.Value))
|
||||||
using (var stream = new MemoryStream(Convert.FromBase64String(icon3xNode.Value.Value)))
|
using (var stream = new MemoryStream(Convert.FromBase64String(icon3xNode.Value.Value)))
|
||||||
mod.Icon3x = sheetBuilder.Add(new Png(stream), 1f / 3);
|
mod.Icon3x = sheetBuilder.Add(new Png(stream), 1f / 3);
|
||||||
|
}
|
||||||
|
|
||||||
// Avoid possibly overwriting a valid mod with an obviously bogus one
|
// Avoid possibly overwriting a valid mod with an obviously bogus one
|
||||||
var key = ExternalMod.MakeKey(mod);
|
var key = ExternalMod.MakeKey(mod);
|
||||||
|
|||||||
Reference in New Issue
Block a user