Tagging - Cache tagging static models (#6804)

* Cache tagging static models

* Fix bugs, use compileFinal

* Apply suggestions from code review

Co-Authored-By: dedmen <dedmen@users.noreply.github.com>

* Use toLower
This commit is contained in:
Dedmen Miller 2019-02-17 18:41:25 +01:00 committed by PabstMirror
parent af1cf2c7f6
commit 7cce148513
2 changed files with 33 additions and 33 deletions

View File

@ -4,39 +4,10 @@
// Cache for static objects
GVAR(cacheStaticModels) = [false] call CBA_fnc_createNamespace;
// Consider static everything vehicle that inherit from Static
// This include houses (which we don't need), but also walls, that we do
private _cfgBase = configFile >> "CfgVehicles";
private _countOptions = count _cfgBase;
for "_index" from 0 to (_countOptions - 1) do {
private _cfgClass = _cfgBase select _index;
if (isClass _cfgClass) then {
if ((configName _cfgClass) isKindOf "Static") then {
private _model = getText (_cfgClass >> "model");
if (_model != "") then {
private _array = _model splitString "\";
GVAR(cacheStaticModels) setVariable [(_array select ((count _array) - 1)), true];
};
};
};
};
// Also consider static all object inheriting from bridges
_cfgBase = configFile >> "CfgNonAIVehicles";
_countOptions = count _cfgBase;
for "_index" from 0 to (_countOptions - 1) do {
private _cfgClass = _cfgBase select _index;
if (isClass _cfgClass) then {
if ((configName _cfgClass) isKindOf ["Bridge_base_F", _cfgBase]) then {
private _model = getText (_cfgClass >> "model");
if (_model != "") then {
private _array = _model splitString "\";
GVAR(cacheStaticModels) setVariable [(_array select ((count _array) - 1)), true];
};
};
};
};
private _cacheStaticModels = call (uiNamespace getVariable [QGVAR(cacheStaticModels), {[]}]);
{
GVAR(cacheStaticModels) setVariable [_x, true];
} forEach _cacheStaticModels;
if (hasInterface) then {
// Compile and cache config tags

View File

@ -1,3 +1,32 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"
private _cacheStaticModels = [];
private _vehicleClasses = "isClass _x && (configName _x) isKindOf 'Static'" configClasses (configFile >> "CfgVehicles");
// Consider static everything vehicle that inherit from Static
// This include houses (which we don't need), but also walls, that we do
{
private _model = getText (_x >> "model");
if (_model != "") then {
private _array = _model splitString "\";
_cacheStaticModels pushBackUnique toLower (_array select ((count _array) - 1));
};
} forEach _vehicleClasses;
private _nonAIVehicleClasses = "isClass _x" configClasses (configFile >> "CfgNonAIVehicles");
// Also consider static all object inheriting from bridges
private _cfgBase = configFile >> "CfgNonAIVehicles";
{
private _model = getText (_x >> "model");
if (_model != "") then {
private _array = _model splitString "\";
_cacheStaticModels pushBackUnique toLower (_array select ((count _array) - 1));
};
} forEach (_nonaivehicleClasses select {(configName _x) isKindOf ["Bridge_base_F", _cfgBase]});
uiNamespace setVariable [QGVAR(cacheStaticModels), compileFinal str _cacheStaticModels];
TRACE_1("compiled",count _cacheStaticModels);