fixes crash on production structure being destroyed; refund instead

This commit is contained in:
Chris Forbes
2009-11-18 19:26:58 +13:00
parent de05f58aef
commit 00d633cbeb

View File

@@ -342,7 +342,7 @@ namespace OpenRa.Game
&& producerTypes.Contains(a.unitInfo.Name) && a.Owner == player); && producerTypes.Contains(a.unitInfo.Name) && a.Owner == player);
if (producer == null) if (producer == null)
throw new InvalidOperationException("BuildUnit without suitable production structure!"); player.CancelProduction(Rules.UnitCategory[name]);
Actor unit; Actor unit;
@@ -375,7 +375,7 @@ namespace OpenRa.Game
} }
world.Add(unit); world.Add(unit);
player.FinishProduction( Rules.UnitCategory[ unit.unitInfo.Name ] ); player.FinishProduction(Rules.UnitCategory[name]);
if (producer.traits.Contains<RenderWarFactory>()) if (producer.traits.Contains<RenderWarFactory>())
producer.traits.Get<RenderWarFactory>().EjectUnit(); producer.traits.Get<RenderWarFactory>().EjectUnit();