Changes for the benefit of pas2c. Use downto in for loops to avoid repeated calls of Random/GetRandom. Wrap nots.
--- a/hedgewars/GSHandlers.inc Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/GSHandlers.inc Wed Jul 25 10:56:14 2012 -0400
@@ -2406,7 +2406,7 @@
//DrawExplosion(gX, gY, 4);
if ((GameTicks and $7) = 0) and (Random(2) = 0) then
- for i:= 1 to Random(2)+1 do
+ for i:= Random(2) downto 0 do
AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke);
if Gear^.Health > 0 then
@@ -2420,7 +2420,7 @@
begin
DrawExplosion(gX, gY, 4);
- for i:= 0 to Random(3) do
+ for i:= Random(3) downto 0 do
AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke);
end;
@@ -2438,20 +2438,12 @@
if not sticky then
begin
if ((GameTicks and $3) = 0) and (Random(1) = 0) then
- begin
- for i:= 1 to Random(2)+1 do
- begin
+ for i:= Random(2) downto 0 do
AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke);
- end;
- end;
end
else
- begin
- for i:= 0 to Random(3) do
- begin
+ for i:= Random(3) downto 0 do
AddVisualGear(gX - 3 + Random(6), gY - 2, vgtSmoke);
- end;
- end;
DeleteGear(Gear)
end;
@@ -4398,7 +4390,7 @@
Gear^.State := Gear^.State and (not gstMoving);
if (Land[y, x] and lfBouncy <> 0)
- or not CalcSlopeTangent(Gear, x, y, tx, ty, 255)
+ or (not CalcSlopeTangent(Gear, x, y, tx, ty, 255))
or (DistanceI(tx,ty) < _12) then // reject shots at too irregular terrain
begin
loadNewPortalBall(Gear, true);
--- a/hedgewars/uAI.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uAI.pas Wed Jul 25 10:56:14 2012 -0400
@@ -415,7 +415,7 @@
end
end;
-PGear(Me)^.State:= PGear(Me)^.State and not gstHHThinking;
+PGear(Me)^.State:= PGear(Me)^.State and (not gstHHThinking);
Think:= 0;
InterlockedDecrement(hasThread)
end;
--- a/hedgewars/uAIMisc.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uAIMisc.pas Wed Jul 25 10:56:14 2012 -0400
@@ -645,7 +645,7 @@
Gear^.Y:= Gear^.Y + Gear^.dY;
if (not Gear^.dY.isNegative) and (TestCollisionYwithGear(Gear, 1) <> 0) then
begin
- Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping);
+ Gear^.State:= Gear^.State and (not (gstMoving or gstHHJumping));
Gear^.dY:= _0;
case JumpType of
jmpHJump:
@@ -709,7 +709,7 @@
if TestCollisionYwithGear(Gear, 1) <> 0 then
begin
inc(GoInfo.Ticks, 410);
- Gear^.State:= Gear^.State and not (gstMoving or gstHHJumping);
+ Gear^.State:= Gear^.State and (not (gstMoving or gstHHJumping));
Gear^.dY:= _0;
// try ljump instead of fall
HHJump(AltGear, jmpLJump, GoInfo);
--- a/hedgewars/uAmmos.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uAmmos.pas Wed Jul 25 10:56:14 2012 -0400
@@ -374,7 +374,7 @@
with CurWeapon^ do
begin
s:= trammo[Ammoz[AmmoType].NameId];
- if (Count <> AMMO_INFINITE) and not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0)) then
+ if (Count <> AMMO_INFINITE) and (not (Hedgehog.Team^.ExtDriven or (Hedgehog.BotLevel > 0))) then
s:= s + ' (' + IntToStr(Count) + ')';
if (Propz and ammoprop_Timerable) <> 0 then
s:= s + ', ' + IntToStr(Timer div 1000) + ' ' + trammo[sidSeconds];
@@ -386,7 +386,7 @@
end
else
begin
- if Gear <> nil then Gear^.State:= Gear^.State and not gstHHChooseTarget;
+ if Gear <> nil then Gear^.State:= Gear^.State and (not gstHHChooseTarget);
isCursorVisible:= false
end;
end
--- a/hedgewars/uCommandHandlers.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uCommandHandlers.pas Wed Jul 25 10:56:14 2012 -0400
@@ -766,7 +766,7 @@
procedure chGameFlags(var s: shortstring);
begin
GameFlags:= StrToInt(s);
-if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and not gfPerHogAmmo
+if GameFlags and gfSharedAmmo <> 0 then GameFlags:= GameFlags and (not gfPerHogAmmo)
end;
procedure chHedgehogTurnTime(var s: shortstring);
--- a/hedgewars/uCommands.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uCommands.pas Wed Jul 25 10:56:14 2012 -0400
@@ -95,7 +95,7 @@
begin
if TrustedSource or t^.Trusted then
begin
- if t^.Rand and not CheckNoTeamOrHH then
+ if t^.Rand and (not CheckNoTeamOrHH) then
CheckSum:= CheckSum xor LongWord(SDLNet_Read32(@CmdStr)) xor LongWord(s[0]) xor GameTicks;
t^.Handler(s);
end;
--- a/hedgewars/uGears.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uGears.pas Wed Jul 25 10:56:14 2012 -0400
@@ -211,7 +211,7 @@
RemoveGearFromList(curHandledGear);
// since I can't think of any good reason this would ever be separate from a remove from list, going to keep it inside this block
if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear);
- curHandledGear^.Message:= curHandledGear^.Message and not (gmRemoveFromList or gmAddToList)
+ curHandledGear^.Message:= curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList))
end;
if curHandledGear^.Active then
begin
@@ -634,8 +634,7 @@
if (GameFlags and gfArtillery) <> 0 then
cArtillery:= true;
-
-for i:= 0 to GetRandom(10)+30 do
+for i:= GetRandom(10)+30 downto 0 do
begin rx:= GetRandom(rightX-leftX)+leftX;
ry:= GetRandom(LAND_HEIGHT-topY)+topY;
rdx:= _90-(GetRandomf*_360);
--- a/hedgewars/uGearsHedgehog.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uGearsHedgehog.pas Wed Jul 25 10:56:14 2012 -0400
@@ -853,7 +853,7 @@
Gear^.State:= Gear^.State and (not gstMoving);
exit
end;
-isFalling:= (Gear^.dY.isNegative) or not TestCollisionYKick(Gear, 1);
+isFalling:= (Gear^.dY.isNegative) or (not TestCollisionYKick(Gear, 1));
if isFalling then
begin
if (Gear^.dY.isNegative) and TestCollisionYKick(Gear, -1) then
@@ -983,7 +983,7 @@
begin
Gear^.State:= Gear^.State and (not gstWinner);
Gear^.State:= Gear^.State and (not gstMoving);
- while (TestCollisionYWithGear(Gear,1) = 0) and not CheckGearDrowning(Gear) do
+ while (TestCollisionYWithGear(Gear,1) = 0) and (not CheckGearDrowning(Gear)) do
Gear^.Y:= Gear^.Y+_1;
SetLittle(Gear^.dX);
Gear^.dY:= _0
--- a/hedgewars/uIO.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uIO.pas Wed Jul 25 10:56:14 2012 -0400
@@ -402,7 +402,7 @@
TargetPoint.Y:= putY
end;
AddFileLog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));
- State:= State and not gstHHChooseTarget;
+ State:= State and (not gstHHChooseTarget);
if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
Message:= Message or (gmAttack and InputMask);
end
--- a/hedgewars/uInputHandler.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uInputHandler.pas Wed Jul 25 10:56:14 2012 -0400
@@ -25,8 +25,9 @@
procedure initModule;
procedure freeModule;
-function KeyNameToCode(name: shortstring; Modifier: shortstring = ''): LongInt;
-procedure MaskModifier(var code: LongInt; modifier: LongWord);
+function KeyNameToCode(name: shortstring): LongInt; inline;
+function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt;
+//procedure MaskModifier(var code: LongInt; modifier: LongWord);
procedure MaskModifier(Modifier: shortstring; var code: LongInt);
procedure ProcessMouse(event: TSDL_MouseButtonEvent; ButtonDown: boolean);
procedure ProcessKey(event: TSDL_KeyboardEvent); inline;
@@ -60,6 +61,11 @@
KeyNames: array [0..cKeyMaxIndex] of string[15];
CurrentBinds: TBinds;
+function KeyNameToCode(name: shortstring): LongInt; inline;
+begin
+ KeyNameToCode:= KeyNameToCode(name, '');
+end;
+
function KeyNameToCode(name: shortstring; Modifier: shortstring): LongInt;
var code: LongInt;
begin
@@ -70,7 +76,7 @@
MaskModifier(Modifier, code);
KeyNameToCode:= code;
end;
-
+(*
procedure MaskModifier(var code: LongInt; Modifier: LongWord);
begin
if(Modifier and KMOD_LSHIFT) <> 0 then code:= code or LSHIFT;
@@ -80,7 +86,7 @@
if(Modifier and KMOD_LCTRL) <> 0 then code:= code or LCTRL;
if(Modifier and KMOD_RCTRL) <> 0 then code:= code or LCTRL;
end;
-
+*)
procedure MaskModifier(Modifier: shortstring; var code: LongInt);
var mod_ : shortstring;
ModifierCount, i: LongInt;
@@ -133,7 +139,7 @@
if CurrentBinds[code][0] <> #0 then
begin
- if (code > 3) and KeyDown and not ((CurrentBinds[code] = 'put') or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true;
+ if (code > 3) and KeyDown and (not ((CurrentBinds[code] = 'put')) or (CurrentBinds[code] = 'ammomenu') or (CurrentBinds[code] = '+cur_u') or (CurrentBinds[code] = '+cur_d') or (CurrentBinds[code] = '+cur_l') or (CurrentBinds[code] = '+cur_r')) then hideAmmoMenu:= true;
if KeyDown then
begin
--- a/hedgewars/uScript.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uScript.pas Wed Jul 25 10:56:14 2012 -0400
@@ -981,7 +981,7 @@
begin
prevgear := CurrentHedgehog^.Gear;
prevgear^.Active := false;
- prevgear^.State:= prevgear^.State and not gstHHDriven;
+ prevgear^.State:= prevgear^.State and (not gstHHDriven);
prevgear^.Z := cHHZ;
prevgear^.Message:= prevgear^.Message or gmRemoveFromList or gmAddToList;
--- a/hedgewars/uTeams.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uTeams.pas Wed Jul 25 10:56:14 2012 -0400
@@ -473,7 +473,7 @@
begin
Gear^.Invulnerable:= false;
Gear^.Damage:= Gear^.Health;
- Gear^.State:= (Gear^.State or gstHHGone) and not gstHHDriven
+ Gear^.State:= (Gear^.State or gstHHGone) and (not gstHHDriven)
end
end
end;
--- a/hedgewars/uWorld.pas Tue Jul 24 18:53:42 2012 -0400
+++ b/hedgewars/uWorld.pas Wed Jul 25 10:56:14 2012 -0400
@@ -1329,7 +1329,7 @@
r.w:= 3;
DrawTextureFromRect(TeamHealthBarWidth + 16, cScreenHeight + DrawHealthY + smallScreenOffset, @r, HealthTex);
- if not highlight and not hasGone and (TeamHealth > 1) then
+ if not highlight and (not hasGone) and (TeamHealth > 1) then
for i:= 0 to cMaxHHIndex do
if Hedgehogs[i].Gear <> nil then
begin