fix 1036 -- GiveUnitCrateAction can give units which don't have BuildableInfo, to anyone

This commit is contained in:
Chris Forbes
2011-07-17 10:29:00 +12:00
parent 6a99ff7931
commit 835d671752

View File

@@ -32,11 +32,11 @@ namespace OpenRA.Mods.RA.Crates
public override int GetSelectionShares(Actor collector)
{
var bi = Rules.Info[Info.Unit].Traits.Get<BuildableInfo>();
var bi = Rules.Info[Info.Unit].Traits.GetOrDefault<BuildableInfo>();
// 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;