Some optimizations
authorunc0rr
Fri, 14 Mar 2014 16:00:36 +0400
changeset 10197 c57798251b55
parent 10196 514e338f2eaf
child 10198 e9cbe111c0df
Some optimizations
hedgewars/uLand.pas
hedgewars/uLandOutline.pas
--- a/hedgewars/uLand.pas	Fri Mar 14 13:59:39 2014 +0400
+++ b/hedgewars/uLand.pas	Fri Mar 14 16:00:36 2014 +0400
@@ -198,7 +198,7 @@
 procedure ColorizeLand(Surface: PSDL_Surface);
 var tmpsurf: PSDL_Surface;
     r: TSDL_Rect;
-    y: LongWord; // stupid SDL 1.2 uses stupid SmallInt for y which limits us to 32767.  But is even worse if LandTex is large, can overflow on 32767 map.
+    y: LongInt; // stupid SDL 1.2 uses stupid SmallInt for y which limits us to 32767.  But is even worse if LandTex is large, can overflow on 32767 map.
 begin
     tmpsurf:= LoadDataImage(ptCurrTheme, 'LandTex', ifCritical or ifIgnoreCaps);
     r.y:= 0;
@@ -306,6 +306,7 @@
     {$HINTS OFF}
     SetPoints(Template, pa, @fps);
     {$HINTS ON}
+    
     for i:= 1 to Template.BezierizeCount do
         begin
         BezierizeEdge(pa, _0_5);
--- a/hedgewars/uLandOutline.pas	Fri Mar 14 13:59:39 2014 +0400
+++ b/hedgewars/uLandOutline.pas	Fri Mar 14 16:00:36 2014 +0400
@@ -113,17 +113,8 @@
     Vx:= int2hwFloat(p1.X - p3.X);
     Vy:= int2hwFloat(p1.Y - p3.Y);
 
-    d:= DistanceI(p2.X - p1.X, p2.Y - p1.Y);
-    d1:= DistanceI(p2.X - p3.X, p2.Y - p3.Y);
     d2:= Distance(Vx, Vy);
 
-    if d1 < d then
-        d:= d1;
-    if d2 < d then
-        d:= d2;
-
-    d:= d * _1div3;
-
     if d2.QWordValue = 0 then
         begin
         Vx:= _0;
@@ -131,12 +122,18 @@
         end
     else
         begin
-        d2:= _1 / d2;
+        d:= DistanceI(p2.X - p1.X, p2.Y - p1.Y);
+        d1:= DistanceI(p2.X - p3.X, p2.Y - p3.Y);
+        
+        if d1 < d then
+            d:= d1;
+        if d2 < d then
+            d:= d2;
+
+        d2:= d * _1div3 / d2;
+        
         Vx:= Vx * d2;
-        Vy:= Vy * d2;
-
-        Vx:= Vx * d;
-        Vy:= Vy * d
+        Vy:= Vy * d2
         end
 end;