From e76dbcd4bf6feba38da2ce07693b206bf3fe6ca2 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 8 Dec 2013 21:34:49 +1300 Subject: [PATCH] Silently ignore bogus prerequisites instead of crashing. Fixes #4225. --- OpenRA.Mods.RA/Player/TechTree.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.RA/Player/TechTree.cs b/OpenRA.Mods.RA/Player/TechTree.cs index 7e78e0a60b..32bd2f2ec3 100755 --- a/OpenRA.Mods.RA/Player/TechTree.cs +++ b/OpenRA.Mods.RA/Player/TechTree.cs @@ -63,10 +63,20 @@ namespace OpenRA.Mods.RA return ret; // Add buildables that provide prerequisites - foreach (var b in player.World.ActorsWithTrait() - .Where(a => a.Actor.IsInWorld && !a.Actor.IsDead() && a.Actor.Owner == player)) + var prereqs = player.World.ActorsWithTrait() + .Where(a => a.Actor.Owner == player && !a.Actor.IsDead() && a.Actor.IsInWorld); + + foreach (var b in prereqs) + { foreach (var p in b.Trait.ProvidesPrerequisites) - ret[ p ].Add( b.Actor ); + { + // Ignore bogus prerequisites + if (p == null) + continue; + + ret[p].Add(b.Actor); + } + } // Add buildables that have a build limit set and are not already in the list player.World.ActorsWithTrait()