Fix crosshair sometimes not getting removed
authorWuzzy <Wuzzy2@mail.ru>
Mon, 14 Jan 2019 16:18:34 +0100
changeset 14584 42f3d6860971
parent 14583 50f511588635
child 14585 1a68c8a07d1f
Fix crosshair sometimes not getting removed
hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsRender.pas	Mon Jan 14 07:14:18 2019 +0100
+++ b/hedgewars/uGearsRender.pas	Mon Jan 14 16:18:34 2019 +0100
@@ -273,7 +273,7 @@
         exit;
 
     // render crosshair
-    if (Gear = CrosshairGear) then
+    if (CrosshairGear <> nil) and (Gear = CrosshairGear) then
         begin
         sign:= hwSign(Gear^.dX);
         m:= 1;
@@ -328,6 +328,7 @@
     curhat: PTexture;
 begin
     HH:= Gear^.Hedgehog;
+    CrosshairGear:= nil;
     if HH^.Unplaced then
         exit;
     if (HH^.CurAmmoType = amKnife) and (HH = CurrentHedgehog) then
@@ -510,6 +511,7 @@
 
                 DrawLineWrapped(hx, hy, tx, ty, 1.0, (sign*m) < 0, wraps, $FF, $00, $00, $C0);
                 end;
+
             // calculate crosshair position
             CrosshairX := Round(hwRound(Gear^.X) + dx * 80 + GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle));
             CrosshairY := Round(hwRound(Gear^.Y) + dy * 80 + GetLaunchY(HH^.CurAmmoType, Gear^.Angle));
@@ -916,7 +918,6 @@
 
     end else // not gstHHDriven
         begin
-        CrosshairGear:= nil;
         // check if hedgehog is sliding/rolling
         if (Gear^.Damage > 0) and (HH^.Effects[heFrozen] = 0)
         and (hwSqr(Gear^.dX) + hwSqr(Gear^.dY) > _0_003) then