hedgewars/uLandPainted.pas
branchsdl2transition
changeset 11362 ed5a6478e710
parent 11046 47a8c19ecb60
child 14416 96624a6cdb93
--- a/hedgewars/uLandPainted.pas	Tue Nov 10 18:16:35 2015 +0100
+++ b/hedgewars/uLandPainted.pas	Tue Nov 10 20:43:13 2015 +0100
@@ -1,6 +1,6 @@
 (*
  * Hedgewars, a free turn based strategy game
- * Copyright (c) 2004-2013 Andrey Korotaev <unC0Rr@gmail.com>
+ * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -13,7 +13,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  *)
 
 {$INCLUDE "options.inc"}
@@ -27,12 +27,13 @@
 procedure freeModule;
 
 implementation
-uses uLandGraphics, uConsts, uVariables, uUtils, SDLh, uCommands, uDebug, uScript;
+uses uLandGraphics, uConsts, uVariables, uUtils, SDLh, uCommands, uScript, uIO;
 
 type PointRec = packed record
     X, Y: SmallInt;
     flags: byte;
     end;
+    PPointRec = ^PointRec;
 
 type
     PPointEntry = ^PointEntry;
@@ -45,7 +46,7 @@
 
 procedure chDraw(var s: shortstring);
 var rec: PointRec;
-    prec: ^PointRec;
+    prec: PPointRec;
     pe: PPointEntry;
     i, l: byte;
 begin
@@ -53,7 +54,7 @@
     l:= length(s);
     while i < l do
         begin
-        prec:= @s[i];
+        prec:= PPointRec(@s[i]);
         rec:= prec^;
         rec.X:= SDLNet_Read16(@rec.X);
         rec.Y:= SDLNet_Read16(@rec.Y);
@@ -81,11 +82,13 @@
     prevPoint: PointRec;
     radius: LongInt;
     color: Longword;
+    lineNumber, linePoints: Longword;
 begin
     // shutup compiler
     prevPoint.X:= 0;
     prevPoint.Y:= 0;
     radius:= 0;
+    linePoints:= 0;
 
     pe:= pointsListHead;
     while (pe <> nil) and (pe^.point.flags and $80 = 0) do
@@ -94,23 +97,27 @@
         pe:= pe^.next;
         end;
 
+    lineNumber:= 0;
+
     while(pe <> nil) do
         begin
         if (pe^.point.flags and $80 <> 0) then
             begin
+            if (lineNumber > 0) and (linePoints = 0) and cAdvancedMapGenMode then
+                    SendIPC('|' + inttostr(lineNumber - 1));
+
+            inc(lineNumber);
+
             if (pe^.point.flags and $40 <> 0) then
                 color:= 0
                 else
                 color:= lfBasic;
             radius:= (pe^.point.flags and $3F) * 5 + 3;
-            AddFileLog('[DRAW] Move to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+'), radius = '+inttostr(radius));
-            FillRoundInLand(pe^.point.X, pe^.point.Y, radius, color)
+            linePoints:= FillRoundInLand(pe^.point.X, pe^.point.Y, radius, color);
             end
             else
             begin
-            AddFileLog('[DRAW] Line to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+'), radius = '+inttostr(radius));
-            DrawThickLine(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y, radius, color);
-            FillRoundInLand(pe^.point.X, pe^.point.Y, radius, color)
+            inc(linePoints, DrawThickLine(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y, radius, color));
             end;
 
         prevPoint:= pe^.point;