Refactor: lfCurrentHog→lfCurHogCrate, lfNotCurrentMask→lfNotCurHogCrate
authorWuzzy <Wuzzy2@mail.ru>
Tue, 10 Jul 2018 18:00:04 +0200
changeset 13463 f1d349a52bc7
parent 13462 4c47a480009b
child 13464 7b4643ff60ea
Refactor: lfCurrentHog→lfCurHogCrate, lfNotCurrentMask→lfNotCurHogCrate
ChangeLog.txt
hedgewars/uAIAmmoTests.pas
hedgewars/uAIMisc.pas
hedgewars/uCollisions.pas
hedgewars/uConsts.pas
hedgewars/uGearsHandlersMess.pas
hedgewars/uGearsHandlersRope.pas
hedgewars/uGearsHedgehog.pas
hedgewars/uGearsList.pas
hedgewars/uLandGraphics.pas
hedgewars/uScript.pas
--- a/ChangeLog.txt	Tue Jul 10 17:11:31 2018 +0200
+++ b/ChangeLog.txt	Tue Jul 10 18:00:04 2018 +0200
@@ -41,6 +41,7 @@
  + New call: GetAmmo(ammoType): Returns ammo configuration (corresponds to SetAmmo)
  + New parameter: SetAmmoTexts: 5th param. showExtra: Set to false to hide texts like “Not yet available”
  + New parameter: ShowMission: 6th param. forceDisplay: Set to true to prevent this particular mission panel to be hidden manually by player
+ * Changed global: lfCurrentHog becomes lfCurHogCrate
  * Fixed variable: TotalRounds was -1 (instead of 0) in first real round after hog placement phase
 
 ====================== 0.9.24.1 ====================
--- a/hedgewars/uAIAmmoTests.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uAIAmmoTests.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -1309,7 +1309,7 @@
 
     //FillChar(cake, sizeof(cake), 0);
     cake.Radius:= 7;
-    cake.CollisionMask:= lfNotCurrentMask;
+    cake.CollisionMask:= lfNotCurHogCrate;
     cake.Hedgehog:= Me^.Hedgehog;
 
     // check left direction
--- a/hedgewars/uAIMisc.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uAIMisc.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -372,10 +372,10 @@
     if not CheckBounds(x, y, r) then
         exit(false);
 
-    if (Land[y-r, x-r] and lfNotCurrentMask <> 0) or
-       (Land[y+r, x-r] and lfNotCurrentMask <> 0) or
-       (Land[y+r, x-r] and lfNotCurrentMask <> 0) or
-       (Land[y+r, x+r] and lfNotCurrentMask <> 0) then
+    if (Land[y-r, x-r] and lfNotCurHogCrate <> 0) or
+       (Land[y+r, x-r] and lfNotCurHogCrate <> 0) or
+       (Land[y+r, x-r] and lfNotCurHogCrate <> 0) or
+       (Land[y+r, x+r] and lfNotCurHogCrate <> 0) then
        exit(true);
 
     TestColl:= false;
@@ -927,7 +927,7 @@
 var pX, pY, tY: LongInt;
 begin
 HHGo:= false;
-Gear^.CollisionMask:= lfNotCurrentMask;
+Gear^.CollisionMask:= lfNotCurHogCrate;
 AltGear^:= Gear^;
 
 GoInfo.Ticks:= 0;
--- a/hedgewars/uCollisions.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uCollisions.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -341,7 +341,7 @@
 var x, y, i: LongInt;
 begin
 // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
-if (Gear^.CollisionMask = lfNotCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
+if (Gear^.CollisionMask = lfNotCurHogCrate) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
     ((hwRound(Gear^.Hedgehog^.Gear^.X) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.X) - Gear^.Radius) or
      (hwRound(Gear^.Hedgehog^.Gear^.X) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.X) + Gear^.Radius)) then
     Gear^.CollisionMask:= $FFFF;
@@ -370,7 +370,7 @@
 var x, y, i: LongInt;
 begin
 // Special case to emulate the old intersect gear clearing, but with a bit of slop for pixel overlap
