You can't just exit function which is supposed to do copy
authorunc0rr
Mon, 10 Nov 2014 21:57:44 +0300
changeset 10485 05b771423b95
parent 10484 2dea4070904a
child 10486 5e2d26bcafd6
You can't just exit function which is supposed to do copy
hedgewars/uLandOutline.pas
--- a/hedgewars/uLandOutline.pas	Mon Nov 10 13:54:57 2014 -0500
+++ b/hedgewars/uLandOutline.pas	Mon Nov 10 21:57:44 2014 +0300
@@ -144,55 +144,57 @@
     tsq, tcb, t, r1, r2, r3, cx1, cx2, cy1, cy2: hwFloat;
     X, Y: LongInt;
 begin
-if pa.Count >= cMaxEdgePoints-1 then exit;
-pi:= EndI;
-i:= StartI;
-ni:= Succ(StartI);
-{$HINTS OFF}
-Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy);
-{$HINTS ON}
-repeat
-    inc(pi);
-    if pi > EndI then
-        pi:= StartI;
-    inc(i);
-    if i > EndI then
+    if pa.Count < cMaxEdgePoints - 2 then
+        begin
+        pi:= EndI;
         i:= StartI;
-    inc(ni);
-    if ni > EndI then
-        ni:= StartI;
-    PVx:= NVx;
-    PVy:= NVy;
-    Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy);
+        ni:= Succ(StartI);
+        {$HINTS OFF}
+        Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy);
+        {$HINTS ON}
+        repeat
+            i:= ni;
+            inc(pi);
+            if pi > EndI then
+                pi:= StartI;
+            inc(ni);
+            if ni > EndI then
+                ni:= StartI;
+            PVx:= NVx;
+            PVy:= NVy;
+            Vector(opa.ar[pi], opa.ar[i], opa.ar[ni], NVx, NVy);
+
+            x1:= opa.ar[pi].x;
+            y1:= opa.ar[pi].y;
+            x2:= opa.ar[i].x;
+            y2:= opa.ar[i].y;
 
-    x1:= opa.ar[pi].x;
-    y1:= opa.ar[pi].y;
-    x2:= opa.ar[i].x;
-    y2:= opa.ar[i].y;
-    cx1:= int2hwFloat(x1) - PVx;
-    cy1:= int2hwFloat(y1) - PVy;
-    cx2:= int2hwFloat(x2) + NVx;
-    cy2:= int2hwFloat(y2) + NVy;
-    t:= _0;
-    while (t.Round = 0) and (pa.Count < cMaxEdgePoints-2) do
-        begin
-        tsq:= t * t;
-        tcb:= tsq * t;
-        r1:= (_1 - t*3 + tsq*3 - tcb);
-        r2:= (     t*3 - tsq*6 + tcb*3);
-        r3:= (           tsq*3 - tcb*3);
-        X:= hwRound(r1 * x1 + r2 * cx1 + r3 * cx2 + tcb * x2);
-        Y:= hwRound(r1 * y1 + r2 * cy1 + r3 * cy2 + tcb * y2);
-        t:= t + Delta;
-        pa.ar[pa.Count].x:= X;
-        pa.ar[pa.Count].y:= Y;
-        inc(pa.Count);
-        //TryDo(pa.Count <= cMaxEdgePoints, 'Edge points overflow', true)
+            cx1:= int2hwFloat(x1) - PVx;
+            cy1:= int2hwFloat(y1) - PVy;
+            cx2:= int2hwFloat(x2) + NVx;
+            cy2:= int2hwFloat(y2) + NVy;
+            t:= _0;
+            while (t.Round = 0) and (pa.Count < cMaxEdgePoints-2) do
+                begin
+                tsq:= t * t;
+                tcb:= tsq * t;
+                r1:= (_1 - t*3 + tsq*3 - tcb);
+                r2:= (     t*3 - tsq*6 + tcb*3);
+                r3:= (           tsq*3 - tcb*3);
+                X:= hwRound(r1 * x1 + r2 * cx1 + r3 * cx2 + tcb * x2);
+                Y:= hwRound(r1 * y1 + r2 * cy1 + r3 * cy2 + tcb * y2);
+                t:= t + Delta;
+                pa.ar[pa.Count].x:= X;
+                pa.ar[pa.Count].y:= Y;
+                inc(pa.Count);
+                //TryDo(pa.Count <= cMaxEdgePoints, 'Edge points overflow', true)
+                end;
+        until i = StartI;
         end;
-until i = StartI;
-pa.ar[pa.Count].x:= opa.ar[StartI].X;
-pa.ar[pa.Count].y:= opa.ar[StartI].Y;
-inc(pa.Count)
+
+    pa.ar[pa.Count].x:= opa.ar[StartI].X;
+    pa.ar[pa.Count].y:= opa.ar[StartI].Y;
+    inc(pa.Count)
 end;
 
 procedure BezierizeEdge(var pa: TPixAr; Delta: hwFloat);