hedgewars/uUtils.pas
changeset 7151 ec15d9e1a7e3
parent 7074 3f23bd0f2af2
child 7180 53ffc8853008
child 7191 9419294e5f33
equal deleted inserted replaced
7148:c7ee9592c9a1 7151:ec15d9e1a7e3
    37 
    37 
    38 function  Min(a, b: LongInt): LongInt; inline;
    38 function  Min(a, b: LongInt): LongInt; inline;
    39 function  Max(a, b: LongInt): LongInt; inline;
    39 function  Max(a, b: LongInt): LongInt; inline;
    40 
    40 
    41 function  IntToStr(n: LongInt): shortstring;
    41 function  IntToStr(n: LongInt): shortstring;
       
    42 function  StrToInt(s: shortstring): LongInt;
    42 function  FloatToStr(n: hwFloat): shortstring;
    43 function  FloatToStr(n: hwFloat): shortstring;
    43 
    44 
    44 function  DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
    45 function  DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
    45 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
    46 function  DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
    46 function  DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
    47 function  DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
    62 
    63 
    63 function  CheckNoTeamOrHH: boolean; inline;
    64 function  CheckNoTeamOrHH: boolean; inline;
    64 
    65 
    65 function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
    66 function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
    66 function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
    67 function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
       
    68 
       
    69 {$IFNDEF PAS2C}
       
    70 procedure Write(var f: textfile; s: shortstring);
       
    71 procedure WriteLn(var f: textfile; s: shortstring);
       
    72 {$ENDIF}
    67 
    73 
    68 procedure initModule(isGame: boolean);
    74 procedure initModule(isGame: boolean);
    69 procedure freeModule;
    75 procedure freeModule;
    70 
    76 
    71 
    77 
   156 function IntToStr(n: LongInt): shortstring;
   162 function IntToStr(n: LongInt): shortstring;
   157 begin
   163 begin
   158 str(n, IntToStr)
   164 str(n, IntToStr)
   159 end;
   165 end;
   160 
   166 
       
   167 function  StrToInt(s: shortstring): LongInt;
       
   168 var c: LongInt;
       
   169 begin
       
   170 val(s, StrToInt, c)
       
   171 end;
       
   172 
   161 function FloatToStr(n: hwFloat): shortstring;
   173 function FloatToStr(n: hwFloat): shortstring;
   162 begin
   174 begin
   163 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))
   175 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))
   164 end;
   176 end;
   165 
   177 
   283 
   295 
   284 procedure AddFileLog(s: shortstring);
   296 procedure AddFileLog(s: shortstring);
   285 begin
   297 begin
   286 s:= s;
   298 s:= s;
   287 {$IFDEF DEBUGFILE}
   299 {$IFDEF DEBUGFILE}
   288 writeln(f, GameTicks, ': ', s);
   300 writeln(f, inttostr(GameTicks)  + ': ' + s);
   289 flush(f)
   301 flush(f)
   290 {$ENDIF}
   302 {$ENDIF}
   291 end;
   303 end;
   292 
   304 
   293 
   305 
   356 
   368 
   357 function CheckNoTeamOrHH: boolean;
   369 function CheckNoTeamOrHH: boolean;
   358 begin
   370 begin
   359 CheckNoTeamOrHH:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil);
   371 CheckNoTeamOrHH:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil);
   360 end;
   372 end;
       
   373 
       
   374 {$IFNDEF PAS2C}
       
   375 procedure Write(var f: textfile; s: shortstring);
       
   376 begin
       
   377 system.write(f, s)
       
   378 end;
       
   379 
       
   380 procedure WriteLn(var f: textfile; s: shortstring);
       
   381 begin
       
   382 system.writeln(f, s)
       
   383 end;
       
   384 {$ENDIF}
   361 
   385 
   362 procedure initModule(isGame: boolean);
   386 procedure initModule(isGame: boolean);
   363 {$IFDEF DEBUGFILE}
   387 {$IFDEF DEBUGFILE}
   364 var logfileBase: shortstring;
   388 var logfileBase: shortstring;
   365 {$IFNDEF MOBILE}var i: LongInt;{$ENDIF}
   389 {$IFNDEF MOBILE}var i: LongInt;{$ENDIF}
   401 procedure freeModule;
   425 procedure freeModule;
   402 begin
   426 begin
   403 recordFileName:= '';
   427 recordFileName:= '';
   404 
   428 
   405 {$IFDEF DEBUGFILE}
   429 {$IFDEF DEBUGFILE}
   406     writeln(f, 'halt at ', GameTicks, ' ticks. TurnTimeLeft = ', TurnTimeLeft);
   430     writeln(f, 'halt at ' + inttostr(GameTicks) + ' ticks. TurnTimeLeft = ' + inttostr(TurnTimeLeft));
   407     flush(f);
   431     flush(f);
   408     close(f);
   432     close(f);
   409 {$ENDIF}
   433 {$ENDIF}
   410 end;
   434 end;
   411 
   435