-if (Gear^.CollisionMask = lfNotCurrentMask) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
+if (Gear^.CollisionMask = lfNotCurHogCrate) and (Gear^.Kind <> gtHedgehog) and (Gear^.Hedgehog <> nil) and (Gear^.Hedgehog^.Gear <> nil) and
     ((hwRound(Gear^.Hedgehog^.Gear^.Y) + Gear^.Hedgehog^.Gear^.Radius + 16 < hwRound(Gear^.Y) - Gear^.Radius) or
      (hwRound(Gear^.Hedgehog^.Gear^.Y) - Gear^.Hedgehog^.Gear^.Radius - 16 > hwRound(Gear^.Y) + Gear^.Radius)) then
     Gear^.CollisionMask:= $FFFF;
--- a/hedgewars/uConsts.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uConsts.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -120,8 +120,8 @@
     lfBouncy         = $0400;  // green
     lfLandMask       = $FF00;  // upper byte is used for terrain, not objects.
 
-    lfCurrentHog     = $0080;  // CurrentHog.  It is also used to flag crates, for convenience of AI.  Since an active hog would instantly collect the crate, this does not impact play
-    lfNotCurrentMask = $FF7F;  // inverse of above. frequently used
+    lfCurHogCrate    = $0080;  // CurrentHedgehog, and crates, for convenience of AI.  Since an active hog would instantly collect the crate, this does not impact playj
+    lfNotCurHogCrate = $FF7F;  // inverse of above. frequently used
     lfObjMask        = $007F;  // lower 7 bits used for hogs and explosives and mines 
     lfNotObjMask     = $FF80;  // inverse of above.
 
@@ -136,7 +136,7 @@
 
     // lower byte is for objects.
     // consists of 0-127 counted for object checkins and $80 as a bit flag for current hog.
-    lfAllObjMask     = $00FF;  // lfCurrentHog or lfObjMask
+    lfAllObjMask     = $00FF;  // lfCurHogCrate or lfObjMask
 
 
 
--- a/hedgewars/uGearsHandlersMess.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -3635,7 +3635,7 @@
 begin
     AllInactive := false;
 
-    Gear^.CollisionMask:= lfNotCurrentMask;
+    Gear^.CollisionMask:= lfNotCurHogCrate;
 
     Gear^.dY:= cMaxWindSpeed * 100;
 
@@ -3956,7 +3956,7 @@
         ry := rndSign(getRandomf * _0_1);
 
         ball:= AddGear(gx, gy, gtBall, 0, SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - _0_8) + ry, 0);
-        ball^.CollisionMask:= lfNotCurrentMask;
+        ball^.CollisionMask:= lfNotCurHogCrate;
 
         PlaySound(sndGun);
         end;
