hedgewars/uUtils.pas
changeset 11775 ee85798d6974
parent 11770 68f26b6a3a7d
child 11788 0327d20fa4a1
equal deleted inserted replaced
11774:04d7aa06ede2 11775:ee85798d6974
    69 
    69 
    70 function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
    70 function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
    71 function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
    71 function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
    72 
    72 
    73 function read1stLn(filePath: shortstring): shortstring;
    73 function read1stLn(filePath: shortstring): shortstring;
       
    74 function readValueFromINI(key, filePath: shortstring): shortstring;
    74 
    75 
    75 {$IFNDEF PAS2C}
    76 {$IFNDEF PAS2C}
    76 procedure Write(var f: textfile; s: shortstring);
    77 procedure Write(var f: textfile; s: shortstring);
    77 procedure WriteLn(var f: textfile; s: shortstring);
    78 procedure WriteLn(var f: textfile; s: shortstring);
    78 function StrLength(s: PChar): Longword;
    79 function StrLength(s: PChar): Longword;
   525         pfsClose(f);
   526         pfsClose(f);
   526         f:= nil;
   527         f:= nil;
   527         end;
   528         end;
   528 end;
   529 end;
   529 
   530 
       
   531 function readValueFromINI(key, filePath: shortstring): shortstring;
       
   532 var f: pfsFile;
       
   533 	s: shortstring;
       
   534 	i: LongInt;
       
   535 begin
       
   536     s:= '';
       
   537 	readValueFromINI:= '';
       
   538 
       
   539     if pfsExists(filePath) then
       
   540         begin
       
   541         f:= pfsOpenRead(filePath);
       
   542 
       
   543         while (not pfsEOF(f)) and allOK do
       
   544 			begin pfsReadLn(f, s);
       
   545 			if Length(s) = 0 then
       
   546 				continue;
       
   547 			if s[1] = ';' then
       
   548 				continue;
       
   549 
       
   550 			i:= Pos('=', s);
       
   551 			if Trim(Copy(s, 1, Pred(i))) = key then
       
   552 				begin
       
   553 				Delete(s, 1, i);
       
   554 				readValueFromINI:= s;
       
   555 				end;
       
   556 			end;
       
   557         pfsClose(f);
       
   558         f:= nil;
       
   559         end;
       
   560 end;
       
   561 
   530 procedure initModule(isNotPreview: boolean);
   562 procedure initModule(isNotPreview: boolean);
   531 {$IFDEF DEBUGFILE}
   563 {$IFDEF DEBUGFILE}
   532 var logfileBase: shortstring;
   564 var logfileBase: shortstring;
   533     i: LongInt;
   565     i: LongInt;
   534 {$ENDIF}
   566 {$ENDIF}