hedgewars/uMisc.pas
changeset 371 731ad6d27bd1
parent 370 c75410fe3133
child 393 db01cc79f278
equal deleted inserted replaced
370:c75410fe3133 371:731ad6d27bd1
    33     GameFlags     : Longword = 0;
    33     GameFlags     : Longword = 0;
    34     TurnTimeLeft  : Longword = 0;
    34     TurnTimeLeft  : Longword = 0;
    35     cHedgehogTurnTime: Longword = 45000;
    35     cHedgehogTurnTime: Longword = 45000;
    36     cMaxAIThinkTime  : Longword = 5000;
    36     cMaxAIThinkTime  : Longword = 5000;
    37 
    37 
    38     cCloudsNumber    : integer = 9;
    38     cCloudsNumber    : LongInt = 9;
    39     cConsoleHeight   : integer = 320;
    39     cConsoleHeight   : LongInt = 320;
    40     cConsoleYAdd     : integer = 0;
    40     cConsoleYAdd     : LongInt = 0;
    41     cScreenWidth     : integer = 1024;
    41     cScreenWidth     : LongInt = 1024;
    42     cScreenHeight    : integer = 768;
    42     cScreenHeight    : LongInt = 768;
    43     cBits            : integer = 16;
    43     cBits            : LongInt = 16;
    44     cBitsStr         : string[2] = '16';
    44     cBitsStr         : string[2] = '16';
    45 
    45 
    46     cWaterLine       : integer = 1024;
    46     cWaterLine       : LongInt = 1024;
    47     cVisibleWater    : integer = 128;
    47     cVisibleWater    : LongInt = 128;
    48     cGearScrEdgesDist: integer = 240;
    48     cGearScrEdgesDist: LongInt = 240;
    49     cCursorEdgesDist : integer = 40;
    49     cCursorEdgesDist : LongInt = 40;
    50     cTeamHealthWidth : integer = 128;
    50     cTeamHealthWidth : LongInt = 128;
    51 
    51 
    52     GameTicks     : LongWord = 0;
    52     GameTicks     : LongWord = 0;
    53 
    53 
    54     cSkyColor     : Longword = 0;
    54     cSkyColor     : Longword = 0;
    55     cWaterColor   : Longword = $005ACE;
    55     cWaterColor   : Longword = $005ACE;
    61     cShowFPS      : boolean = true;
    61     cShowFPS      : boolean = true;
    62     cCaseFactor   : Longword = 3;  {1..10}
    62     cCaseFactor   : Longword = 3;  {1..10}
    63     cFullScreen   : boolean = true;
    63     cFullScreen   : boolean = true;
    64     cLocaleFName  : shortstring = 'en.txt';
    64     cLocaleFName  : shortstring = 'en.txt';
    65     cSeed         : shortstring = '';
    65     cSeed         : shortstring = '';
    66     cInitVolume   : integer = 128;
    66     cInitVolume   : LongInt = 128;
    67     cVolumeDelta  : integer = 0;
    67     cVolumeDelta  : LongInt = 0;
    68     cTimerInterval   : Longword = 5;
    68     cTimerInterval   : Longword = 5;
    69     cHasFocus     : boolean = true;
    69     cHasFocus     : boolean = true;
    70 
    70 
    71 var
    71 var
    72     cSendEmptyPacketTime : LongWord = 2000;
    72     cSendEmptyPacketTime : LongWord = 2000;
    79 
    79 
    80     flagMakeCapture: boolean = false;
    80     flagMakeCapture: boolean = false;
    81 
    81 
    82     InitStepsFlags: Longword = 0;
    82     InitStepsFlags: Longword = 0;
    83 
    83 
    84     AttackBar: integer = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
    84     AttackBar: LongInt = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
    85 
    85 
    86 function hwSign(r: hwFloat): integer;
    86 function hwSign(r: hwFloat): LongInt;
    87 function Min(a, b: integer): integer;
    87 function Min(a, b: LongInt): LongInt;
    88 function Max(a, b: integer): integer;
    88 function Max(a, b: LongInt): LongInt;
    89 function rndSign(num: hwFloat): hwFloat;
    89 function rndSign(num: hwFloat): hwFloat;
    90 procedure OutError(Msg: String; isFatalError: boolean);
    90 procedure OutError(Msg: String; isFatalError: boolean);
    91 procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean);
    91 procedure TryDo(Assert: boolean; Msg: string; isFatal: boolean);
    92 procedure SDLTry(Assert: boolean; isFatal: boolean);
    92 procedure SDLTry(Assert: boolean; isFatal: boolean);
    93 function IntToStr(n: LongInt): shortstring;
    93 function IntToStr(n: LongInt): shortstring;
    94 function FloatToStr(n: hwFloat): shortstring;
    94 function FloatToStr(n: hwFloat): shortstring;
    95 function DxDy2Angle32(const _dY, _dX: hwFloat): integer;
    95 function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
    96 function DxDy2AttackAngle(const _dY, _dX: hwFloat): integer;
    96 function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
    97 procedure AdjustColor(var Color: Longword);
    97 procedure AdjustColor(var Color: Longword);
    98 {$IFDEF DEBUGFILE}
    98 {$IFDEF DEBUGFILE}
    99 procedure AddFileLog(s: shortstring);
    99 procedure AddFileLog(s: shortstring);
   100 function RectToStr(Rect: TSDL_Rect): shortstring;
   100 function RectToStr(Rect: TSDL_Rect): shortstring;
   101 {$ENDIF}
   101 {$ENDIF}
   113 var KBnum: Longword = 0;
   113 var KBnum: Longword = 0;
   114 {$IFDEF DEBUGFILE}
   114 {$IFDEF DEBUGFILE}
   115 var f: textfile;
   115 var f: textfile;
   116 {$ENDIF}
   116 {$ENDIF}
   117 
   117 
   118 function hwSign(r: hwFloat): integer;
   118 function hwSign(r: hwFloat): LongInt;
   119 begin
   119 begin
   120 if r.isNegative then hwSign:= -1 else hwSign:= 1
   120 if r.isNegative then hwSign:= -1 else hwSign:= 1
   121 end;
   121 end;
   122 
   122 
   123 function Min(a, b: integer): integer;
   123 function Min(a, b: LongInt): LongInt;
   124 begin
   124 begin
   125 if a < b then Min:= a else Min:= b
   125 if a < b then Min:= a else Min:= b
   126 end;
   126 end;
   127 
   127 
   128 function Max(a, b: integer): integer;
   128 function Max(a, b: LongInt): LongInt;
   129 begin
   129 begin
   130 if a > b then Max:= a else Max:= b
   130 if a > b then Max:= a else Max:= b
   131 end;
   131 end;
   132 
   132 
   133 procedure OutError(Msg: String; isFatalError: boolean);
   133 procedure OutError(Msg: String; isFatalError: boolean);
   175         fpatan
   175         fpatan
   176         fwait
   176         fwait
   177 end;
   177 end;
   178 {$ENDIF}
   178 {$ENDIF}
   179 
   179 
   180 function DxDy2Angle32(const _dY, _dX: hwFloat): integer;
   180 function DxDy2Angle32(const _dY, _dX: hwFloat): LongInt;
   181 const _16divPI: Extended = 16/pi;
   181 const _16divPI: Extended = 16/pi;
   182 var dY, dX: Extended;
   182 var dY, dX: Extended;
   183 begin
   183 begin
   184 dY:= _dY.QWordValue / $100000000;
   184 dY:= _dY.QWordValue / $100000000;
   185 if _dY.isNegative then dY:= - dY;
   185 if _dY.isNegative then dY:= - dY;
   186 dX:= _dX.QWordValue / $100000000;
   186 dX:= _dX.QWordValue / $100000000;
   187 if _dX.isNegative then dX:= - dX;
   187 if _dX.isNegative then dX:= - dX;
   188 DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f
   188 DxDy2Angle32:= trunc(arctan2(dY, dX) * _16divPI) and $1f
   189 end;
   189 end;
   190 
   190 
   191 function DxDy2AttackAngle(const _dY, _dX: hwFloat): integer;
   191 function DxDy2AttackAngle(const _dY, _dX: hwFloat): LongInt;
   192 const MaxAngleDivPI: Extended = cMaxAngle/pi;
   192 const MaxAngleDivPI: Extended = cMaxAngle/pi;
   193 var dY, dX: Extended;
   193 var dY, dX: Extended;
   194 begin
   194 begin
   195 dY:= _dY.QWordValue / $100000000;
   195 dY:= _dY.QWordValue / $100000000;
   196 if _dY.isNegative then dY:= - dY;
   196 if _dY.isNegative then dY:= - dY;
   250 begin
   250 begin
   251 RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')'
   251 RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')'
   252 end;
   252 end;
   253 
   253 
   254 
   254 
   255 var i: integer;
   255 var i: LongInt;
   256 
   256 
   257 initialization
   257 initialization
   258 cDrownSpeed.QWordValue:= 257698038;// 0.06
   258 cDrownSpeed.QWordValue:= 257698038;// 0.06
   259 cMaxWindSpeed.QWordValue:=   2147484;// 0.0005
   259 cMaxWindSpeed.QWordValue:=   2147484;// 0.0005
   260 cWindSpeed.QWordValue:=    429496;// 0.0001
   260 cWindSpeed.QWordValue:=    429496;// 0.0001