--- a/CMakeLists.txt Thu Mar 15 22:46:37 2007 +0000
+++ b/CMakeLists.txt Sat Mar 17 18:17:19 2007 +0000
@@ -1,6 +1,6 @@
project(hedgewars)
-cmake_minimum_required(VERSION 2.4.4 FATAL_ERROR)
+cmake_minimum_required(VERSION 2.4.0)
if(DEFINED DATA_INSTALL_DIR)
set(SHAREPATH ${DATA_INSTALL_DIR}/hedgewars/)
--- a/INSTALL Thu Mar 15 22:46:37 2007 +0000
+++ b/INSTALL Sat Mar 17 18:17:19 2007 +0000
@@ -6,7 +6,7 @@
- SDL_mixer >= 1.2
- SDL_image >= 1.2
- SDL_ttf >= 2.0
- - CMake >= 2.4.4
+ - CMake >= 2.4.0
1. Configure:
$ cmake .
--- a/hedgewars/CCHandlers.inc Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/CCHandlers.inc Sat Mar 17 18:17:19 2007 +0000
@@ -115,7 +115,7 @@
begin
SplitBySpace(id, s);
val(id, Hedgehogs[HedgehogsNumber].BotLevel);
- Gear:= AddGear(0, 0, gtHedgehog, 0, 0, 0, 0);
+ Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
Gear^.Hedgehog:= @Hedgehogs[HedgehogsNumber];
val(s, Gear^.Health);
TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
--- a/hedgewars/GSHandlers.inc Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/GSHandlers.inc Sat Mar 17 18:17:19 2007 +0000
@@ -20,7 +20,7 @@
function CheckGearDrowning(Gear: PGear): boolean;
begin
-if cWaterLine < Gear^.Y + Gear^.Radius then
+if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then
begin
CheckGearDrowning:= true;
Gear^.State:= gstDrowning;
@@ -39,7 +39,7 @@
procedure CheckHHDamage(Gear: PGear);
begin
-if _0_4 < Gear^.dY then Gear^.Damage:= Gear^.Damage + 1 + hwRound(70 * (hwAbs(Gear^.dY) - _0_4));
+if _0_4 < Gear^.dY then Gear^.Damage:= Gear^.Damage + 1 + hwRound((hwAbs(Gear^.dY) - _0_4) * 70);
end;
////////////////////////////////////////////////////////////////////////////////
@@ -50,8 +50,8 @@
dAngle:= (hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) * _0_1;
if not Gear^.dX.isNegative then Gear^.DirAngle:= Gear^.DirAngle + dAngle
else Gear^.DirAngle:= Gear^.DirAngle - dAngle;
-if Gear^.DirAngle < 0 then Gear^.DirAngle:= Gear^.DirAngle + 16
-else if 16 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - 16
+if Gear^.DirAngle.isNegative then Gear^.DirAngle:= Gear^.DirAngle + _16
+else if _16 < Gear^.DirAngle then Gear^.DirAngle:= Gear^.DirAngle - _16
end;
////////////////////////////////////////////////////////////////////////////////
@@ -87,8 +87,8 @@
if hwSqr(Gear^.dX) + hwSqr(Gear^.dY) < _1div100000 then
if (Gear^.Timer = 0) then Gear^.Active:= false
else begin
- Gear^.dX:= 0;
- Gear^.dY:= 0
+ Gear^.dX:= _0;
+ Gear^.dY:= _0
end;
Gear^.State:= Gear^.State or gstCollision
end;
@@ -103,11 +103,11 @@
procedure doStepCloud(Gear: PGear);
begin
Gear^.X:= Gear^.X + cWindSpeed * 200 + Gear^.dX;
-if Gear^.Y > -160 then Gear^.dY:= Gear^.dY - _1div50000
- else Gear^.dY:= Gear^.dY + _1div50000;
+if hwRound(Gear^.Y) > -160 then Gear^.dY:= Gear^.dY - _1div50000
+ else Gear^.dY:= Gear^.dY + _1div50000;
Gear^.Y:= Gear^.Y + Gear^.dY;
-if Gear^.X < -cScreenWidth - 256 then Gear^.X:= cScreenWidth + 2048 else
-if Gear^.X > cScreenWidth + 2048 then Gear^.X:= -cScreenWidth - 256
+if hwRound(Gear^.X) < -cScreenWidth - 256 then Gear^.X:= int2hwFloat(cScreenWidth + 2048) else
+if hwRound(Gear^.X) > cScreenWidth + 2048 then Gear^.X:= int2hwFloat(-cScreenWidth - 256)
end;
////////////////////////////////////////////////////////////////////////////////
@@ -124,7 +124,7 @@
gtClusterBomb: begin
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
for i:= 0 to 4 do
- AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, (getrandom - _0_5) * _0_2, (getrandom - 3) * _0_08, 0);
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtCluster, 0, (getrandom - _0_5) * _0_2, (getrandom - _3) * _0_08, 0);
end
end;
DeleteGear(Gear);
@@ -145,7 +145,7 @@
exit
end;
if (GameTicks and $1F) = 0 then
- AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0)
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
end;
////////////////////////////////////////////////////////////////////////////////
@@ -161,7 +161,7 @@
exit
end;
if (GameTicks and $3F) = 0 then
- AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0)
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
end;
////////////////////////////////////////////////////////////////////////////////
@@ -181,7 +181,7 @@
begin
AllInactive:= false;
Gear^.Y:= Gear^.Y - _0_08;
-if Gear^.Y < cWaterLine + 10 then
+if hwRound(Gear^.Y) < cWaterLine + 10 then
DeleteGear(Gear)
end;
@@ -191,16 +191,16 @@
AllInactive:= false;
str(Gear^.State, s);
Gear^.Surf:= RenderString(s, PHedgehog(Gear^.Hedgehog)^.Team^.Color, fnt16);
-if Gear^.Y < cWaterLine then Gear^.doStep:= @doStepHealthTagWork
- else Gear^.doStep:= @doStepHealthTagWorkUnderWater
+if hwRound(Gear^.Y) < cWaterLine then Gear^.doStep:= @doStepHealthTagWork
+ else Gear^.doStep:= @doStepHealthTagWorkUnderWater
end;
////////////////////////////////////////////////////////////////////////////////
procedure doStepGrave(Gear: PGear);
begin
AllInactive:= false;
-if Gear^.dY < 0 then
- if TestCollisionY(Gear, -1) then Gear^.dY:= 0;
+if Gear^.dY.isNegative then
+ if TestCollisionY(Gear, -1) then Gear^.dY:= _0;
if not Gear^.dY.isNegative then
if TestCollisionY(Gear, 1) then
@@ -236,7 +236,7 @@
begin
y:= hwRound(Gear^.Y);
if y + Gear^.Radius < cWaterLine then
- AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, 0, 0, 0);
+ AddGear(hwRound(Gear^.X), y, gtSmokeTrace, 0, _0, _0, 0);
end;
CheckCollision(Gear);
@@ -295,7 +295,7 @@
end;
dec(i)
until i = 0;
-if (Gear^.X < 0) or (Gear^.Y < 0) or (Gear^.X > 2048) or (Gear^.Y > 1024) then
+if (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then
begin
DeleteGear(Gear);
AfterAttack
@@ -327,7 +327,7 @@
dec(Gear^.Health, Gear^.Damage);
Gear^.Damage:= 0
end;
-if (Gear^.Health <= 0) or (Gear^.X < 0) or (Gear^.Y < 0) or (Gear^.X > 2048) or (Gear^.Y > 1024) then
+if (Gear^.Health <= 0) or (Gear^.X < _0) or (Gear^.Y < _0) or (Gear^.X > _2048) or (Gear^.Y > _1024) then
DeleteGear(Gear)
end;
@@ -396,26 +396,26 @@
end;
if TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.dY:= 0;
+ Gear^.dY:= _0;
SetLittle(HHGear^.dX);
- HHGear^.dY:= 0;
+ HHGear^.dY:= _0;
end else
begin
Gear^.dY:= Gear^.dY + cGravity;
Gear^.Y:= Gear^.Y + Gear^.dY;
- if Gear^.Y > 1024 then Gear^.Timer:= 1
+ if Gear^.Y > _1024 then Gear^.Timer:= 1
end;
Gear^.X:= Gear^.X + HHGear^.dX;
HHGear^.X:= Gear^.X;
-HHGear^.Y:= Gear^.Y - cHHRadius;
+HHGear^.Y:= Gear^.Y - int2hwFloat(cHHRadius);
if (Gear^.Message and gm_Attack) <> 0 then
if (Gear^.State and gsttmpFlag) <> 0 then Gear^.Timer:= 1 else else
if (Gear^.State and gsttmpFlag) = 0 then Gear^.State:= Gear^.State or gsttmpFlag;
if ((Gear^.Message and gm_Left) <> 0) then Gear^.dX:= - _0_3 else
if ((Gear^.Message and gm_Right) <> 0) then Gear^.dX:= _0_3
- else Gear^.dX:= 0;
+ else Gear^.dX:= _0;
end;
procedure doStepPickHammer(Gear: PGear);
@@ -423,7 +423,7 @@
ar: TRangeArray;
begin
i:= 0;
-y:= hwRound(Gear^.Y) - cHHRadius*2;
+y:= hwRound(Gear^.Y) - cHHRadius * 2;
while y < hwRound(Gear^.Y) do
begin
ar[i].Left := hwRound(Gear^.X) - Gear^.Radius - LongInt(GetRandom(2));
@@ -431,7 +431,7 @@
inc(y, 2);
inc(i)
end;
-DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius*2, 2, Pred(i));
+DrawHLinesExplosions(@ar, 3, hwRound(Gear^.Y) - cHHRadius * 2, 2, Pred(i));
Gear^.dY:= PHedgehog(Gear^.Hedgehog)^.Gear^.dY;
PlaySound(sndPickhammer, true);
doStepPickHammerWork(Gear);
@@ -455,7 +455,7 @@
if abs(LongInt(HHGear^.Angle) - BTPrevAngle) > 7 then
begin
- Gear^.dX:= hwSign(HHGear^.dX) * AngleSin(HHGear^.Angle) * _0_5;
+ Gear^.dX:= SignAs(AngleSin(HHGear^.Angle) * _0_5, HHGear^.dX);
Gear^.dY:= AngleCos(HHGear^.Angle) * ( - _0_5);
BTPrevAngle:= HHGear^.Angle;
b:= true
@@ -464,8 +464,8 @@
if Gear^.Timer mod cHHStepTicks = 0 then
begin
b:= true;
- if Gear^.dX < 0 then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right
- else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left;
+ if Gear^.dX.isNegative then HHGear^.Message:= (HHGear^.Message or gm_Left) and not gm_Right
+ else HHGear^.Message:= (HHGear^.Message or gm_Right) and not gm_Left;
HHGear^.State:= HHGear^.State and not gstAttacking;
HedgehogStep(HHGear);
@@ -486,7 +486,7 @@
end;
if b then
- DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - 4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7,
+ DrawTunnel(HHGear^.X - Gear^.dX * cHHRadius, HHGear^.Y - _4 - Gear^.dY * cHHRadius + hwAbs(Gear^.dY) * 7,
Gear^.dX, Gear^.dY,
cHHRadius * 5, cHHRadius * 2 + 6);
@@ -547,15 +547,15 @@
cs:= Gear^.dY + HHGear^.dY;
cc:= Gear^.dX + HHGear^.dX;
-len:= 1 / Distance(cc, cs);
+len:= _1 / Distance(cc, cs);
cc:= cc * len;
cs:= cs * len;
flCheck:= not flCheck;
if flCheck then // check whether rope needs dividing
begin
- len:= Gear^.Elasticity - 20;
- while len > 5 do
+ len:= Gear^.Elasticity - _20;
+ while len > _5 do
begin
tx:= cc*len;
ty:= cs*len;
@@ -578,7 +578,7 @@
Gear^.Friction:= Gear^.Friction - len;
break
end;
- len:= len - 3
+ len:= len - _3
end;
end else
if RopePoints.Count > 0 then // check whether the last dividing point could be removed
@@ -600,7 +600,7 @@
cs:= Gear^.dY + HHGear^.dY;
cc:= Gear^.dX + HHGear^.dX;
-len:= 1 / Distance(cc, cs);
+len:= _1 / Distance(cc, cs);
cc:= cc * len;
cs:= cs * len;
@@ -611,7 +611,7 @@
if not (TestCollisionXwithGear(HHGear, hwSign(Gear^.dX))
or TestCollisionYwithGear(HHGear, hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity + _0_3;
-if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > 30) then
+if ((Gear^.Message and gm_Up) <> 0) and (Gear^.Elasticity > _30) then
if not (TestCollisionXwithGear(HHGear, -hwSign(Gear^.dX))
or TestCollisionYwithGear(HHGear, -hwSign(Gear^.dY))) then Gear^.Elasticity:= Gear^.Elasticity - _0_3;
@@ -638,12 +638,12 @@
begin
Gear^.X:= Gear^.X - Gear^.dX;
Gear^.Y:= Gear^.Y - Gear^.dY;
-Gear^.Elasticity:= Gear^.Elasticity + 1;
+Gear^.Elasticity:= Gear^.Elasticity + _1;
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
if (HHGear^.State and gstFalling) <> 0 then
if TestCollisionYwithGear(HHGear, 1) then
begin
- HHGear^.dY:= 0;
+ HHGear^.dY:= _0;
CheckHHDamage(HHGear);
HHGear^.State:= HHGear^.State and not (gstFalling or gstHHJumping);
end else
@@ -655,11 +655,11 @@
Gear^.Y:= Gear^.Y + HHGear^.dY;
HHGear^.dY:= HHGear^.dY + cGravity;
tt:= Gear^.Elasticity;
- tx:= 0;
- ty:= 0;
- while tt > 20 do
+ tx:= _0;
+ ty:= _0;
+ while tt > _20 do
begin
- if TestCollisionXwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dX))
+ if TestCollisionXwithXYShift(Gear, tx, hwRound(ty), hwSign(Gear^.dX))
or TestCollisionYwithXYShift(Gear, hwRound(tx), hwRound(ty), hwSign(Gear^.dY)) then
begin
Gear^.X:= Gear^.X + tx;
@@ -667,11 +667,11 @@
Gear^.Elasticity:= tt;
Gear^.doStep:= @doStepRopeWork;
with HHGear^ do State:= State and not gstAttacking;
- tt:= 0
+ tt:= _0
end;
tx:= tx + Gear^.dX - Gear^.dX;
ty:= ty + Gear^.dY - Gear^.dY;
- tt:= tt - 2;
+ tt:= tt - _2;
end;
end;
CheckCollision(Gear);
@@ -679,8 +679,8 @@
begin
Gear^.doStep:= @doStepRopeWork;
with HHGear^ do State:= State and not gstAttacking;
- if Gear^.Elasticity < 10 then
- Gear^.Elasticity:= 10000;
+ if Gear^.Elasticity < _10 then
+ Gear^.Elasticity:= _10000;
end;
if (Gear^.Elasticity > Gear^.Friction) or ((Gear^.Message and gm_Attack) = 0) then
@@ -737,8 +737,8 @@
if Gear^.Active = false then
begin
if Gear^.CollIndex = High(Longword) then AddGearCI(Gear);
- Gear^.dX:= 0;
- Gear^.dY:= 0
+ Gear^.dX:= _0;
+ Gear^.dY:= _0
end;
CalcRotationDirAngle(Gear);
AllInactive:= false
@@ -798,7 +798,7 @@
DeleteGear(Gear);
doMakeExplosion(x, y, 25, EXPLAutoSound);
for i:= 0 to 63 do
- AddGear(x, y, gtFlame, 0, 0, 0, 0);
+ AddGear(x, y, gtFlame, 0, _0, _0, 0);
exit
end;
@@ -807,11 +807,11 @@
AllInactive:= false;
Gear^.dY:= Gear^.dY + cGravity;
Gear^.Y:= Gear^.Y + Gear^.dY;
- if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0 else
+ if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0 else
if (not Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, 1) then
begin
Gear^.dY:= - Gear^.dY * Gear^.Elasticity;
- if Gear^.dY > - _0_001 then Gear^.dY:= 0
+ if Gear^.dY > - _0_001 then Gear^.dY:= _0
else if Gear^.dY < - _0_03 then PlaySound(sndGraveImpact, false);
end;
CheckGearDrowning(Gear);
@@ -905,7 +905,7 @@
if Gear^.dY > _0_1 then Gear^.dY:= Gear^.dY * _0_995;
Gear^.X:= Gear^.X + Gear^.dX;
Gear^.Y:= Gear^.Y + Gear^.dY;
- if Gear^.Y > 1023 then
+ if not (Gear^.Y < _1024) then
begin
DeleteGear(Gear);
exit
@@ -942,7 +942,7 @@
if hwRound(HHGear^.Y) <= Gear^.Tag - 2 then
begin
Gear^.Tag:= hwRound(HHGear^.Y);
- DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y - 1, _0_5, 0, cHHRadius * 4, 2);
+ DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y - _1, _0_5, _0, cHHRadius * 4, 2);
HHGear^.State:= HHGear^.State or gstNoDamage;
Gear^.Y:= HHGear^.Y;
AmmoShove(Gear, 30, 40);
@@ -965,15 +965,15 @@
begin
AllInactive:= false;
HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
-HHGear^.X:= hwRound(HHGear^.X) - _0_5;
+HHGear^.X:= int2hwFloat(hwRound(HHGear^.X)) - _0_5;
SetLittle(HHGear^.dX);
HHGear^.dY:= - _0_3;
Gear^.X:= HHGear^.X;
-Gear^.dX:= hwSign(HHGear^.dX) * _0_45;
+Gear^.dX:= SignAs(_0_45, HHGear^.dX);
Gear^.dY:= - _0_9;
Gear^.doStep:= @doStepFirePunchWork;
-DrawTunnel(HHGear^.X - cHHRadius, HHGear^.Y + 1, _0_5, 0, cHHRadius * 4, 5);
+DrawTunnel(HHGear^.X - int2hwFloat(cHHRadius), HHGear^.Y + _1, _0_5, _0, cHHRadius * 4, 5);
end;
////////////////////////////////////////////////////////////////////////////////
@@ -992,7 +992,7 @@
begin
Message:= 0;
SetLittle(dx);
- dY:= 0;
+ dY:= _0;
State:= State and not (gstAttacking or gstAttacked);
State:= State or gstFalling;
end;
@@ -1021,17 +1021,17 @@
procedure doStepAirAttackWork(Gear: PGear);
begin
AllInactive:= false;
-Gear^.X:= Gear^.X + Gear^.Tag * cAirPlaneSpeed;
+Gear^.X:= Gear^.X + cAirPlaneSpeed * Gear^.Tag;
if (Gear^.Health > 0)and( not (Gear^.X < Gear^.dX))and(Gear^.X < Gear^.dX + cAirPlaneSpeed) then
begin
dec(Gear^.Health);
case Gear^.State of
- 0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.Tag * cBombsSpeed, 0, 0);
- 1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, Gear^.Tag * cBombsSpeed, 0, 0);
+ 0: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
+ 1: FollowGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtMine, 0, cBombsSpeed * Gear^.Tag, _0, 0);
end;
- Gear^.dX:= Gear^.dX + Gear^.Tag * cBombsDistance
+ Gear^.dX:= Gear^.dX + cBombsDistance * Gear^.Tag
end;
-if (Gear^.X > 3072) or (Gear^.X < -1024) then DeleteGear(Gear)
+if (hwRound(Gear^.X) > 3072) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear)
end;
procedure doStepAirAttack(Gear: PGear);
@@ -1039,13 +1039,13 @@
AllInactive:= false;
if Gear^.X.QWordValue = 0 then Gear^.Tag:= 1
else Gear^.Tag:= -1;
-Gear^.X:= 1024 - Gear^.Tag * 2048;
-Gear^.Y:= -128;
-Gear^.dX:= TargetPoint.X -
- Gear^.Tag * cBombsDistance * 5 / 2;
+Gear^.X:= _1024 - _2048 * Gear^.Tag;
+Gear^.Y:= -_128;
+Gear^.dX:= int2hwFloat(TargetPoint.X) -
+ cBombsDistance * _5 * Gear^.Tag / _2;
-if TargetPoint.Y - Gear^.Y > 0 then
- Gear^.dX:= Gear^.dX - Gear^.Tag * cBombsSpeed * hwSqrt(2 * (TargetPoint.Y - Gear^.Y) / cGravity);
+if TargetPoint.Y - hwRound(Gear^.Y) > 0 then
+ Gear^.dX:= Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(TargetPoint.Y) - Gear^.Y) * 2 / cGravity) * Gear^.Tag;
Gear^.Health:= 6;
Gear^.doStep:= @doStepAirAttackWork
end;
@@ -1063,7 +1063,7 @@
exit
end;
if (GameTicks and $3F) = 0 then
- AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, 0, 0, 0)
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
end;
////////////////////////////////////////////////////////////////////////////////
--- a/hedgewars/HHHandlers.inc Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/HHHandlers.inc Sat Mar 17 18:17:19 2007 +0000
@@ -60,19 +60,19 @@
PlaySound(sndShotgunReload, false);
CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtShotgunShot, 0, xx * _0_5, yy * _0_5, 0);
end;
- amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, 0, 0, 0);
+ amPickHammer: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) + cHHRadius, gtPickHammer, 0, _0, _0, 0);
amSkip: TurnTimeLeft:= 0;
amRope: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtRope, 0, xx, yy, 0);
- amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, hwSign(dX) * _0_02, 0, 3000);
+ amMine: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtMine, 0, SignAs(_0_02, dX), _0, 3000);
amDEagle: AddGear(hwRound(X), hwRound(Y), gtDEagleShot, 0, xx * _0_5, yy * _0_5, 0);
- amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, hwSign(dX) * _0_03, 0, 5000);
+ amDynamite: AddGear(hwRound(X) + hwSign(dX) * 7, hwRound(Y), gtDynamite, 0, SignAs(_0_03, dX), _0, 5000);
amBaseballBat: AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtShover, 0, xx * _0_5, yy * _0_5, 0)^.Radius:= 20;
- amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, 0, 0, 0);
- amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, 0, 0, 0);
- amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, 0, 0, 0);
- amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, 0, 0, 0);
- amBlowTorch: CurAmmoGear:= AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtBlowTorch, 0, hwSign(Gear^.dX) * _0_5, 0, 0);
- amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, 0, 0, 0);
+ amFirePunch: CurAmmoGear:= AddGear(hwRound(X) + hwSign(dX) * 10, hwRound(Y), gtFirePunch, 0, _0, _0, 0);
+ amParachute: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtParachute, 0, _0, _0, 0);
+ amAirAttack: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 0, _0, _0, 0);
+ amMineStrike: AddGear(Ammo^[CurSlot, CurAmmo].Pos, 0, gtAirAttack, 1, _0, _0, 0);
+ amBlowTorch: CurAmmoGear:= AddGear(hwRound(X), hwRound(Y), gtBlowTorch, 0, SignAs(_0_5, dX), _0, 0);
+ amGirder: CurAmmoGear:= AddGear(0, 0, gtGirder, Ammo^[CurSlot, CurAmmo].Pos, _0, _0, 0);
end;
Power:= 0;
if CurAmmoGear <> nil then
@@ -153,13 +153,13 @@
begin
Gear^.Message:= 0;
if not TestCollisionYwithGear(Gear, -1) then
- if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - 2 else
- if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - 1;
+ if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _2 else
+ if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1;
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
or TestCollisionYwithGear(Gear, -1)) then
begin
Gear^.dY:= -_0_15;
- Gear^.dX:= hwSign(Gear^.dX) * _0_15;
+ Gear^.dX:= SignAs(_0_15, Gear^.dX);
Gear^.State:= Gear^.State or gstFalling or gstHHJumping;
exit
end;
@@ -183,45 +183,45 @@
PHedgehog(Gear^.Hedgehog)^.visStepPos:= (PHedgehog(Gear^.Hedgehog)^.visStepPos + 1) and 7;
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
begin
- if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
end;
- if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + hwSign(Gear^.dX);
+ if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then Gear^.X:= Gear^.X + SignAs(_1, Gear^.dX);
SetAllHHToActive;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y - 6;
- Gear^.dY:= 0;
+ Gear^.Y:= Gear^.Y - _6;
+ Gear^.dY:= _0;
Gear^.State:= Gear^.State or gstFalling
end;
end
@@ -287,13 +287,13 @@
begin
Gear^.State:= Gear^.State or gstHHHJump;
Gear^.dY:= -_0_25;
- Gear^.dX:= hwSign(Gear^.dX) * _0_02
+ Gear^.dX:= SignAs(_0_02, Gear^.dX)
end;
Gear^.Message:= Gear^.Message and not (gm_LJump or gm_HJump);
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX);
Gear^.X:= Gear^.X + Gear^.dX;
Gear^.dY:= Gear^.dY + cGravity;
- if (Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0;
+ if (Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0;
Gear^.Y:= Gear^.Y + Gear^.dY;
if (not Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, 1) then
begin
@@ -302,7 +302,7 @@
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping or gstHHHJump);
StepTicks:= 300;
- Gear^.dY:= 0
+ Gear^.dY:= _0
end;
CheckGearDrowning(Gear);
exit
@@ -319,7 +319,7 @@
//DeleteCI(Gear);
if not TestCollisionYwithGear(Gear, 1) then
begin
- if (Gear^.dY < 0) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0;
+ if (Gear^.dY.isNegative) and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0;
Gear^.State:= Gear^.State or gstFalling or gstMoving;
Gear^.dY:= Gear^.dY + cGravity
end else begin
@@ -327,7 +327,7 @@
if ((hwAbs(Gear^.dX) + hwAbs(Gear^.dY)) < _0_55)
and ((Gear^.State and gstHHJumping) <> 0) then SetLittle(Gear^.dX);
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping);
- if Gear^.dY > 0 then Gear^.dY:= 0;
+ if Gear^.dY > _0 then Gear^.dY:= _0;
if ((Gear^.State and gstMoving) <> 0) then Gear^.dX:= Gear^.dX * Gear^.Friction
end;
@@ -337,11 +337,11 @@
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
if ((Gear^.State and gstFalling) = 0) then
if hwAbs(Gear^.dX) > _0_01 then
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - 1 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -2, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - 2 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -3, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_9; Gear^.Y:= Gear^.Y - 3 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -4, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_87; Gear^.Y:= Gear^.Y - 4 end else
- if not TestCollisionXwithXYShift(Gear, hwSign(Gear^.dX) - Gear^.dX, -5, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_84; Gear^.Y:= Gear^.Y - 5 end else
+ if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -1, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_96; Gear^.Y:= Gear^.Y - _1 end else
+ if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -2, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_93; Gear^.Y:= Gear^.Y - _2 end else
+ if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -3, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_9 ; Gear^.Y:= Gear^.Y - _3 end else
+ if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -4, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_87; Gear^.Y:= Gear^.Y - _4 end else
+ if not TestCollisionXwithXYShift(Gear, int2hwFloat(hwSign(Gear^.dX)) - Gear^.dX, -5, hwSign(Gear^.dX)) then begin Gear^.X:= Gear^.X + Gear^.dX; Gear^.dX:= Gear^.dX * _0_84; Gear^.Y:= Gear^.Y - _5 end else
if hwAbs(Gear^.dX) > _0_02 then Gear^.dX:= -Gear^.Elasticity * Gear^.dX
else begin
Gear^.State:= Gear^.State and not gstMoving;
@@ -358,18 +358,18 @@
begin
Gear^.State:= Gear^.State and not gstMoving;
SetLittle(Gear^.dX);
- Gear^.dY:= 0
+ Gear^.dY:= _0
end else Gear^.State:= Gear^.State or gstMoving;
if (Gear^.State and gstMoving) <> 0 then
begin
Gear^.X:= Gear^.X + Gear^.dX;
Gear^.Y:= Gear^.Y + Gear^.dY;
- if (Gear^.dY > 0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
+ if (Gear^.dY > _0) and not TestCollisionYwithGear(Gear, 1) and TestCollisionYwithXYShift(Gear, 0, 1, 1) then
begin
CheckHHDamage(Gear);
- Gear^.dY:= 0;
- Gear^.Y:= Gear^.Y + 1
+ Gear^.dY:= _0;
+ Gear^.Y:= Gear^.Y + _1
end;
end else
if Gear^.Health = 0 then
@@ -377,7 +377,7 @@
if AllInactive then
begin
doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
- AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog;
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtGrave, 0, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
DeleteGear(Gear);
SetAllToActive
end;
--- a/hedgewars/hwengine.dpr Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/hwengine.dpr Sat Mar 17 18:17:19 2007 +0000
@@ -1,4 +1,4 @@
-(*
+ (*
* Hedgewars, a worms-like game
* Copyright (c) 2004-2007 Andrey Korotaev <unC0Rr@gmail.com>
*
@@ -163,7 +163,7 @@
////////////////////
procedure GetParams;
-var c: LongInt;
+var
{$IFDEF DEBUGFILE}
i: LongInt;
{$ENDIF}
@@ -177,16 +177,16 @@
case ParamCount of
12: begin
- val(ParamStr(2), cScreenWidth, c);
- val(ParamStr(3), cScreenHeight, c);
+ val(ParamStr(2), cScreenWidth);
+ val(ParamStr(3), cScreenHeight);
cBitsStr:= ParamStr(4);
- val(cBitsStr, cBits, c);
- val(ParamStr(5), ipcPort, c);
+ val(cBitsStr, cBits);
+ val(ParamStr(5), ipcPort);
cFullScreen:= ParamStr(6) = '1';
isSoundEnabled:= ParamStr(7) = '1';
cLocaleFName:= ParamStr(8);
- val(ParamStr(9), cInitVolume, c);
- val(ParamStr(10), cTimerInterval, c);
+ val(ParamStr(9), cInitVolume);
+ val(ParamStr(10), cTimerInterval);
PathPrefix:= ParamStr(11);
cShowFPS:= ParamStr(12) = '1';
for p:= Succ(Low(TPathType)) to High(TPathType) do
@@ -194,7 +194,7 @@
AddClouds
end;
3: begin
- val(ParamStr(2), ipcPort, c);
+ val(ParamStr(2), ipcPort);
GameType:= gmtLandPreview;
if ParamStr(3) <> 'landpreview' then OutError(errmsgShouldntRun, true);
end
--- a/hedgewars/uAI.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uAI.pas Sat Mar 17 18:17:19 2007 +0000
@@ -156,7 +156,7 @@
while (i < Stack.Count) do
begin
if(not(hwAbs(Stack.States[i].Hedgehog.X - Me^.X) +
- hwAbs(Stack.States[i].Hedgehog.Y - Me^.Y) > 2)) and
+ hwAbs(Stack.States[i].Hedgehog.Y - Me^.Y) > _2)) and
(Stack.States[i].Hedgehog.Message = Me^.Message) then exit(true);
inc(i)
end;
--- a/hedgewars/uAIAmmoTests.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uAIAmmoTests.pas Sat Mar 17 18:17:19 2007 +0000
@@ -63,7 +63,7 @@
function TestBazooka(Me: PGear; Targ: TPoint; Level: LongInt; var Time: Longword; var Angle, Power: LongInt; var ExplX, ExplY, ExplR: LongInt): LongInt;
var Vx, Vy, r: hwFloat;
- rTime: hwFloat;
+ rTime: LongInt;
Score, EX, EY: LongInt;
Result: LongInt;
@@ -76,7 +76,7 @@
y:= Me^.Y;
dX:= Vx;
dY:= -Vy;
- t:= hwRound(rTime);
+ t:= rTime;
repeat
x:= x + dX;
y:= y + dY;
@@ -98,10 +98,10 @@
Result:= BadTurn;
repeat
rTime:= rTime + 300 + Level * 50 + random(300);
- Vx:= - cWindSpeed * rTime * _0_5 + (Targ.X - hwRound(Me^.X)) / rTime;
- Vy:= cGravity * rTime * _0_5 - (Targ.Y - hwRound(Me^.Y)) / rTime;
+ Vx:= - cWindSpeed * rTime * _0_5 + (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(rTime);
+ Vy:= cGravity * rTime * _0_5 - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(rTime);
r:= Distance(Vx, Vy);
- if not (r > 1) then
+ if not (r > _1) then
begin
Score:= CheckTrace;
if Result <= Score then
@@ -150,10 +150,10 @@
ExplR:= 0;
repeat
inc(TestTime, 1000);
- Vx:= (Targ.X - Me^.X) / (TestTime + tDelta);
- Vy:= cGravity * ((TestTime + tDelta) div 2) - (Targ.Y - Me^.Y) / (TestTime + tDelta);
+ Vx:= (int2hwFloat(Targ.X) - Me^.X) / int2hwFloat(TestTime + tDelta);
+ Vy:= cGravity * ((TestTime + tDelta) div 2) - (int2hwFloat(Targ.Y) - Me^.Y) / int2hwFloat(TestTime + tDelta);
r:= Distance(Vx, Vy);
- if not (r > 1) then
+ if not (r > _1) then
begin
Score:= CheckTrace;
if Result < Score then
@@ -180,8 +180,8 @@
Power:= 1;
if Metric(hwRound(Me^.X), hwRound(Me^.Y), Targ.X, Targ.Y) < 80 then
exit(BadTurn);
-Vx:= (Targ.X - Me^.X) * _1div1024;
-Vy:= (Targ.Y - Me^.Y) * _1div1024;
+Vx:= (int2hwFloat(Targ.X) - Me^.X) * _1div1024;
+Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * _1div1024;
x:= Me^.X;
y:= Me^.Y;
Angle:= DxDy2AttackAngle(Vx, -Vy);
@@ -197,7 +197,7 @@
else dec(Result, Level * 4000);
exit(Result)
end
-until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024);
+until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x < _0) or (y < _0) or (x > _2048) or (y > _1024);
TestShotgun:= BadTurn
end;
@@ -209,11 +209,11 @@
ExplR:= 0;
Time:= 0;
Power:= 1;
-if hwAbs(Me^.X - Targ.X) + hwAbs(Me^.Y - Targ.Y) < 80 then
+if Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 80 then
exit(BadTurn);
-t:= _0_5 / Distance(Targ.X - Me^.X, Targ.Y - Me^.Y);
-Vx:= (Targ.X - Me^.X) * t;
-Vy:= (Targ.Y - Me^.Y) * t;
+t:= _0_5 / Distance(int2hwFloat(Targ.X) - Me^.X, int2hwFloat(Targ.Y) - Me^.Y);
+Vx:= (int2hwFloat(Targ.X) - Me^.X) * t;
+Vy:= (int2hwFloat(Targ.Y) - Me^.Y) * t;
x:= Me^.X;
y:= Me^.Y;
Angle:= DxDy2AttackAngle(Vx, -Vy);
@@ -223,9 +223,9 @@
y:= y + vY;
if ((hwRound(x) and $FFFFF800) = 0)and((hwRound(y) and $FFFFFC00) = 0)
and (Land[hwRound(y), hwRound(x)] <> 0) then inc(d);
-until (hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 4) or (x < 0) or (y < 0) or (x > 2048) or (y > 1024) or (d > 200);
-if hwAbs(Targ.X - x) + hwAbs(Targ.Y - y) < 2 then Result:= max(0, (4 - d div 50) * 7 * 1024)
- else Result:= Low(LongInt);
+until (Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 4) or (x < _0) or (y < _0) or (x > _2048) or (y > _1024) or (d > 200);
+if Abs(Targ.X - hwRound(x)) + Abs(Targ.Y - hwRound(y)) < 3 then Result:= max(0, (4 - d div 50) * 7 * 1024)
+ else Result:= Low(LongInt);
TestDesertEagle:= Result
end;
@@ -233,13 +233,14 @@
var Result: LongInt;
begin
ExplR:= 0;
-if (Level > 2) and not (hwAbs(Me^.X - Targ.X) + hwAbs(Me^.Y - Targ.Y) < 25) then
+if (Level > 2) and not (Abs(hwRound(Me^.X) - Targ.X) + Abs(hwRound(Me^.Y) - Targ.Y) < 25) then
exit(BadTurn);
Time:= 0;
Power:= 1;
-Angle:= DxDy2AttackAngle(hwSign(Targ.X - Me^.X), 1);
-Result:= RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Targ.X - Me^.X), hwRound(Me^.Y), 15, 30);
+if (Targ.X) - hwRound(Me^.X) >= 0 then Angle:= cMaxAngle div 4
+ else Angle:= - cMaxAngle div 4;
+Result:= RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X), hwRound(Me^.Y), 15, 30);
if Result <= 0 then Result:= BadTurn else inc(Result);
TestBaseballBat:= Result
end;
@@ -251,12 +252,13 @@
Time:= 0;
Power:= 1;
Angle:= 0;
-if (hwAbs(Me^.X - Targ.X) > 25) or (hwAbs(Me^.Y - 50 - Targ.Y) > 50) then
+if (Abs(hwRound(Me^.X) - Targ.X) > 25) or (Abs(hwRound(Me^.Y) - 50 - Targ.Y) > 50) then
exit(BadTurn);
Result:= 0;
for i:= 0 to 4 do
- Result:= Result + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(Targ.X - Me^.X), hwRound(Me^.Y) - 20 * i - 5, 10, 30);
+ Result:= Result + RateShove(Me, hwRound(Me^.X) + 10 * hwSign(int2hwFloat(Targ.X) - Me^.X),
+ hwRound(Me^.Y) - 20 * i - 5, 10, 30);
if Result <= 0 then Result:= BadTurn else inc(Result);
TestFirePunch:= Result
end;
--- a/hedgewars/uAIMisc.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uAIMisc.pas Sat Mar 17 18:17:19 2007 +0000
@@ -146,7 +146,7 @@
for i:= 0 to Pred(bonuses.Count) do
with bonuses.ar[i] do
begin
- r:= hwRound(Distance(Gear^.X - X, Gear^.Y - y));
+ r:= hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
if r < Radius then
inc(Result, Score * (Radius - r))
end;
@@ -180,7 +180,7 @@
for i:= 0 to Targets.Count do
with Targets.ar[i] do
begin
- dmg:= r - hwRound(Distance(Point.x - x, Point.y - y));
+ dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y));
if dmg > 0 then
begin
dmg:= dmg shr 1;
@@ -202,7 +202,7 @@
for i:= 0 to Pred(Targets.Count) do
with Targets.ar[i] do
begin
- dmg:= r - hwRound(Distance(Point.x - x, Point.y - y));
+ dmg:= r - hwRound(DistanceI(Point.x - x, Point.y - y));
if dmg > 0 then
begin
if power > abs(Score) then
@@ -236,47 +236,47 @@
end else exit(Result);
jmpLJump: begin
if not TestCollisionYwithGear(Gear, -1) then
- if not TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - 2 else
- if not TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - 1;
+ if not TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - int2hwFloat(2) else
+ if not TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)) then Gear^.Y:= Gear^.Y - _1;
if not (TestCollisionXwithGear(Gear, hwSign(Gear^.dX))
or TestCollisionYwithGear(Gear, -1)) then
begin
Gear^.dY:= -_0_15;
- Gear^.dX:= hwSign(Gear^.dX) * _0_15;
+ Gear^.dX:= SignAs(_0_15, Gear^.dX);
Gear^.State:= Gear^.State or gstFalling or gstHHJumping
end else exit(Result)
end
end;
repeat
-if not (Gear^.Y + cHHRadius < cWaterLine) then exit(Result);
+if not (hwRound(Gear^.Y) + cHHRadius < cWaterLine) then exit(Result);
if (Gear^.State and gstFalling) <> 0 then
begin
if (GoInfo.Ticks = 350) then
if (not (hwAbs(Gear^.dX) > cLittle)) and (Gear^.dY < -_0_02) then
begin
Gear^.dY:= -_0_25;
- Gear^.dX:= hwSign(Gear^.dX) * _0_02
+ Gear^.dX:= SignAs(_0_02, Gear^.dX)
end;
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then SetLittle(Gear^.dX);
Gear^.X:= Gear^.X + Gear^.dX;
inc(GoInfo.Ticks);
Gear^.dY:= Gear^.dY + cGravity;
if Gear^.dY > _0_4 then exit(Result);
- if (Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= 0;
+ if (Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, -1) then Gear^.dY:= _0;
Gear^.Y:= Gear^.Y + Gear^.dY;
if (not Gear^.dY.isNegative)and TestCollisionYwithGear(Gear, 1) then
begin
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping);
- Gear^.dY:= 0;
+ Gear^.dY:= _0;
case JumpType of
- jmpHJump: if (bY - Gear^.Y > 5) then
+ jmpHJump: if bY - hwRound(Gear^.Y) > 5 then
begin
Result:= true;
GoInfo.JumpType:= jmpHJump;
inc(GoInfo.Ticks, 300 + 300) // 300 before jump, 300 after
end;
- jmpLJump: if hwAbs(bX - Gear^.X) > 30 then
+ jmpLJump: if abs(bX - hwRound(Gear^.X)) > 30 then
begin
Result:= true;
GoInfo.JumpType:= jmpLJump;
@@ -319,7 +319,7 @@
begin
inc(GoInfo.Ticks, 300);
Gear^.State:= Gear^.State and not (gstFalling or gstHHJumping);
- Gear^.dY:= 0;
+ Gear^.dY:= _0;
Result:= true;
HHJump(AltGear, jmpLJump, GoInfo); // try ljump instead of fall
exit(Result)
@@ -330,47 +330,47 @@
if (Gear^.Message and gm_Right )<>0 then Gear^.dX:= cLittle else exit(Result);
if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
begin
- if not (TestCollisionXwithXYShift(Gear, 0, -6, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -5, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -4, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -3, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -2, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
- if not (TestCollisionXwithXYShift(Gear, 0, -1, hwSign(Gear^.dX))
- or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - 1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -6, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -5, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -4, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
+ if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
+ or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
end;
if not TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
begin
- Gear^.X:= Gear^.X + hwSign(Gear^.dX);
+ Gear^.X:= Gear^.X + int2hwFloat(hwSign(Gear^.dX));
inc(GoInfo.Ticks, cHHStepTicks)
end;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y + 1;
+ Gear^.Y:= Gear^.Y + _1;
if not TestCollisionYwithGear(Gear, 1) then
begin
- Gear^.Y:= Gear^.Y - 6;
- Gear^.dY:= 0;
+ Gear^.Y:= Gear^.Y - _6;
+ Gear^.dY:= _0;
Gear^.State:= Gear^.State or gstFalling
end
end
--- a/hedgewars/uCollisions.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uCollisions.pas Sat Mar 17 18:17:19 2007 +0000
@@ -34,7 +34,7 @@
function TestCollisionXwithGear(Gear: PGear; Dir: LongInt): boolean;
function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean;
function TestCollisionY(Gear: PGear; Dir: LongInt): boolean;
-function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: hwFloat; Dir: LongInt): boolean;
+function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean;
implementation
@@ -119,13 +119,13 @@
TestCollisionXwithGear:= false
end;
-function TestCollisionXwithXYShift(Gear: PGear; ShiftX, ShiftY: hwFloat; Dir: LongInt): boolean;
+function TestCollisionXwithXYShift(Gear: PGear; ShiftX: hwFloat; ShiftY: LongInt; Dir: LongInt): boolean;
begin
Gear^.X:= Gear^.X + ShiftX;
-Gear^.Y:= Gear^.Y + ShiftY;
+Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
TestCollisionXwithXYShift:= TestCollisionXwithGear(Gear, Dir);
Gear^.X:= Gear^.X - ShiftX;
-Gear^.Y:= Gear^.Y - ShiftY
+Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
end;
function TestCollisionYwithGear(Gear: PGear; Dir: LongInt): boolean;
@@ -168,11 +168,11 @@
function TestCollisionYwithXYShift(Gear: PGear; ShiftX, ShiftY: LongInt; Dir: LongInt): boolean;
begin
-Gear^.X:= Gear^.X + ShiftX;
-Gear^.Y:= Gear^.Y + ShiftY;
+Gear^.X:= Gear^.X + int2hwFloat(ShiftX);
+Gear^.Y:= Gear^.Y + int2hwFloat(ShiftY);
TestCollisionYwithXYShift:= TestCollisionYwithGear(Gear, Dir);
-Gear^.X:= Gear^.X - ShiftX;
-Gear^.Y:= Gear^.Y - ShiftY
+Gear^.X:= Gear^.X - int2hwFloat(ShiftX);
+Gear^.Y:= Gear^.Y - int2hwFloat(ShiftY)
end;
end.
--- a/hedgewars/uFloat.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uFloat.pas Sat Mar 17 18:17:19 2007 +0000
@@ -36,7 +36,7 @@
end;
{$endif FPC_LITTLE_ENDIAN}
-operator := (i: LongInt) z : hwFloat;
+function int2hwFloat (i: LongInt) : hwFloat;
operator + (z1, z2: hwFloat) z : hwFloat;
operator - (z1, z2: hwFloat) z : hwFloat;
@@ -45,6 +45,7 @@
operator * (z1, z2: hwFloat) z : hwFloat;
operator * (z1: hwFloat; z2: LongInt) z : hwFloat;
operator / (z1, z2: hwFloat) z : hwFloat;
+operator / (z1: hwFloat; z2: LongInt) z : hwFloat;
operator < (z1, z2: hwFloat) b : boolean;
operator > (z1, z2: hwFloat) b : boolean;
@@ -55,8 +56,10 @@
function hwSqr(t: hwFloat): hwFloat;
function hwSqrt(t: hwFloat): hwFloat;
function Distance(dx, dy: hwFloat): hwFloat;
+function DistanceI(dx, dy: LongInt): hwFloat;
function AngleSin(Angle: Longword): hwFloat;
function AngleCos(Angle: Longword): hwFloat;
+function SignAs(num, signum: hwFloat): hwFloat;
const _1div1024: hwFloat = (isNegative: false; QWordValue: 4194304);
_1div10000: hwFloat = (isNegative: false; QWordValue: 429496);
@@ -95,6 +98,24 @@
_0_995: hwFloat = (isNegative: false; QWordValue: 4273492459);
_0_999: hwFloat = (isNegative: false; QWordValue: 4290672328);
_1_9: hwFloat = (isNegative: false; QWordValue: 8160437862);
+ _0: hwFloat = (isNegative: false; QWordValue: 0);
+ _1: hwFloat = (isNegative: false; QWordValue: 4294967296);
+ _2: hwFloat = (isNegative: false; QWordValue: 4294967296 * 2);
+ _3: hwFloat = (isNegative: false; QWordValue: 4294967296 * 3);
+ _4: hwFloat = (isNegative: false; QWordValue: 4294967296 * 4);
+ _5: hwFloat = (isNegative: false; QWordValue: 4294967296 * 5);
+ _6: hwFloat = (isNegative: false; QWordValue: 4294967296 * 6);
+ _10: hwFloat = (isNegative: false; QWordValue: 4294967296 * 10);
+ _16: hwFloat = (isNegative: false; QWordValue: 4294967296 * 16);
+ _19: hwFloat = (isNegative: false; QWordValue: 4294967296 * 19);
+ _20: hwFloat = (isNegative: false; QWordValue: 4294967296 * 20);
+ _25: hwFloat = (isNegative: false; QWordValue: 4294967296 * 25);
+ _30: hwFloat = (isNegative: false; QWordValue: 4294967296 * 30);
+ _128: hwFloat = (isNegative: false; QWordValue: 4294967296 * 128);
+ _450: hwFloat = (isNegative: false; QWordValue: 4294967296 * 450);
+ _1024: hwFloat = (isNegative: false; QWordValue: 4398046511104);
+ _2048: hwFloat = (isNegative: false; QWordValue: 8796093022208);
+ _10000: hwFloat = (isNegative: false; QWordValue: 4294967296 * 10000);
cLittle: hwFloat = (isNegative: false; QWordValue: 1);
cHHKick: hwFloat = (isNegative: false; QWordValue: 128849018);
@@ -109,11 +130,11 @@
{$IFDEF FPC}
-operator := (i: LongInt) z : hwFloat;
+function int2hwFloat (i: LongInt) : hwFloat;
begin
-z.isNegative:= i < 0;
-z.Round:= abs(i);
-z.Frac:= 0
+int2hwFloat.isNegative:= i < 0;
+int2hwFloat.Round:= abs(i);
+int2hwFloat.Frac:= 0
end;
operator + (z1, z2: hwFloat) z : hwFloat;
@@ -196,6 +217,13 @@
end
end;
+operator / (z1: hwFloat; z2: LongInt) z : hwFloat;
+begin
+z.isNegative:= z1.isNegative xor (z2 < 0);
+z2:= abs(z2);
+z.QWordValue:= z1.QWordValue div z2
+end;
+
operator < (z1, z2: hwFloat) b : boolean;
begin
if z1.isNegative <> z2.isNegative then
@@ -265,6 +293,17 @@
Distance:= Result
end;
+function DistanceI(dx, dy: LongInt): hwFloat;
+begin
+DistanceI:= Distance(int2hwFloat(dx), int2hwFloat(dy))
+end;
+
+function SignAs(num, signum: hwFloat): hwFloat;
+begin
+SignAs:= num;
+SignAs.isNegative:= signum.isNegative
+end;
+
{$INCLUDE SinTable.inc}
function AngleSin(Angle: Longword): hwFloat;
--- a/hedgewars/uGears.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uGears.pas Sat Mar 17 18:17:19 2007 +0000
@@ -165,8 +165,8 @@
New(Result);
{$IFDEF DEBUGFILE}AddFileLog('AddGear: type = ' + inttostr(ord(Kind)));{$ENDIF}
FillChar(Result^, sizeof(TGear), 0);
-Result^.X:= X;
-Result^.Y:= Y;
+Result^.X:= int2hwFloat(X);
+Result^.Y:= int2hwFloat(Y);
Result^.Kind := Kind;
Result^.State:= State;
Result^.Active:= true;
@@ -216,18 +216,18 @@
Result^.Timer:= 4000
end;
gtSmokeTrace: begin
- Result^.X:= Result^.X - 16;
- Result^.Y:= Result^.Y - 16;
+ Result^.X:= Result^.X - _16;
+ Result^.Y:= Result^.Y - _16;
Result^.State:= 8
end;
gtRope: begin
Result^.Radius:= 3;
- Result^.Friction:= 450;
+ Result^.Friction:= _450;
RopePoints.Count:= 0;
end;
gtExplosion: begin
- Result^.X:= Result^.X - 25;
- Result^.Y:= Result^.Y - 25;
+ Result^.X:= Result^.X - _25;
+ Result^.Y:= Result^.Y - _25;
end;
gtMine: begin
Result^.Radius:= 3;
@@ -241,7 +241,6 @@
end;
gtDEagleShot: begin
Result^.Radius:= 1;
- Result^.Radius:= 1;
Result^.Health:= 50
end;
gtDynamite: begin
@@ -292,10 +291,10 @@
exit
end else
begin
- if not (Gear^.Y < cWaterLine) then
+ if not (hwRound(Gear^.Y) < cWaterLine) then
begin
t:= max(Gear^.Damage, Gear^.Health);
- AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog;
+ AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
inc(StepDamage, t)
end;
team:= PHedgehog(Gear^.Hedgehog)^.Team;
@@ -327,7 +326,7 @@
if Gear^.Health < Gear^.Damage then Gear^.Health:= 0
else dec(Gear^.Health, Gear^.Damage);
AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12 - PHedgehog(Gear^.Hedgehog)^.HealthTag^.h,
- gtHealthTag, Gear^.Damage, 0, 0, 0)^.Hedgehog:= Gear^.Hedgehog;
+ gtHealthTag, Gear^.Damage, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
RenderHealth(PHedgehog(Gear^.Hedgehog)^);
RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
@@ -622,10 +621,10 @@
procedure AddMiscGears;
var i: LongInt;
begin
-AddGear(0, 0, gtATStartGame, 0, 0, 0, 2000);
+AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
if (GameFlags and gfForts) = 0 then
for i:= 0 to 3 do
- FindPlace(AddGear(0, 0, gtMine, 0, 0, 0, 0), false, 0, 2048);
+ FindPlace(AddGear(0, 0, gtMine, 0, _0, _0, 0), false, 0, 2048);
end;
procedure AddClouds;
@@ -650,13 +649,13 @@
TargetPoint.X:= NoPointX;
{$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
if (Mask and EXPLDontDraw) = 0 then DrawExplosion(X, Y, Radius);
-if Radius = 50 then AddGear(X, Y, gtExplosion, 0, 0, 0, 0);
+if Radius = 50 then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false);
if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1;
Gear:= GearsList;
while Gear <> nil do
begin
- dmg:= Radius - hwRound(Distance(Gear^.X - X, Gear^.Y - Y));
+ dmg:= Radius - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
if dmg > 0 then
begin
dmg:= dmg div 2;
@@ -669,8 +668,8 @@
if (Mask and EXPLNoDamage) = 0 then inc(Gear^.Damage, dmg);
if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
begin
- Gear^.dX:= Gear^.dX + (_0_005 * dmg + cHHKick) * hwSign(Gear^.X - X);
- Gear^.dY:= Gear^.dY + (_0_005 * dmg + cHHKick) * hwSign(Gear^.Y - Y);
+ Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
+ Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
Gear^.Active:= true;
FollowGear:= Gear
end;
@@ -683,7 +682,7 @@
end;
Gear:= Gear^.NextGear
end;
-//uAIMisc.AwareOfExplosion(0, 0, 0)
+uAIMisc.AwareOfExplosion(0, 0, 0)
end;
procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt);
@@ -742,7 +741,7 @@
while t <> nil do
begin
if (t <> Gear) and (t^.Kind = Kind) then
- if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > 1) then
+ if not((hwSqr(Gear^.X - t^.X) / rX + hwSqr(Gear^.Y - t^.Y) / rY) > _1) then
exit(t);
t:= t^.NextGear
end;
@@ -756,7 +755,7 @@
while t <> nil do
begin
if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then
- if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - cHHRadius) * 2 > 2) then
+ if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then
begin
inc(t^.Damage, 5);
t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02;
@@ -778,7 +777,7 @@
while t <> nil do
begin
if t^.Kind in Kind then
- if not (hwSqr(mX - t^.X) / rX + hwSqr(mY - t^.Y) / rY > 1) then
+ if not (hwSqr(int2hwFloat(mX) - t^.X) / rX + hwSqr(int2hwFloat(mY) - t^.Y) / rY > _1) then
exit(t);
t:= t^.NextGear
end;
@@ -804,7 +803,7 @@
i: TAmmoType;
begin
if (CountGears(gtCase) >= 5) or (getrandom(cCaseFactor) <> 0) then exit;
-FollowGear:= AddGear(0, 0, gtCase, 0, 0, 0, 0);
+FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0);
case getrandom(2) of
0: begin
FollowGear^.Health:= 25;
@@ -890,8 +889,8 @@
if cnt2 > 0 then
with ar2[GetRandom(cnt2)] do
begin
- Gear^.X:= x;
- Gear^.Y:= y;
+ Gear^.X:= int2hwFloat(x);
+ Gear^.Y:= int2hwFloat(y);
{$IFDEF DEBUGFILE}
AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
{$ENDIF}
--- a/hedgewars/uLand.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uLand.pas Sat Mar 17 18:17:19 2007 +0000
@@ -136,21 +136,21 @@
procedure Vector(p1, p2, p3: TPoint; var Vx, Vy: hwFloat);
var d1, d2, d: hwFloat;
begin
-Vx:= p1.X - p3.X;
-Vy:= p1.Y - p3.Y;
-d:= Distance(p2.X - p1.X, p2.Y - p1.Y);
-d1:= Distance(p2.X - p3.X, p2.Y - p3.Y);
+Vx:= int2hwFloat(p1.X - p3.X);
+Vy:= int2hwFloat(p1.Y - p3.Y);
+d:= DistanceI(p2.X - p1.X, p2.Y - p1.Y);
+d1:= DistanceI(p2.X - p3.X, p2.Y - p3.Y);
d2:= Distance(Vx, Vy);
if d1 < d then d:= d1;
if d2 < d then d:= d2;
d:= d * _1div3;
if d2.QWordValue = 0 then
begin
- Vx:= 0;
- Vy:= 0
+ Vx:= _0;
+ Vy:= _0
end else
begin
- d2:= 1 / d2;
+ d2:= _1 / d2;
Vx:= Vx * d2;
Vy:= Vy * d2;
@@ -162,8 +162,8 @@
procedure AddLoopPoints(var pa, opa: TPixAr; StartI, EndI: LongInt; Delta: hwFloat);
var i, pi, ni: LongInt;
NVx, NVy, PVx, PVy: hwFloat;
- x1, x2, y1, y2, cx1, cx2, cy1, cy2: hwFloat;
- tsq, tcb, t, r1, r2, r3: hwFloat;
+ x1, x2, y1, y2: LongInt;
+ tsq, tcb, t, r1, r2, r3, cx1, cx2, cy1, cy2: hwFloat;
X, Y: LongInt;
begin
pi:= EndI;
@@ -185,18 +185,18 @@
y1:= opa.ar[pi].y;
x2:= opa.ar[i].x;
y2:= opa.ar[i].y;
- cx1:= x1 - PVx;
- cy1:= y1 - PVy;
- cx2:= x2 + NVx;
- cy2:= y2 + NVy;
- t:= 0;
+ cx1:= int2hwFloat(x1) - PVx;
+ cy1:= int2hwFloat(y1) - PVy;
+ cx2:= int2hwFloat(x2) + NVx;
+ cy2:= int2hwFloat(y2) + NVy;
+ t:= _0;
while t.Round = 0 do
begin
tsq:= t * t;
tcb:= tsq * t;
- r1:= (1 - 3*t + 3*tsq - tcb);
- r2:= ( 3*t - 6*tsq + 3*tcb);
- r3:= ( 3*tsq - 3*tcb);
+ r1:= (_1 - t*3 + tsq*3 - tcb);
+ r2:= ( t*3 - tsq*6 + tcb*3);
+ r3:= ( tsq*3 - tcb*3);
X:= hwRound(r1 * x1 + r2 * cx1 + r3 * cx2 + tcb * x2);
Y:= hwRound(r1 * y1 + r2 * cy1 + r3 * cy2 + tcb * y2);
t:= t + Delta;
--- a/hedgewars/uTeams.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uTeams.pas Sat Mar 17 18:17:19 2007 +0000
@@ -104,13 +104,13 @@
begin // draw
AddCaption(trmsg[sidDraw], $FFFFFF, capgrpGameState);
SendStat(siGameResult, trmsg[sidDraw]);
- AddGear(0, 0, gtATFinishGame, 0, 0, 0, 2000)
+ AddGear(0, 0, gtATFinishGame, 0, _0, _0, 2000)
end else // win
begin
s:= Format(trmsg[sidWinner], AliveTeam^.TeamName);
AddCaption(s, $FFFFFF, capgrpGameState);
SendStat(siGameResult, s);
- AddGear(0, 0, gtATFinishGame, 0, 0, 0, 2000)
+ AddGear(0, 0, gtATFinishGame, 0, _0, _0, 2000)
end;
SendStats
end;
@@ -158,7 +158,7 @@
ResetKbd;
cWindSpeed:= rndSign(GetRandom * cMaxWindSpeed);
-g:= AddGear(0, 0, gtATSmoothWindCh, 0, 0, 0, 1);
+g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1);
g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
ApplyAmmoChanges(CurrentTeam^.Hedgehogs[CurrentTeam^.CurrHedgehog]);
@@ -297,7 +297,7 @@
end else TeamHealthBarWidth:= (TeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth
end;
// FIXME: at the game init, gtTeamHealthSorters are created for each team, and they work simultaneously
-AddGear(0, 0, gtTeamHealthSorter, 0, 0, 0, 0)
+AddGear(0, 0, gtTeamHealthSorter, 0, _0, _0, 0)
end;
procedure RestoreTeamsFromSave;
--- a/hedgewars/uWorld.pas Thu Mar 15 22:46:37 2007 +0000
+++ b/hedgewars/uWorld.pas Sat Mar 17 18:17:19 2007 +0000
@@ -403,7 +403,7 @@
exit
end
else begin
- CursorPoint.x:= (CursorPoint.x * 7 + (hwRound(FollowGear^.X + hwSign(FollowGear^.dX) * 100) + WorldDx)) div 8;
+ CursorPoint.x:= (CursorPoint.x * 7 + (hwRound(FollowGear^.X) + hwSign(FollowGear^.dX) * 100) + WorldDx) div 8;
CursorPoint.y:= (CursorPoint.y * 7 + (hwRound(FollowGear^.Y) + WorldDy)) div 8
end;