@@ -5442,7 +5442,7 @@
             flame:= AddGear(gx, gy, gtFlame, gstTmpFlag,
                     SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
                     AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
-            flame^.CollisionMask:= lfNotCurrentMask;
+            flame^.CollisionMask:= lfNotCurHogCrate;
             //flame^.FlightTime:= 500;  use the default huge value to avoid sticky flame suddenly being damaging as opposed to other flames
 
             if (Gear^.Health mod 30) = 0 then
@@ -5450,7 +5450,7 @@
                 flame:= AddGear(gx, gy, gtFlame, 0,
                         SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
                         AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
-                flame^.CollisionMask:= lfNotCurrentMask;
+                flame^.CollisionMask:= lfNotCurHogCrate;
 		//flame^.FlightTime:= 500;
                 end
             end;
@@ -5534,7 +5534,7 @@
         land:= AddGear(gx, gy, gtFlake, gstTmpFlag,
                 SignAs(AngleSin(HHGear^.Angle) * speed, HHGear^.dX) + rx,
                 AngleCos(HHGear^.Angle) * ( - speed) + ry, 0);
-        land^.CollisionMask:= lfNotCurrentMask;
+        land^.CollisionMask:= lfNotCurHogCrate;
 
         Gear^.Timer:= Gear^.Tag
         end;
@@ -6851,7 +6851,7 @@
         ry := rndSign(getRandomf * _0_2);
 
         bullet:= AddGear(gx, gy, gtMinigunBullet, 0, SignAs(AngleSin(HHGear^.Angle) * _0_8, HHGear^.dX) + rx, AngleCos(HHGear^.Angle) * ( - _0_8) + ry, 0);
-        bullet^.CollisionMask:= lfNotCurrentMask;
+        bullet^.CollisionMask:= lfNotCurHogCrate;
         bullet^.WDTimer := Gear^.WDTimer;
         Inc(Gear^.WDTimer);
 
--- a/hedgewars/uGearsHandlersRope.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uGearsHandlersRope.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -497,7 +497,7 @@
         end;
 
     if Gear^.Elasticity < _20 then Gear^.CollisionMask:= lfLandMask
-    else Gear^.CollisionMask:= lfNotCurrentMask; //lfNotObjMask or lfNotHHObjMask;
+    else Gear^.CollisionMask:= lfNotCurHogCrate; //lfNotObjMask or lfNotHHObjMask;
     CheckCollision(Gear);
 
     if (Gear^.State and gstCollision) <> 0 then
--- a/hedgewars/uGearsHedgehog.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uGearsHedgehog.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -493,7 +493,7 @@
                 newGear^.Target.X:= TargetPoint.X;
                 newGear^.Target.Y:= TargetPoint.Y
                 end;
-            if (newGear <> nil) and (newGear^.CollisionMask and lfCurrentHog <> 0) then newGear^.CollisionMask:= newGear^.CollisionMask and (not lfCurrentHog);
+            if (newGear <> nil) and (newGear^.CollisionMask and lfCurHogCrate <> 0) then newGear^.CollisionMask:= newGear^.CollisionMask and (not lfCurHogCrate);
 
             // Clear FollowGear if using on a rope/parachute/saucer etc so focus stays with the hog's movement
             if altUse then
--- a/hedgewars/uGearsList.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uGearsList.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -212,7 +212,7 @@
     begin
     gear^.Hedgehog:= CurrentHedgehog;
     if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then
-        gear^.CollisionMask:= lfNotCurrentMask
+        gear^.CollisionMask:= lfNotCurHogCrate
     end;
 
 if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
@@ -414,7 +414,7 @@
                 RopePoints.Count:= 0;
                 gear^.Tint:= $D8D8D8FF;
                 gear^.Tag:= 0; // normal rope render
-                gear^.CollisionMask:= lfNotCurrentMask //lfNotObjMask or lfNotHHObjMask;
+                gear^.CollisionMask:= lfNotCurHogCrate //lfNotObjMask or lfNotHHObjMask;
                 end;
         gtMine: begin
                 gear^.ImpactSound:= sndMineImpact;
--- a/hedgewars/uLandGraphics.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uLandGraphics.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -236,12 +236,12 @@
     setCurrentHog:
         for i:= fromPix to toPix do
             begin
-            Land[y, i]:= Land[y, i] or lfCurrentHog
+            Land[y, i]:= Land[y, i] or lfCurHogCrate
             end;
     removeCurrentHog:
         for i:= fromPix to toPix do
             begin
-            Land[y, i]:= Land[y, i] and lfNotCurrentMask;
+            Land[y, i]:= Land[y, i] and lfNotCurHogCrate;
             end;
     end;
 end;
--- a/hedgewars/uScript.pas	Tue Jul 10 17:11:31 2018 +0200
+++ b/hedgewars/uScript.pas	Tue Jul 10 18:00:04 2018 +0200
@@ -3926,7 +3926,7 @@
 ScriptSetInteger('lfBouncy'        , lfBouncy);
 
 ScriptSetInteger('lfLandMask'      , lfLandMask);
-ScriptSetInteger('lfCurrentHog'    , lfCurrentHog);
+ScriptSetInteger('lfCurHogCrate'   , lfCurHogCrate);
 ScriptSetInteger('lfHHMask'        , lfHHMask);
 ScriptSetInteger('lfNotHHObjMask'  , lfNotHHObjMask);
 ScriptSetInteger('lfAllObjMask'    , lfAllObjMask);