Convert reading hedgehogs limit from map config
authorunc0rr
Sun, 18 Nov 2012 18:58:46 +0400
changeset 8060 341fa76d0749
parent 8059 07661fb20586
child 8061 c08e9c3e0737
child 8062 abbcdf73327a
Convert reading hedgehogs limit from map config
hedgewars/uLand.pas
--- a/hedgewars/uLand.pas	Sun Nov 18 18:52:58 2012 +0400
+++ b/hedgewars/uLand.pas	Sun Nov 18 18:58:46 2012 +0400
@@ -31,7 +31,7 @@
 implementation
 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, SysUtils,
      uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures,
-     uLandGenMaze, uLandOutline;
+     uLandGenMaze, uLandOutline, uPhysFSLayer;
 
 var digest: shortstring;
 
@@ -423,26 +423,26 @@
 end;
 
 procedure LoadMapConfig;
-var f: textfile;
+var f: PFSFile;
     s: shortstring;
 begin
 s:= cPathz[ptMapCurrent] + '/map.cfg';
 
 WriteLnToConsole('Fetching map HH limit');
-{$I-}
-Assign(f, s);
-filemode:= 0; // readonly
-Reset(f);
-if IOResult <> 0 then
+
+f:= pfsOpenRead(s);
+if f <> nil then
     begin
-    s:= cPathz[ptMissionMaps] + '/' + ExtractFileName(cPathz[ptMapCurrent]) + '/map.cfg';
-    Assign(f, s);
-    Reset(f);
+    pfsReadLn(f, s);
+    if not pfsEof(f) then
+        begin
+        pfsReadLn(f, s);
+        val(s, MaxHedgehogs)
+        end;
+
+    pfsClose(f)
     end;
-Readln(f);
-if not eof(f) then
-    Readln(f, MaxHedgehogs);
-{$I+}
+
 if (MaxHedgehogs = 0) then
     MaxHedgehogs:= 18;
 end;