Fix an NRE during building placement under rare circumstances

Happens when the last conyard vanishes at the same time a building
is picked up for placement.
This commit is contained in:
Oliver Brakmann
2015-07-11 11:46:40 +02:00
parent bd12a742f1
commit dd89aa1d48

View File

@@ -49,7 +49,8 @@ namespace OpenRA.Mods.Common.Orders
buildingInfo = info.Traits.Get<BuildingInfo>();
var buildableInfo = info.Traits.Get<BuildableInfo>();
race = buildableInfo.ForceRace ?? queue.MostLikelyProducer().Trait.Race;
var mostLikelyProducer = queue.MostLikelyProducer();
race = buildableInfo.ForceRace ?? (mostLikelyProducer.Trait != null ? mostLikelyProducer.Trait.Race : producer.Owner.Country.Race);
buildOk = map.SequenceProvider.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
buildBlocked = map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);