--- a/hedgewars/uLandPainted.pas Wed Dec 08 22:35:29 2010 +0100
+++ b/hedgewars/uLandPainted.pas Thu Dec 09 11:59:07 2010 +0300
@@ -23,6 +23,7 @@
interface
procedure LoadFromFile(fileName: shortstring);
+procedure Draw;
procedure initModule;
implementation
@@ -33,6 +34,15 @@
flags: byte;
end;
+type
+ PPointEntry = ^PointEntry;
+ PointEntry = record
+ point: PointRec;
+ next: PPointEntry;
+ end;
+
+var pointsListHead, pointsListLast: PPointEntry;
+
procedure DrawLineOnLand(X1, Y1, X2, Y2: LongInt);
var eX, eY, dX, dY: LongInt;
i, sX, sY, x, y, d: LongInt;
@@ -125,11 +135,57 @@
end;
procedure chDraw(var s: shortstring);
+var rec: PointRec;
+ prec: ^PointRec;
+ pe: PPointEntry;
+ i, l: byte;
begin
+ i:= 1;
+ l:= length(s);
+ while i < l do
+ begin
+ prec:= @s[i];
+ rec:= prec^;
+ rec.X:= SDLNet_Read16(@rec.X);
+ rec.Y:= SDLNet_Read16(@rec.Y);
+
+ pe:= new(PPointEntry);
+ if pointsListLast = nil then
+ pointsListHead:= pe
+ else
+ pointsListLast^.next:= pe;
+ pointsListLast:= pe;
+
+ pe^.point:= rec;
+ pe^.next:= nil;
+
+ inc(i, 5)
+ end;
+end;
+
+procedure Draw;
+var pe: PPointEntry;
+ prevPoint: PointRec;
+begin
+ pe:= pointsListHead;
+
+ while(pe <> nil) do
+ begin
+ if (pe^.point.flags and $80 <> 0) then
+ FillRoundInLand(pe^.point.X, pe^.point.Y, 34, lfBasic)
+ else
+ DrawLineOnLand(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y);
+
+ prevPoint:= pe^.point;
+ pe:= pe^.next;
+ end;
end;
procedure initModule;
begin
+ pointsListHead:= nil;
+ pointsListLast:= nil;
+
RegisterVariable('draw', vtCommand, @chDraw, false);
end;