From f44da354d5bab851dbd415a860da2bb37c24b1b7 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Tue, 11 Apr 2017 10:12:03 -0500 Subject: [PATCH] Fix tagging model cache (#5055) --- addons/tagging/XEH_postInit.sqf | 4 ++-- addons/tagging/functions/fnc_checkTaggable.sqf | 18 ++++++------------ addons/tagging/functions/fnc_tag.sqf | 12 ++++-------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/addons/tagging/XEH_postInit.sqf b/addons/tagging/XEH_postInit.sqf index 6693bda2f6..1e7003281a 100644 --- a/addons/tagging/XEH_postInit.sqf +++ b/addons/tagging/XEH_postInit.sqf @@ -16,7 +16,7 @@ for "_index" from 0 to (_countOptions - 1) do { private _model = getText (_cfgClass >> "model"); if (_model != "") then { private _array = _model splitString "\"; - GVAR(cacheStaticModels) setVariable [toLower (_array select ((count _array) - 2)), _cfgClass]; + GVAR(cacheStaticModels) setVariable [(_array select ((count _array) - 1)), true]; }; }; }; @@ -32,7 +32,7 @@ for "_index" from 0 to (_countOptions - 1) do { private _model = getText (_cfgClass >> "model"); if (_model != "") then { private _array = _model splitString "\"; - GVAR(cacheStaticModels) setVariable [toLower (_array select ((count _array) - 2)), _cfgClass]; + GVAR(cacheStaticModels) setVariable [(_array select ((count _array) - 1)), true]; }; }; }; diff --git a/addons/tagging/functions/fnc_checkTaggable.sqf b/addons/tagging/functions/fnc_checkTaggable.sqf index d739bbfec5..e4328687a9 100644 --- a/addons/tagging/functions/fnc_checkTaggable.sqf +++ b/addons/tagging/functions/fnc_checkTaggable.sqf @@ -9,16 +9,14 @@ * Is surface taggable * * Example: - * [unit] call ace_tagging_fnc_checkTaggable + * [player] call ace_tagging_fnc_checkTaggable * * Public: No */ #include "script_component.hpp" -params ["_unit"]; - -[[_unit], { +[_this, { params ["_unit"]; // Exit if no required item in inventory @@ -45,15 +43,11 @@ params ["_unit"]; if (_object isKindOf "Static") exitWith {false}; // If the class is not categorized correctly search the cache - private _array = str(_object) splitString " "; - private _str = toLower (_array select 1); - TRACE_1("Object:",_str); - private _objClass = GVAR(cacheStaticModels) getVariable _str; + private _modelName = (getModelInfo _object) select 0; + private _isStatic = GVAR(cacheStaticModels) getVariable [_modelName, false]; + TRACE_2("Object:",_modelName,_isStatic); // If the class in not on the cache, exit - if (isNil "_objClass") exitWith { - false - }; - true + (!_isStatic) }) exitWith { TRACE_1("Pointed object is non static",_object); false diff --git a/addons/tagging/functions/fnc_tag.sqf b/addons/tagging/functions/fnc_tag.sqf index 3aec5ec139..f90e09cd0a 100644 --- a/addons/tagging/functions/fnc_tag.sqf +++ b/addons/tagging/functions/fnc_tag.sqf @@ -49,15 +49,11 @@ if ((!isNull _object) && { if (_object isKindOf "Static") exitWith {false}; // If the class is not categorized correctly search the cache - private _array = str(_object) splitString " "; - private _str = toLower (_array select 1); - TRACE_1("Object:",_str); - private _objClass = GVAR(cacheStaticModels) getVariable _str; + private _modelName = (getModelInfo _object) select 0; + private _isStatic = GVAR(cacheStaticModels) getVariable [_modelName, false]; + TRACE_2("Object:",_modelName,_isStatic); // If the class in not on the cache, exit - if (isNil "_objClass") exitWith { - false - }; - true + (!_isStatic) }) exitWith { TRACE_1("Pointed object is non static",_object); false