From 38b5a8d4f822eac029cd04d45d5b840c08ed5862 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sat, 3 Mar 2012 18:17:21 +1300 Subject: [PATCH] Fix #1327 - div/0 in Drag with extreme movement speeds --- OpenRA.Mods.RA/Move/Drag.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/Move/Drag.cs b/OpenRA.Mods.RA/Move/Drag.cs index f58eb4c818..909cefd703 100755 --- a/OpenRA.Mods.RA/Move/Drag.cs +++ b/OpenRA.Mods.RA/Move/Drag.cs @@ -18,6 +18,7 @@ namespace OpenRA.Mods.RA.Move int2 endLocation; int2 startLocation; int length; + int ticks = 0; public Drag(int2 start, int2 end, int length) { @@ -26,17 +27,19 @@ namespace OpenRA.Mods.RA.Move this.length = length; } - int ticks = 0; public override Activity Tick( Actor self ) { var mobile = self.Trait(); - mobile.PxPosition = int2.Lerp(startLocation, endLocation, ticks, length - 1); + mobile.PxPosition = length > 1 + ? int2.Lerp(startLocation, endLocation, ticks, length - 1) + : endLocation; if (++ticks >= length) { mobile.IsMoving = false; return NextActivity; } + mobile.IsMoving = true; return this; }