From 0b695be84115f7e0e9791b5e54b5dcc0ce02fe60 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 22 Sep 2023 11:09:46 -0500 Subject: [PATCH] Laserpointer - Block switching to unsupported visible lasers (#9416) --- addons/common/functions/fnc_lightIntensityFromObject.sqf | 2 -- addons/laserpointer/CfgEventHandlers.hpp | 5 +++++ addons/laserpointer/XEH_preInit.sqf | 5 +++++ addons/laserpointer/XEH_preStart.sqf | 5 +++++ docs/wiki/development/ace3-config-entries.md | 1 - 5 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 addons/laserpointer/XEH_preStart.sqf diff --git a/addons/common/functions/fnc_lightIntensityFromObject.sqf b/addons/common/functions/fnc_lightIntensityFromObject.sqf index 3afdb0f635..38895557ad 100644 --- a/addons/common/functions/fnc_lightIntensityFromObject.sqf +++ b/addons/common/functions/fnc_lightIntensityFromObject.sqf @@ -30,8 +30,6 @@ if (_lightSource isKindOf "CAManBase") then { private _flashlight = (_lightSource weaponAccessories _weapon) select 1; - if (getNumber (configFile >> "CfgWeapons" >> _flashlight >> "ACE_laserpointer") > 0) exitWith {}; // Red = 1, Green = 2 - private _properties = [[_flashlight], FUNC(getLightPropertiesWeapon), uiNamespace, format [QEGVAR(cache,%1_%2), QUOTE(DFUNC(getLightPropertiesWeapon)), _flashlight], 1E11] call FUNC(cachedCall); //_properties = [_flashlight] call FUNC(getLightPropertiesWeapon); diff --git a/addons/laserpointer/CfgEventHandlers.hpp b/addons/laserpointer/CfgEventHandlers.hpp index 9b160c1600..f72363981a 100644 --- a/addons/laserpointer/CfgEventHandlers.hpp +++ b/addons/laserpointer/CfgEventHandlers.hpp @@ -1,3 +1,8 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; class Extended_PreInit_EventHandlers { class ADDON { init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); diff --git a/addons/laserpointer/XEH_preInit.sqf b/addons/laserpointer/XEH_preInit.sqf index 19f1494f29..7ab1e00588 100644 --- a/addons/laserpointer/XEH_preInit.sqf +++ b/addons/laserpointer/XEH_preInit.sqf @@ -1,3 +1,8 @@ #include "script_component.hpp" +{ + TRACE_1("blocking switching to unsupported laser mode",_x); + [_x, { false }] call CBA_fnc_addAttachmentCondition; +} forEach (keys (uiNamespace getVariable QGVAR(oldLasers))); + ADDON = true; diff --git a/addons/laserpointer/XEH_preStart.sqf b/addons/laserpointer/XEH_preStart.sqf new file mode 100644 index 0000000000..41fe08e7cc --- /dev/null +++ b/addons/laserpointer/XEH_preStart.sqf @@ -0,0 +1,5 @@ +#include "script_component.hpp" + +private _lasers = ((toString {(getNumber (_x >> "ACE_laserpointer")) > 0}) configClasses (configFile >> "CfgWeapons")) apply {configName _x}; +if (_lasers isNotEqualTo []) then { WARNING_1("%1 attachements still using unsupported ACE_laserpointer config",count _lasers) }; +uiNamespace setVariable [QGVAR(oldLasers), compileFinal (_lasers createHashMapFromArray [])]; diff --git a/docs/wiki/development/ace3-config-entries.md b/docs/wiki/development/ace3-config-entries.md index b8f66a9f18..9e656ad48c 100644 --- a/docs/wiki/development/ace3-config-entries.md +++ b/docs/wiki/development/ace3-config-entries.md @@ -76,7 +76,6 @@ ace_detonator ace_barrelTwist ace_twistDirection ace_barrelLength -ace_laserpointer ace_nextmodeclass ace_modedescription ace_hearing_protection