From 5eb3d2ea2dea17cc594e3b4ec927558af11ec660 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@993157c7-ee19-0410-b2c4-bb4e9862e678> Date: Mon, 23 Jul 2007 05:27:40 +0000 Subject: [PATCH] git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1322 993157c7-ee19-0410-b2c4-bb4e9862e678 --- OpenRa.Game/Unit.cs | 54 ++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/OpenRa.Game/Unit.cs b/OpenRa.Game/Unit.cs index 2cc6fe1aee..bfdaadc3ce 100644 --- a/OpenRa.Game/Unit.cs +++ b/OpenRa.Game/Unit.cs @@ -71,40 +71,40 @@ namespace OpenRa.Game { nextOrder = delegate( Game game, double t ) { - int speed = (int)( t * ( Speed * 100 ) ); - if( nextOrder != null ) destination = toCell; int desiredFacing = GetFacing( toCell - fromCell ); if( facing != desiredFacing ) - Turn( desiredFacing ); - else { - moveFraction += speed; - if( moveFraction >= moveFractionTotal ) - { - moveFraction = 0; - moveFractionTotal = 0; - fromCell = toCell; - - if( toCell == destination ) - currentOrder = null; - else - { - List res = game.pathFinder.FindUnitPath( this, PathFinder.DefaultEstimator( destination ) ); - if( res.Count != 0 ) - { - toCell = res[ res.Count - 1 ]; - - int2 dir = toCell - fromCell; - moveFractionTotal = ( dir.X != 0 && dir.Y != 0 ) ? 250 : 200; - } - else - destination = toCell; - } - } + Turn( desiredFacing ); + return; } + + moveFraction += (int)( t * ( Speed * 100 ) ); + if( moveFraction < moveFractionTotal ) + return; + + moveFraction = 0; + moveFractionTotal = 0; + fromCell = toCell; + + if( toCell == destination ) + { + currentOrder = null; + return; + } + + List res = game.pathFinder.FindUnitPath( this, PathFinder.DefaultEstimator( destination ) ); + if( res.Count != 0 ) + { + toCell = res[ res.Count - 1 ]; + + int2 dir = toCell - fromCell; + moveFractionTotal = ( dir.X != 0 && dir.Y != 0 ) ? 250 : 200; + } + else + destination = toCell; }; }