fix attack crashing game

This commit is contained in:
Alli
2010-01-06 20:49:08 +13:00
parent f6510de995
commit 7579366f54

View File

@@ -26,10 +26,13 @@ namespace OpenRa.Game.Traits
protected override void QueueAttack( Actor self, Order order )
{
var b = self.traits.Get<Building>();
if (b != null && b.InsuffientPower())
return;
if (self.traits.Contains<Building>())
{
var b = self.traits.Get<Building>();
if (b != null && b.InsuffientPower())
return;
}
const int RangeTolerance = 1; /* how far inside our maximum range we should try to sit */
/* todo: choose the appropriate weapon, when only one works against this target */
var weapon = order.Subject.Info.Primary ?? order.Subject.Info.Secondary;
@@ -39,6 +42,7 @@ namespace OpenRa.Game.Traits
Math.Max( 0, (int)Rules.WeaponInfo[ weapon ].Range - RangeTolerance ) ) );
target = order.TargetActor;
}
bool buildComplete = false;