Minedetector - Cache detectableClasses (#6805)

* Cache minedetector detectableClasses

* use compileFinal
This commit is contained in:
Dedmen Miller 2019-02-17 19:31:34 +01:00 committed by PabstMirror
parent 21fd4e5d16
commit 0c8c924487
2 changed files with 21 additions and 9 deletions

View File

@ -5,16 +5,12 @@ GVAR(detectorConfigs) = call CBA_fnc_createNamespace;
// Create a dictionary of detectable classnames // Create a dictionary of detectable classnames
GVAR(detectableClasses) = call CBA_fnc_createNamespace; 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 [_x, true];
GVAR(detectableClasses) setVariable [configName _x, true]; } forEach _detectableClasses;
}; TRACE_1("built cache",count allVariables GVAR(detectableClasses));
} 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]);
[QGVAR(enableDetector), FUNC(enableDetector)] call CBA_fnc_addEventHandler; [QGVAR(enableDetector), FUNC(enableDetector)] call CBA_fnc_addEventHandler;
[QGVAR(disableDetector), FUNC(disableDetector)] call CBA_fnc_addEventHandler; [QGVAR(disableDetector), FUNC(disableDetector)] call CBA_fnc_addEventHandler;

View File

@ -1,3 +1,19 @@
#include "script_component.hpp" #include "script_component.hpp"
#include "XEH_PREP.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];