Adjust conditions for showing crosshair
authornemo
Sun, 20 Mar 2011 12:52:36 -0400
changeset 5031 e26f430be1ed
parent 5028 3c43f00b0743
child 5033 46da78d7966b
Adjust conditions for showing crosshair
hedgewars/HHHandlers.inc
hedgewars/uAmmos.pas
hedgewars/uGearsRender.pas
--- a/hedgewars/HHHandlers.inc	Sun Mar 20 08:42:32 2011 +0000
+++ b/hedgewars/HHHandlers.inc	Sun Mar 20 12:52:36 2011 -0400
@@ -90,7 +90,14 @@
         if i <= cMaxSlotAmmoIndex then ammoidx:= i
         else ammoidx:= -1
         end;
-        if ammoidx >= 0 then CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
+        if ammoidx >= 0 then 
+            begin
+            CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
+            if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+                ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
+            else
+                ShowCrosshair:= (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0;
+            end
     end
 end;
 
@@ -385,6 +392,10 @@
                 TurnTimeLeft:=round(Ammoz[a].TimeAfterTurn * (cGetAwayTime / 100));
                 end;
             if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) then State:= State or gstAttacked;
+            if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+                ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
+            else
+                ShowCrosshair:= (Ammoz[a].Ammo.Propz and ammoprop_NoCrosshair) = 0;
             if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then ApplyAmmoChanges(CurrentHedgehog^)
             end;
         end
--- a/hedgewars/uAmmos.pas	Sun Mar 20 08:42:32 2011 +0000
+++ b/hedgewars/uAmmos.pas	Sun Mar 20 12:52:36 2011 -0400
@@ -295,6 +295,10 @@
         end;
     TryDo(slot <= cMaxSlotIndex, 'Ammo slot index overflow', true);
     CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
+    if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
+        ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
+    else
+        ShowCrosshair:= (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0;
     end
 end;
 
@@ -333,10 +337,6 @@
             Gear^.State:= Gear^.State and not gstHHChooseTarget;
             isCursorVisible:= false
             end;
-        if (CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) then
-            ShowCrosshair:= (Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0
-        else
-            ShowCrosshair:= (Propz and ammoprop_NoCrosshair) = 0;
         end
     end;
 end;
--- a/hedgewars/uGearsRender.pas	Sun Mar 20 08:42:32 2011 +0000
+++ b/hedgewars/uGearsRender.pas	Sun Mar 20 12:52:36 2011 -0400
@@ -259,8 +259,8 @@
     if (Gear^.State and gstHHDriven) <> 0 then
         begin
         if ((Gear^.State and gstHHThinking) = 0) and
-        (ShowCrosshair  or ((CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtRope))) and
-        ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then
+        ShowCrosshair and
+        ((Gear^.State and gstAnimation) = 0) then
             begin
     (* These calculations are a little complex for a few reasons:
     1: I need to draw the laser from weapon origin to nearest land