From 835d67175200da0e412c69d9ae0b1fb909aee016 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 17 Jul 2011 10:29:00 +1200 Subject: [PATCH] fix 1036 -- GiveUnitCrateAction can give units which don't have BuildableInfo, to anyone --- OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs b/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs index 0d42e55957..ed574a98dd 100644 --- a/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/GiveUnitCrateAction.cs @@ -32,11 +32,11 @@ namespace OpenRA.Mods.RA.Crates public override int GetSelectionShares(Actor collector) { - var bi = Rules.Info[Info.Unit].Traits.Get(); + var bi = Rules.Info[Info.Unit].Traits.GetOrDefault(); // this unit is not buildable by the collector's country, so // don't give them free ones either. - if (!bi.Owner.Contains(collector.Owner.Country.Race)) return 0; + if (bi != null && !bi.Owner.Contains(collector.Owner.Country.Race)) return 0; // avoid dumping tanks in the sea, and ships on dry land. if (!GetSuitableCells(collector.Location).Any()) return 0;