# HG changeset patch
# User Wuzzy <almikes@aol.com>
# Date 1492895207 -7200
# Node ID cdd88439776028cbf5ea900c9186ee82a9c2a427
# Parent  d3a52e51efd42781b2bd538a60193146818cf13e
Fix sniper rifle disabling laser sight utility after shooting

diff -r d3a52e51efd4 -r cdd884397760 ChangeLog.txt
--- a/ChangeLog.txt	Sat Apr 22 22:23:49 2017 +0200
+++ b/ChangeLog.txt	Sat Apr 22 23:06:47 2017 +0200
@@ -30,6 +30,7 @@
  * Video recording functionality is restored
  * Fixed bee not being affected by wrap world edge while still being thrown
  * Fixed turn not ending when sticky mine was trapped on rubberband
+ * Fixed sniper rifle disabling laser sight utility after using
  * Fixed hedgehog-voices missing a response type (Justyouwait/"You're gonna pay for that") on some platforms (e.g. Linux)
  * Fixed SD-flakes of themes not working if regular flakes were disabled
  * Fixed RC planes being able to collect frozen crates
diff -r d3a52e51efd4 -r cdd884397760 hedgewars/uGears.pas
--- a/hedgewars/uGears.pas	Sat Apr 22 22:23:49 2017 +0200
+++ b/hedgewars/uGears.pas	Sat Apr 22 23:06:47 2017 +0200
@@ -522,7 +522,10 @@
     cDamageModifier:= _1;
 
     if (GameFlags and gfLaserSight) = 0 then
+        begin
         cLaserSighting:= false;
+        cLaserSightingSniper:= false
+        end;
 
     if (GameFlags and gfArtillery) = 0 then
         cArtillery:= false;
diff -r d3a52e51efd4 -r cdd884397760 hedgewars/uGearsHandlersMess.pas
--- a/hedgewars/uGearsHandlersMess.pas	Sat Apr 22 22:23:49 2017 +0200
+++ b/hedgewars/uGearsHandlersMess.pas	Sat Apr 22 23:06:47 2017 +0200
@@ -1316,8 +1316,8 @@
         or (hwRound(Gear^.X) and LAND_WIDTH_MASK <> 0)
         or (hwRound(Gear^.Y) and LAND_HEIGHT_MASK <> 0) then
             begin
-            if (Gear^.Kind = gtSniperRifleShot) and ((GameFlags and gfLaserSight) = 0) then
-                cLaserSighting := false;
+            if (Gear^.Kind = gtSniperRifleShot) then
+                cLaserSightingSniper := false;
             if (Ammoz[Gear^.AmmoType].Ammo.NumPerTurn <= CurrentHedgehog^.MultiShootAttacks) and ((GameFlags and gfArtillery) = 0) then
                 cArtillery := false;
 
@@ -1370,10 +1370,10 @@
 
     HHGear^.State := HHGear^.State or gstNotKickable;
     HedgehogChAngle(HHGear);
-    if not cLaserSighting then
-        // game does not have default laser sight. turn it on and give them a chance to aim
-        begin
-        cLaserSighting := true;
+    if cLaserSightingSniper = false then
+        // Turn sniper's laser sight on and give it a chance to aim
+        begin
+        cLaserSightingSniper := true;
         HHGear^.Message := 0;
         if (HHGear^.Angle >= 32) then
             dec(HHGear^.Angle,32)
diff -r d3a52e51efd4 -r cdd884397760 hedgewars/uGearsRender.pas
--- a/hedgewars/uGearsRender.pas	Sat Apr 22 22:23:49 2017 +0200
+++ b/hedgewars/uGearsRender.pas	Sat Apr 22 23:06:47 2017 +0200
@@ -383,7 +383,7 @@
     *)
             dx:= sign * m * Sin(Gear^.Angle * pi / cMaxAngle);
             dy:= -Cos(Gear^.Angle * pi / cMaxAngle);
-            if cLaserSighting then
+            if cLaserSighting or cLaserSightingSniper then
                 begin
                 lx:= GetLaunchX(HH^.CurAmmoType, sign * m, Gear^.Angle);
                 ly:= GetLaunchY(HH^.CurAmmoType, Gear^.Angle);
diff -r d3a52e51efd4 -r cdd884397760 hedgewars/uVariables.pas
--- a/hedgewars/uVariables.pas	Sat Apr 22 22:23:49 2017 +0200
+++ b/hedgewars/uVariables.pas	Sat Apr 22 23:06:47 2017 +0200
@@ -186,6 +186,7 @@
     cBuildMaxDist   : LongInt;
     cDamageModifier : hwFloat;
     cLaserSighting  : boolean;
+    cLaserSightingSniper : boolean;
     cVampiric       : boolean;
     cArtillery      : boolean;
     WeaponTooltipTex: PTexture;
@@ -2762,6 +2763,7 @@
     ZoomValue       := cDefaultZoomLevel;
     WeaponTooltipTex:= nil;
     cLaserSighting  := false;
+    cLaserSightingSniper := false;
     cVampiric       := false;
     cArtillery      := false;
     flagMakeCapture := false;