Remove Timer2 from Gear, add a Timer to Hedgehog
authornemo
Sun, 21 Mar 2010 13:41:11 +0000
changeset 3030 411146650700
parent 3029 67483e87590c
child 3031 542444bfe37d
Remove Timer2 from Gear, add a Timer to Hedgehog
hedgewars/uAmmos.pas
hedgewars/uGears.pas
hedgewars/uTeams.pas
--- a/hedgewars/uAmmos.pas	Sun Mar 21 03:51:58 2010 +0000
+++ b/hedgewars/uAmmos.pas	Sun Mar 21 13:41:11 2010 +0000
@@ -287,7 +287,7 @@
 
 with Hedgehog do
     begin
-    Gear^.Timer2:= 10;
+    Timer:= 10;
 
     if (Ammo^[CurSlot, CurAmmo].Count = 0) then
         SwitchToFirstLegalAmmo(Hedgehog);
--- a/hedgewars/uGears.pas	Sun Mar 21 03:51:58 2010 +0000
+++ b/hedgewars/uGears.pas	Sun Mar 21 13:41:11 2010 +0000
@@ -44,7 +44,7 @@
             Radius: LongInt;
             Angle, Power : Longword;
             DirAngle: real;
-            Timer, Timer2 : LongWord;
+            Timer : LongWord;
             Elasticity: hwFloat;
             Friction  : hwFloat;
             Message, MsgParam : Longword;
@@ -879,9 +879,10 @@
     lx, ly, dx, dy, ax, ay, aAngle, dAngle, hAngle: real;  // laser, change
     defaultPos, HatVisible: boolean;
     VertexBuffer: array [0..1] of TVertex2f;
+    HH: PHedgehog;
 begin
-
-if PHedgehog(Gear^.Hedgehog)^.Unplaced then exit;
+HH:= PHedgehog(Gear^.Hedgehog);
+if HH^.Unplaced then exit;
 m:= 1;
 if ((Gear^.State and gstHHHJump) <> 0) and not cArtillery then m:= -1;
 if (Gear^.State and gstHHDeath) <> 0 then
@@ -992,7 +993,7 @@
         // draw crosshair
         cx:= Round(hwRound(Gear^.X) + dx * 80);
         cy:= Round(hwRound(Gear^.Y) + dy * 80);
-        DrawRotatedTex(PHedgehog(Gear^.Hedgehog)^.Team^.CrosshairTex,
+        DrawRotatedTex(HH^.Team^.CrosshairTex,
                 12, 12, cx + WorldDx, cy + WorldDy, 0,
                 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle);
         end;
@@ -1042,7 +1043,7 @@
                            1,
                            0,
                            DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
-                   with PHedgehog(Gear^.Hedgehog)^ do
+                   with HH^ do
                        if (HatTex <> nil) then
                            DrawRotatedTextureF(HatTex, 1.0, -1.0, -6.0, sx, sy, 0, i, 32, 32,
                                i*DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + hAngle);
@@ -1055,9 +1056,9 @@
                 DrawHedgehog(sx, sy,
                         hwSign(Gear^.dX),
                         3,
-                        PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
+                        HH^.visStepPos div 2,
                         0);
-                with PHedgehog(Gear^.Hedgehog)^ do
+                with HH^ do
                     if (HatTex <> nil) then
                        DrawTextureF(HatTex,
                            1,
@@ -1161,7 +1162,7 @@
         DrawHedgehog(sx, sy,
             hwSign(Gear^.dX),
             0,
-            PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
+            HH^.visStepPos div 2,
             0);
         defaultPos:= false;
         HatVisible:= true
@@ -1181,13 +1182,13 @@
     else
     if ((Gear^.State and gstAttacked) = 0) then
         begin
-        if Gear^.Timer2 > 0 then
+        if HH^.Timer > 0 then
             begin
             // There must be a tidier way to do this. Anyone?
             if aangle <= 90 then aangle:= aangle+360;
-            if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*Gear^.Timer2/10)
-            else aangle:= aangle+((240-aangle)*Gear^.Timer2/10);
-            dec(Gear^.Timer2)
+            if Gear^.dX > _0 then aangle:= aangle-((aangle-240)*HH^.Timer/10)
+            else aangle:= aangle+((240-aangle)*HH^.Timer/10);
+            dec(HH^.Timer)
             end;
         amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
         case amt of
@@ -1255,7 +1256,7 @@
                 0);
 
             HatVisible:= true;
-            with PHedgehog(Gear^.Hedgehog)^ do
+            with HH^ do
                 if (HatTex <> nil)
                 and (HatVisibility > 0) then
                     DrawTextureF(HatTex,
@@ -1301,7 +1302,7 @@
         end;
     end;
 
-with PHedgehog(Gear^.Hedgehog)^ do
+with HH^ do
     begin
     if defaultPos then
         begin
@@ -1367,7 +1368,7 @@
         end
     end;
 
-with PHedgehog(Gear^.Hedgehog)^ do
+with HH^ do
     begin
     if ((Gear^.State and not gstWinner) = 0)
         or (bShowFinger and ((Gear^.State and gstHHDriven) <> 0)) then
--- a/hedgewars/uTeams.pas	Sun Mar 21 03:51:58 2010 +0000
+++ b/hedgewars/uTeams.pas	Sun Mar 21 13:41:11 2010 +0000
@@ -54,6 +54,7 @@
             Hat: shortstring;
             King: boolean;  // Flag for a bunch of hedgehog attributes
             Unplaced: boolean;  // Flag for hog placing mode
+            Timer: Longword;
             end;
 
     TTeam = record