From dbb59c8fd106c10153f5847f6d90a5576615887b Mon Sep 17 00:00:00 2001
From: ulteq <ulteq@web.de>
Date: Wed, 16 Nov 2016 12:55:43 +0100
Subject: [PATCH] New 'overwriteZeroRange' setting

---
 addons/scopes/ACE_Settings.hpp                      | 7 +++++++
 addons/scopes/CfgVehicles.hpp                       | 6 ++++++
 addons/scopes/functions/fnc_getCurrentZeroRange.sqf | 2 +-
 addons/scopes/functions/fnc_initModuleSettings.sqf  | 1 +
 addons/scopes/stringtable.xml                       | 6 ++++++
 5 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/addons/scopes/ACE_Settings.hpp b/addons/scopes/ACE_Settings.hpp
index 29d6635cf2..6ff483cb50 100644
--- a/addons/scopes/ACE_Settings.hpp
+++ b/addons/scopes/ACE_Settings.hpp
@@ -20,6 +20,13 @@ class ACE_Settings {
         displayName = CSTRING(correctZeroing_displayName);
         description = CSTRING(correctZeroing_description);
     };
+    // Enables the use of the 'defaultZeroRange' setting to overwrite the discreteDistance[] config
+    class GVAR(overwriteZeroRange) {
+        typeName = "BOOL";
+        value = 0;
+        displayName = CSTRING(overwriteZeroRange_displayName);
+        description = CSTRING(overwriteZeroRange_description);
+    };
     // Only affects scopes with elevation adjustment turrets (ACE_ScopeAdjust_Vertical != [0,0])
     class GVAR(defaultZeroRange) {
         typeName = "SCALAR";
diff --git a/addons/scopes/CfgVehicles.hpp b/addons/scopes/CfgVehicles.hpp
index 4a23ea0baf..fd2a7d01c6 100644
--- a/addons/scopes/CfgVehicles.hpp
+++ b/addons/scopes/CfgVehicles.hpp
@@ -46,6 +46,12 @@ class CfgVehicles {
                 typeName = "BOOL";
                 defaultValue = 1;
             };
+            class overwriteZeroRange {
+                displayName = CSTRING(overwriteZeroRange_DisplayName);
+                description = CSTRING(overwriteZeroRange_Description);
+                typeName = "BOOL";
+                defaultValue = 0;
+            };
             class defaultZeroRange {
                 displayName = CSTRING(defaultZeroRange_DisplayName);
                 description = CSTRING(defaultZeroRange_Description);
diff --git a/addons/scopes/functions/fnc_getCurrentZeroRange.sqf b/addons/scopes/functions/fnc_getCurrentZeroRange.sqf
index 0f7fe746eb..a82bd0714e 100644
--- a/addons/scopes/functions/fnc_getCurrentZeroRange.sqf
+++ b/addons/scopes/functions/fnc_getCurrentZeroRange.sqf
@@ -30,7 +30,7 @@ private _opticConfig = if (_optic != "") then {
 };
 
 private _zeroRange = currentZeroing _unit;
-if (GVAR(canAdjustElevation) select _weaponIndex) then {
+if (GVAR(overwriteZeroRange) && {GVAR(canAdjustElevation) select _weaponIndex}) then {
     _zeroRange = GVAR(defaultZeroRange);
 };
 if (isNumber (_opticConfig >> "ACE_ScopeZeroRange")) then {
diff --git a/addons/scopes/functions/fnc_initModuleSettings.sqf b/addons/scopes/functions/fnc_initModuleSettings.sqf
index 91ab202db3..a04433f11e 100644
--- a/addons/scopes/functions/fnc_initModuleSettings.sqf
+++ b/addons/scopes/functions/fnc_initModuleSettings.sqf
@@ -21,6 +21,7 @@ if !(_activated) exitWith {};
 [_logic, QGVAR(enabled), "enabled"] call EFUNC(common,readSettingFromModule);
 [_logic, QGVAR(forceUseOfAdjustmentTurrets), "forceUseOfAdjustmentTurrets"] call EFUNC(common,readSettingFromModule);
 [_logic, QGVAR(correctZeroing), "correctZeroing"] call EFUNC(common,readSettingFromModule);
+[_logic, QGVAR(overwriteZeroRange), "overwriteZeroRange"] call EFUNC(common,readSettingFromModule);
 [_logic, QGVAR(defaultZeroRange), "defaultZeroRange"] call EFUNC(common,readSettingFromModule);
 [_logic, QGVAR(zeroReferenceTemperature), "zeroReferenceTemperature"] call EFUNC(common,readSettingFromModule);
 [_logic, QGVAR(zeroReferenceBarometricPressure), "zeroReferenceBarometricPressure"] call EFUNC(common,readSettingFromModule);
diff --git a/addons/scopes/stringtable.xml b/addons/scopes/stringtable.xml
index f74325ab62..bffaeb0301 100644
--- a/addons/scopes/stringtable.xml
+++ b/addons/scopes/stringtable.xml
@@ -22,6 +22,12 @@
         <Key ID="STR_ACE_Scopes_correctZeroing_description">
             <English>Corrects the zeroing of all small arms sights</English>
         </Key>
+        <Key ID="STR_ACE_Scopes_overwriteZeroRange_displayName">
+            <English>Overwrite zero distance</English>
+        </Key>
+        <Key ID="STR_ACE_Scopes_overwriteZeroRange_Description">
+            <English>Uses the 'defaultZeroRange' setting to overwrite the zero range of high power scopes</English>
+        </Key>
         <Key ID="STR_ACE_Scopes_defaultZeroRange_displayName">
             <English>Default zero distance</English>
         </Key>