rope: another small optimization
authorsheepluva
Tue, 29 Jun 2010 06:27:59 +0200
changeset 3584 7c05f2e0a8b5
parent 3583 13818670ad9e
child 3585 39570d86de57
rope: another small optimization
hedgewars/GSHandlers.inc
hedgewars/uFloat.pas
--- a/hedgewars/GSHandlers.inc	Tue Jun 29 05:22:25 2010 +0200
+++ b/hedgewars/GSHandlers.inc	Tue Jun 29 06:27:59 2010 +0200
@@ -1153,10 +1153,6 @@
 
     haveDivided := false;
     // check whether rope needs dividing
-    len := _1 / Distance(ropeDx, ropeDy);
-    // old rope pos
-    nx := ropeDx * len;
-    ny := ropeDy * len;
 
     len := Gear^.Elasticity - _5;
     while len > _3 do
@@ -1166,6 +1162,15 @@
         if ((ly and LAND_HEIGHT_MASK) = 0) and ((lx and LAND_WIDTH_MASK) = 0) and (Land[ly, lx] <> 0
            ) then
         begin
+            // calculate those the first time we have to divide the rope
+            if not haveDivided then
+            begin
+            ny := _1 / Distance(ropeDx, ropeDy);
+            // old rope pos
+            nx := ropeDx * ny;
+            ny := ropeDy * ny;
+            end;
+
             with RopePoints.ar[RopePoints.Count] do
             begin
                 X := Gear^.X;
--- a/hedgewars/uFloat.pas	Tue Jun 29 05:22:25 2010 +0200
+++ b/hedgewars/uFloat.pas	Tue Jun 29 06:27:59 2010 +0200
@@ -108,10 +108,10 @@
            _0_96: hwFloat = (isNegative: false; QWordValue:  4123168604);
           _0_995: hwFloat = (isNegative: false; QWordValue:  4273492459);
           _0_999: hwFloat = (isNegative: false; QWordValue:  4290672328);
-            _1_9: hwFloat = (isNegative: false; QWordValue:  8160437862);
               _0: hwFloat = (isNegative: false; QWordValue:           0);
               _1: hwFloat = (isNegative: false; QWordValue:  4294967296);
             _1_5: hwFloat = (isNegative: false; QWordValue:  4294967296 * 3 div 2);
+            _1_9: hwFloat = (isNegative: false; QWordValue:  8160437862);
               _2: hwFloat = (isNegative: false; QWordValue:  4294967296 * 2);
               _3: hwFloat = (isNegative: false; QWordValue:  4294967296 * 3);
               _4: hwFloat = (isNegative: false; QWordValue:  4294967296 * 4);