Add reference to ammo at time of gear creation to allow switching to work on jetpack/parachute
authornemo
Sun, 04 Apr 2010 14:47:45 +0000
changeset 3302 0973c5af5141
parent 3301 df0c2a29c3d7
child 3303 397a8f048bb3
Add reference to ammo at time of gear creation to allow switching to work on jetpack/parachute
hedgewars/HHHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/HHHandlers.inc	Sun Apr 04 10:16:40 2010 +0000
+++ b/hedgewars/HHHandlers.inc	Sun Apr 04 14:47:45 2010 +0000
@@ -110,7 +110,7 @@
         ((State and (gstAttacked or gstHHChooseTarget)) = 0) and
         (((State and gstMoving) = 0) or
             // Allow attacks while moving on ammo with AltAttack
-            ((CurAmmoGear <> nil) and ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0)) or
+            ((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)) or
             ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_AttackInMove) <> 0)) and
         ((TargetPoint.X <> NoPointX) or ((Ammo^[CurSlot, CurAmmo].Propz and ammoprop_NeedTarget) = 0)) then
         begin
@@ -226,6 +226,7 @@
            and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) = 0){check for dropping ammo from rope} then
            begin
            CurAmmoGear^.Ammo:= @(Ammo^[CurSlot, CurAmmo]);
+           CurAmmoGear^.AmmoType:= CurAmmoGear^.Ammo^.AmmoType;
            Message:= Message or gm_Attack;
            CurAmmoGear^.Message:= Message
            end else begin
@@ -663,7 +664,7 @@
         Attack(Gear) // should be before others to avoid desync with '/put' msg and changing weapon msgs
     else
 else with PHedgehog(Gear^.Hedgehog)^ do
-     if ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0)
+     if ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0)
         and ((Gear^.Message and gm_LJump) <> 0)
         and (((Ammo^[CurSlot, CurAmmo].Propz) and ammoprop_AltUse) <> 0) then
         begin
@@ -672,7 +673,7 @@
         end;
 
 if (CurAmmoGear = nil)
-    or ((CurAmmoGear^.Ammo^.Propz and ammoprop_AltAttack) <> 0) then
+    or ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
     begin
     if ((Gear^.Message and gm_Slot) <> 0) then
         begin
--- a/hedgewars/uGears.pas	Sun Apr 04 10:16:40 2010 +0000
+++ b/hedgewars/uGears.pas	Sun Apr 04 14:47:45 2010 +0000
@@ -33,6 +33,7 @@
             Invulnerable: Boolean;
             RenderTimer: Boolean;
             Ammo : PAmmo;
+            AmmoType : TAmmoType;  // Used to track AmmoType at time of Gear creation, since Ammo can be reassigned
             State : Longword;
             X : hwFloat;
             Y : hwFloat;