- Remove loading from file procedure
authorunc0rr
Thu, 23 Dec 2010 21:54:57 +0300
changeset 4648 d8e1b43482d2
parent 4646 48ab5ea4e9c9
child 4649 82bf0a0fa8b0
- Remove loading from file procedure - Add an assert on data format
hedgewars/uLandPainted.pas
--- a/hedgewars/uLandPainted.pas	Thu Dec 23 12:30:33 2010 -0500
+++ b/hedgewars/uLandPainted.pas	Thu Dec 23 21:54:57 2010 +0300
@@ -22,12 +22,11 @@
 
 interface
 
-procedure LoadFromFile(fileName: shortstring);
 procedure Draw;
 procedure initModule;
 
 implementation
-uses uLandGraphics, uConsts, uUtils, SDLh, uCommands;
+uses uLandGraphics, uConsts, uUtils, SDLh, uCommands, uDebug;
 
 type PointRec = packed record
     X, Y: SmallInt;
@@ -106,34 +105,6 @@
         end
 end;
 
-
-procedure LoadFromFile(fileName: shortstring);
-var
-    f: file of PointRec;
-    rec, prevRec: PointRec;
-begin
-    fileMode:= 0;
-
-    assignFile(f, fileName);
-    reset(f);
-
-    while not eof(f) do
-        begin
-        read(f, rec);
-        rec.X:= SDLNet_Read16(@rec.X);
-        rec.Y:= SDLNet_Read16(@rec.Y);
-
-        // FIXME: handle single point
-        if eof(f) or (rec.flags and $80 <> 0) then
-            else
-            DrawLineOnLand(prevRec.X, prevRec.Y, rec.X, rec.Y);
-
-        prevRec:= rec;
-        end;
-
-    closeFile(f);
-end;
-
 procedure chDraw(var s: shortstring);
 var rec: PointRec;
     prec: ^PointRec;
@@ -167,7 +138,12 @@
 var pe: PPointEntry;
     prevPoint: PointRec;
 begin
+    // shutup compiler
+    prevPoint.X:= 0;
+    prevPoint.Y:= 0;
+
     pe:= pointsListHead;
+    TryDo((pe = nil) or (pe^.point.flags and $80 <> 0), 'Corrupted draw data', true);
 
     while(pe <> nil) do
         begin
@@ -177,7 +153,7 @@
             DrawLineOnLand(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y);
 
         prevPoint:= pe^.point;
-        pe:= pe^.next;
+        pe:= pe^.next;  
         end;
 end;