From 34849426805cdfa81180a53480c15e11cdea1ed2 Mon Sep 17 00:00:00 2001
From: ulteq <ulteq@users.noreply.github.com>
Date: Sun, 22 Oct 2017 10:44:00 +0200
Subject: [PATCH] Scopes - Fixed MRAD conversion (#5651)

* Same issue as https://github.com/acemod/ACE3/pull/5640
---
 addons/scopes/functions/fnc_applyScopeAdjustment.sqf | 2 +-
 addons/scopes/functions/fnc_firedEH.sqf              | 2 +-
 addons/scopes/script_component.hpp                   | 2 ++
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/addons/scopes/functions/fnc_applyScopeAdjustment.sqf b/addons/scopes/functions/fnc_applyScopeAdjustment.sqf
index 47ee4c570c..37f83384a6 100644
--- a/addons/scopes/functions/fnc_applyScopeAdjustment.sqf
+++ b/addons/scopes/functions/fnc_applyScopeAdjustment.sqf
@@ -34,7 +34,7 @@ playSound selectRandom ["ACE_Scopes_Click_1", "ACE_Scopes_Click_2", "ACE_Scopes_
 // slightly rotate the player if looking through optic
 if (cameraView == "GUNNER") then {
     // Convert adjustmentDifference from mils to degrees
-    _adjustmentDifference = _adjustmentDifference apply {_x * 0.05625};
+    _adjustmentDifference = _adjustmentDifference apply {MRAD_TO_DEG(_x)};
     _adjustmentDifference params ["_elevationDifference", "_windageDifference"];
     private _pitchBankYaw = [_unit] call EFUNC(common,getPitchBankYaw);
     _pitchBankYaw params ["_pitch", "_bank", "_yaw"];
diff --git a/addons/scopes/functions/fnc_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf
index f83371ec13..670db51fe0 100644
--- a/addons/scopes/functions/fnc_firedEH.sqf
+++ b/addons/scopes/functions/fnc_firedEH.sqf
@@ -28,7 +28,7 @@ private _zeroing = +(_adjustment select _weaponIndex);
 TRACE_1("Adjusting With",_zeroing);
 
 // Convert zeroing from mils to degrees
-_zeroing = _zeroing vectorMultiply 0.05625;
+_zeroing = _zeroing vectorMultiply MRAD_TO_DEG(1);
 
 if (GVAR(correctZeroing)) then {
     private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false];
diff --git a/addons/scopes/script_component.hpp b/addons/scopes/script_component.hpp
index a797b36191..cc6acebc98 100644
--- a/addons/scopes/script_component.hpp
+++ b/addons/scopes/script_component.hpp
@@ -22,4 +22,6 @@
     #define DEBUG_SETTINGS DEBUG_SETTINGS_SCOPES
 #endif
 
+#define MRAD_TO_DEG(d) (d / 17.45329252) // Conversion factor: 9 / (50 * PI)
+
 #include "\z\ace\addons\main\script_macros.hpp"