hedgewars/uGearsRender.pas
changeset 14579 42f3d6860971
parent 14572 34e810295d08
child 14598 62dea281e4d5
--- 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