Fix a few crosshair bugs. Disable ShowCrosshair and just decide when drawing.
authornemo
Sun, 10 Apr 2011 14:04:56 -0400
changeset 5136 948da1e50205
parent 5134 97827ad5c904
child 5137 b6140f35735f
Fix a few crosshair bugs. Disable ShowCrosshair and just decide when drawing.
hedgewars/HHHandlers.inc
hedgewars/uAmmos.pas
hedgewars/uGearsRender.pas
hedgewars/uVariables.pas
--- a/hedgewars/HHHandlers.inc	Sun Apr 10 20:02:25 2011 +0200
+++ b/hedgewars/HHHandlers.inc	Sun Apr 10 14:04:56 2011 -0400
@@ -90,14 +90,7 @@
         if i <= cMaxSlotAmmoIndex then ammoidx:= i
         else ammoidx:= -1
         end;
-        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
+        if ammoidx >= 0 then CurAmmoType:= Ammo^[slot, ammoidx].AmmoType;
     end
 end;
 
@@ -390,9 +383,6 @@
                 begin
                 if TagTurnTimeLeft = 0 then TagTurnTimeLeft:= TurnTimeLeft;
                 TurnTimeLeft:=(Ammoz[a].TimeAfterTurn * cGetAwayTime) div 100;
-                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:= false;
                 end;
             if ((Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) = 0) then State:= State or gstAttacked;
             if (Ammoz[a].Ammo.Propz and ammoprop_NoRoundEnd) <> 0 then ApplyAmmoChanges(CurrentHedgehog^)
--- a/hedgewars/uAmmos.pas	Sun Apr 10 20:02:25 2011 +0200
+++ b/hedgewars/uAmmos.pas	Sun Apr 10 14:04:56 2011 -0400
@@ -228,7 +228,6 @@
                 begin
                 PackAmmo(Ammo, Ammoz[AmmoType].Slot);
                 //SwitchNotHeldAmmo(Hedgehog);
-                ShowCrossHair:= false;
                 CurAmmoType:= amNothing
                 end
             end
@@ -295,10 +294,6 @@
         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;
 
--- a/hedgewars/uGearsRender.pas	Sun Apr 10 20:02:25 2011 +0200
+++ b/hedgewars/uGearsRender.pas	Sun Apr 10 14:04:56 2011 -0400
@@ -259,7 +259,11 @@
     if (Gear^.State and gstHHDriven) <> 0 then
         begin
         if ((Gear^.State and gstHHThinking) = 0) and
-        ShowCrosshair and
+/// If current ammo is active, and current ammo has alt attack and uses a crosshair  (rope, basically, right now, with no crosshair for parachute/saucer
+            (((CurAmmoGear <> nil) and ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_AltAttack) <> 0) and
+             ((Ammoz[CurAmmoGear^.AmmoType].Ammo.Propz and ammoprop_NoCrossHair) = 0)) or
+/// If no current ammo is active, and the selected ammo uses a crosshair
+             (CurAmmoGear = nil) and ((Ammoz[HH^.CurAmmoType].Ammo.Propz and ammoprop_NoCrosshair) = 0)) and
         ((Gear^.State and gstAnimation) = 0) then
             begin
     (* These calculations are a little complex for a few reasons:
--- a/hedgewars/uVariables.pas	Sun Apr 10 20:02:25 2011 +0200
+++ b/hedgewars/uVariables.pas	Sun Apr 10 14:04:56 2011 -0400
@@ -124,7 +124,7 @@
     bBetweenTurns   : boolean;
     bWaterRising    : boolean;
 
-    ShowCrosshair   : boolean;
+    //ShowCrosshair   : boolean;  This variable is inconvenient to set.  Easier to decide when rendering
     CursorMovementX : LongInt;
     CursorMovementY : LongInt;
     cDrownSpeed     : hwFloat;