From a3dc1df109928918cbaa96f8bf60b5773a248859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Thu, 12 Feb 2015 11:57:55 -0300 Subject: [PATCH] scopes: moved getWeaponIndex to common --- addons/common/XEH_preInit.sqf | 1 + addons/{scopes => common}/functions/fnc_getWeaponIndex.sqf | 2 ++ addons/scopes/XEH_preInit.sqf | 1 - addons/scopes/functions/fnc_adjustScope.sqf | 2 +- addons/scopes/functions/fnc_canAdjustScope.sqf | 2 +- addons/scopes/functions/fnc_firedEH.sqf | 2 +- addons/scopes/functions/fnc_showZeroing.sqf | 2 +- 7 files changed, 7 insertions(+), 5 deletions(-) rename addons/{scopes => common}/functions/fnc_getWeaponIndex.sqf (92%) diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index 9b8964df1b..a186d2ddbe 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -75,6 +75,7 @@ PREP(getVehicleCargo); PREP(getVehicleCodriver); PREP(getVehicleCrew); PREP(getWeaponAzimuthAndInclination); +PREP(getWeaponIndex); PREP(getWeaponType); PREP(getWindDirection); PREP(goKneeling); diff --git a/addons/scopes/functions/fnc_getWeaponIndex.sqf b/addons/common/functions/fnc_getWeaponIndex.sqf similarity index 92% rename from addons/scopes/functions/fnc_getWeaponIndex.sqf rename to addons/common/functions/fnc_getWeaponIndex.sqf index 05c1202795..6cac6d244e 100644 --- a/addons/scopes/functions/fnc_getWeaponIndex.sqf +++ b/addons/common/functions/fnc_getWeaponIndex.sqf @@ -16,6 +16,8 @@ EXPLODE_2_PVT(_this,_unit,_weapon); +if (_weapon = "") exitWith {-1}; + [ primaryWeapon _unit, secondaryWeapon _unit, diff --git a/addons/scopes/XEH_preInit.sqf b/addons/scopes/XEH_preInit.sqf index 5dd7153263..e574cc72d4 100644 --- a/addons/scopes/XEH_preInit.sqf +++ b/addons/scopes/XEH_preInit.sqf @@ -6,7 +6,6 @@ PREP(adjustScope); PREP(canAdjustScope); PREP(firedEH); PREP(getOptics); -PREP(getWeaponIndex); PREP(inventoryCheck); PREP(showZeroing); diff --git a/addons/scopes/functions/fnc_adjustScope.sqf b/addons/scopes/functions/fnc_adjustScope.sqf index cf4d7e7146..031ff3a820 100644 --- a/addons/scopes/functions/fnc_adjustScope.sqf +++ b/addons/scopes/functions/fnc_adjustScope.sqf @@ -18,7 +18,7 @@ private ["_unit", "_weapons", "_zeroing", "_pitchbankyaw", "_pitch", "_bank", "_ _unit = _this select 0; -_weaponIndex = [_unit, currentWeapon _unit] call FUNC(getWeaponIndex); +_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); _adjustment = _unit getVariable QGVAR(Adjustment); if (isNil "_adjustment") then { diff --git a/addons/scopes/functions/fnc_canAdjustScope.sqf b/addons/scopes/functions/fnc_canAdjustScope.sqf index 75d5dd73a7..eda08dc0ee 100644 --- a/addons/scopes/functions/fnc_canAdjustScope.sqf +++ b/addons/scopes/functions/fnc_canAdjustScope.sqf @@ -18,7 +18,7 @@ private ["_unit", "_weaponIndex", "_zeroing", "_optic", "_maxHorizontal", "_maxV _unit = _this select 0; -_weaponIndex = [_unit, currentWeapon _unit] call FUNC(getWeaponIndex); +_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {false}; _adjustment = _unit getVariable QGVAR(Adjustment); diff --git a/addons/scopes/functions/fnc_firedEH.sqf b/addons/scopes/functions/fnc_firedEH.sqf index b6da3c7a9e..371d1e5f33 100644 --- a/addons/scopes/functions/fnc_firedEH.sqf +++ b/addons/scopes/functions/fnc_firedEH.sqf @@ -31,7 +31,7 @@ if !([_unit] call EFUNC(common,isPlayer)) exitWith {}; _weapon = _this select 1; _projectile = _this select 5; -_weaponIndex = [_unit, currentWeapon _unit] call FUNC(getWeaponIndex); +_weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {}; _zeroing = _adjustment select _weaponIndex; diff --git a/addons/scopes/functions/fnc_showZeroing.sqf b/addons/scopes/functions/fnc_showZeroing.sqf index f00ca5fedb..836f69b2df 100644 --- a/addons/scopes/functions/fnc_showZeroing.sqf +++ b/addons/scopes/functions/fnc_showZeroing.sqf @@ -16,7 +16,7 @@ disableSerialization; private ["_weaponIndex","_adjustment","_layer","_display","_zeroing","_vertical","_horizontal"]; -_weaponIndex = [ACE_player, currentWeapon ACE_player] call FUNC(getWeaponIndex); +_weaponIndex = [ACE_player, currentWeapon ACE_player] call EFUNC(common,getWeaponIndex); if (_weaponIndex < 0) exitWith {}; _adjustment = ACE_player getVariable QGVAR(Adjustment);