Fix crashes in WeaponInfo when warheads or projectiles cannot be created
This commit is contained in:
@@ -139,7 +139,11 @@ namespace OpenRA.GameRules
|
|||||||
{
|
{
|
||||||
if (!yaml.ToDictionary().TryGetValue("Projectile", out var proj))
|
if (!yaml.ToDictionary().TryGetValue("Projectile", out var proj))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var ret = Game.CreateObject<IProjectileInfo>(proj.Value + "Info");
|
var ret = Game.CreateObject<IProjectileInfo>(proj.Value + "Info");
|
||||||
|
if (ret == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
FieldLoader.Load(ret, proj);
|
FieldLoader.Load(ret, proj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -150,6 +154,9 @@ namespace OpenRA.GameRules
|
|||||||
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
|
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
|
||||||
{
|
{
|
||||||
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
|
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
|
||||||
|
if (ret == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
FieldLoader.Load(ret, node.Value);
|
FieldLoader.Load(ret, node.Value);
|
||||||
retList.Add(ret);
|
retList.Add(ret);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user