add new long WRange.RangeSquared to avoid integer overflows

This commit is contained in:
Matthias Mailänder
2015-05-31 23:51:30 +02:00
parent 79edf648a7
commit ea5003cd2d
15 changed files with 18 additions and 22 deletions

View File

@@ -56,7 +56,7 @@ namespace OpenRA.Mods.D2k.Traits
public void RequestTransport(CPos destination, Activity afterLandActivity)
{
var destPos = self.World.Map.CenterOfCell(destination);
if (destination == CPos.Zero || (self.CenterPosition - destPos).LengthSquared < info.MinDistance.Range * info.MinDistance.Range)
if (destination == CPos.Zero || (self.CenterPosition - destPos).LengthSquared < info.MinDistance.RangeSquared)
{
WantsTransport = false; // Be sure to cancel any pending transports
return;
@@ -120,7 +120,7 @@ namespace OpenRA.Mods.D2k.Traits
return false;
var destPos = self.World.Map.CenterOfCell(Destination);
if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.Range * info.MinDistance.Range)
if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.RangeSquared)
{
MovementCancelled(self);
return false;
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.D2k.Traits
// Last change to change our mind...
var destPos = self.World.Map.CenterOfCell(Destination);
if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.Range * info.MinDistance.Range)
if ((self.CenterPosition - destPos).LengthSquared < info.MinDistance.RangeSquared)
{
MovementCancelled(self);
return false;