Fix crashes in WeaponInfo when warheads or projectiles cannot be created

This commit is contained in:
abcdefg30
2022-06-22 16:58:08 +02:00
committed by Paul Chote
parent 185bef39b0
commit 82692b9d7f

View File

@@ -139,7 +139,11 @@ namespace OpenRA.GameRules
{
if (!yaml.ToDictionary().TryGetValue("Projectile", out var proj))
return null;
var ret = Game.CreateObject<IProjectileInfo>(proj.Value + "Info");
if (ret == null)
return null;
FieldLoader.Load(ret, proj);
return ret;
}
@@ -150,6 +154,9 @@ namespace OpenRA.GameRules
foreach (var node in yaml.Nodes.Where(n => n.Key.StartsWith("Warhead")))
{
var ret = Game.CreateObject<IWarhead>(node.Value.Value + "Warhead");
if (ret == null)
continue;
FieldLoader.Load(ret, node.Value);
retList.Add(ret);
}