diff --git a/addons/minedetector/XEH_postInit.sqf b/addons/minedetector/XEH_postInit.sqf index 7ea04b5a5d..1c448794cc 100644 --- a/addons/minedetector/XEH_postInit.sqf +++ b/addons/minedetector/XEH_postInit.sqf @@ -5,16 +5,12 @@ GVAR(detectorConfigs) = call CBA_fnc_createNamespace; // Create a dictionary of detectable classnames GVAR(detectableClasses) = call CBA_fnc_createNamespace; + +private _detectableClasses = call (uiNamespace getVariable [QGVAR(detectableClasses), {[]}]); //See XEH_preStart.sqf { - if ((getNumber (_x >> QGVAR(detectable))) == 1) then { - GVAR(detectableClasses) setVariable [configName _x, true]; - }; -} forEach (configProperties [configFile >> "CfgVehicles", "isClass _x", true]); -{ - if ((getNumber (_x >> QGVAR(detectable))) == 1) then { - GVAR(detectableClasses) setVariable [configName _x, true]; - }; -} forEach (configProperties [configFile >> "CfgAmmo", "isClass _x", true]); + GVAR(detectableClasses) setVariable [_x, true]; +} forEach _detectableClasses; +TRACE_1("built cache",count allVariables GVAR(detectableClasses)); [QGVAR(enableDetector), FUNC(enableDetector)] call CBA_fnc_addEventHandler; [QGVAR(disableDetector), FUNC(disableDetector)] call CBA_fnc_addEventHandler; diff --git a/addons/minedetector/XEH_preStart.sqf b/addons/minedetector/XEH_preStart.sqf index 022888575e..48f003d08e 100644 --- a/addons/minedetector/XEH_preStart.sqf +++ b/addons/minedetector/XEH_preStart.sqf @@ -1,3 +1,19 @@ #include "script_component.hpp" #include "XEH_PREP.hpp" + +// Cache detectable classes, see XEH_postInit.sqf +private _detectableClasses = []; +{ + if ((getNumber (_x >> QGVAR(detectable))) == 1) then { + _detectableClasses pushBackUnique configName _x; + }; +} forEach (configProperties [configFile >> "CfgVehicles", "isClass _x", true]); +{ + if ((getNumber (_x >> QGVAR(detectable))) == 1) then { + _detectableClasses pushBackUnique configName _x; + }; +} forEach (configProperties [configFile >> "CfgAmmo", "isClass _x", true]); + +TRACE_1("compiled",count _detectableClasses); +uiNamespace setVariable [QGVAR(detectableClasses), compileFinal str _detectableClasses];