hedgewars/uUtils.pas
changeset 13844 94d0d1ab7a0e
parent 13312 092adcf707c5
child 13898 8c702a4839ec
equal deleted inserted replaced
13843:cf7626f46bb2 13844:94d0d1ab7a0e
    48 function  MinD(a, b: double) : double; inline;
    48 function  MinD(a, b: double) : double; inline;
    49 function  Max(a, b: LongInt): LongInt; inline;
    49 function  Max(a, b: LongInt): LongInt; inline;
    50 
    50 
    51 function  IntToStr(n: LongInt): shortstring;
    51 function  IntToStr(n: LongInt): shortstring;
    52 function  StrToInt(s: shortstring): LongInt;
    52 function  StrToInt(s: shortstring): LongInt;
       
    53 function  StrToInt(s: shortstring; var success: boolean): LongInt;
    53 function  FloatToStr(n: hwFloat): shortstring;
    54 function  FloatToStr(n: hwFloat): shortstring;
    54 
    55 
    55 function  DxDy2Angle(const _dY, _dX: hwFloat): real; inline;
    56 function  DxDy2Angle(const _dY, _dX: hwFloat): real; inline;
    56 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
    57 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
    57 function  DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
    58 function  DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
   329 function IntToStr(n: LongInt): shortstring;
   330 function IntToStr(n: LongInt): shortstring;
   330 begin
   331 begin
   331 str(n, IntToStr)
   332 str(n, IntToStr)
   332 end;
   333 end;
   333 
   334 
       
   335 // Convert string to longint, with error checking.
       
   336 // Success will be set to false when conversion failed.
       
   337 // See documentation on Val procedure for syntax of s
       
   338 function StrToInt(s: shortstring; var success: boolean): LongInt;
       
   339 var Code: Word;
       
   340 begin
       
   341 val(s, StrToInt, Code);
       
   342 success:= Code = 0;
       
   343 end;
       
   344 
       
   345 // Convert string to longint, without error checking
   334 function StrToInt(s: shortstring): LongInt;
   346 function StrToInt(s: shortstring): LongInt;
   335 begin
   347 var success: boolean; // ignored
   336 val(s, StrToInt);
   348 begin
       
   349 success:= true; // avoid compiler hint
       
   350 StrToInt:= StrToInt(s, success);
   337 end;
   351 end;
   338 
   352 
   339 function FloatToStr(n: hwFloat): shortstring;
   353 function FloatToStr(n: hwFloat): shortstring;
   340 begin
   354 begin
   341 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))
   355 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))