From 61000df1202ef79e7621305676de1aa92cfaf944 Mon Sep 17 00:00:00 2001 From: mharis001 <34453221+mharis001@users.noreply.github.com> Date: Fri, 21 Sep 2018 16:11:02 -0400 Subject: [PATCH] Tagging - Cache required items check and use uniqueItems (#6582) * Cache required items check and use uniqueItems * Use config-case for required items --- addons/tagging/functions/fnc_addCustomTag.sqf | 1 - addons/tagging/functions/fnc_addTagActions.sqf | 2 +- addons/tagging/functions/fnc_applyCustomTag.sqf | 2 ++ addons/tagging/functions/fnc_checkTaggable.sqf | 5 +++-- addons/tagging/functions/fnc_compileConfigTags.sqf | 4 +++- addons/tagging/functions/fnc_quickTag.sqf | 2 +- 6 files changed, 10 insertions(+), 6 deletions(-) diff --git a/addons/tagging/functions/fnc_addCustomTag.sqf b/addons/tagging/functions/fnc_addCustomTag.sqf index 4a0fdf6ced..cb426493b3 100644 --- a/addons/tagging/functions/fnc_addCustomTag.sqf +++ b/addons/tagging/functions/fnc_addCustomTag.sqf @@ -48,7 +48,6 @@ if (_textures isEqualTo []) exitWith { }; _identifier = [_identifier] call CBA_fnc_removeWhitespace; -_requiredItem = toLower _requiredItem; // Add [QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon]] call CBA_fnc_globalEventJIP; diff --git a/addons/tagging/functions/fnc_addTagActions.sqf b/addons/tagging/functions/fnc_addTagActions.sqf index 692fccd194..a5fdcd219a 100644 --- a/addons/tagging/functions/fnc_addTagActions.sqf +++ b/addons/tagging/functions/fnc_addTagActions.sqf @@ -33,7 +33,7 @@ private _actions = []; }, { (_this select 2) params ["_unit", "", "", "_requiredItem"]; - _requiredItem in ((items _unit) apply {toLower _x}) + _requiredItem in (_unit call EFUNC(common,uniqueItems)) }, {}, [_unit, _class, _textures, _requiredItem] diff --git a/addons/tagging/functions/fnc_applyCustomTag.sqf b/addons/tagging/functions/fnc_applyCustomTag.sqf index 123ce8df4c..be73d85021 100644 --- a/addons/tagging/functions/fnc_applyCustomTag.sqf +++ b/addons/tagging/functions/fnc_applyCustomTag.sqf @@ -25,6 +25,8 @@ params ["_identifier", "_displayName", "_requiredItem"]; if !(GVAR(cachedTags) select {_x select 0 == _identifier} isEqualTo []) exitWith { INFO_2("Tag with selected identifier already exists: %1 (%2)",_identifier,_displayName) }; +_requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // Convert To config case +_this set [2, _requiredItem]; GVAR(cachedTags) pushBack _this; GVAR(cachedRequiredItems) pushBackUnique _requiredItem; diff --git a/addons/tagging/functions/fnc_checkTaggable.sqf b/addons/tagging/functions/fnc_checkTaggable.sqf index 473d2e390e..3a022ca2b7 100644 --- a/addons/tagging/functions/fnc_checkTaggable.sqf +++ b/addons/tagging/functions/fnc_checkTaggable.sqf @@ -19,7 +19,9 @@ params ["_unit"]; // Exit if no required item in inventory - if ((GVAR(cachedRequiredItems) arrayIntersect ((items _unit) apply {toLower _x})) isEqualTo []) exitWith {false}; + if ([_unit, { + GVAR(cachedRequiredItems) arrayIntersect (_unit call EFUNC(common,uniqueItems)) isEqualTo [] + }, _unit, QGVAR(checkRequiredItemsCache), 9999, "cba_events_loadoutEvent"] call EFUNC(common,cachedCall)) exitWith {false}; private _startPosASL = eyePos _unit; private _cameraPosASL = AGLToASL positionCameraToWorld [0, 0, 0]; @@ -36,7 +38,6 @@ // Exit if trying to tag a non static object TRACE_1("Obj:",_intersections); - // Exit if trying to tag a non static object if ((!isNull _object) && { // If the class is alright, do not exit if (_object isKindOf "Static") exitWith {false}; diff --git a/addons/tagging/functions/fnc_compileConfigTags.sqf b/addons/tagging/functions/fnc_compileConfigTags.sqf index 35b8f2d4c7..c9aaca9506 100644 --- a/addons/tagging/functions/fnc_compileConfigTags.sqf +++ b/addons/tagging/functions/fnc_compileConfigTags.sqf @@ -25,7 +25,7 @@ _failure = true; }; - private _requiredItem = toLower (getText (_x >> "requiredItem")); + private _requiredItem = getText (_x >> "requiredItem"); if (_requiredItem == "") then { ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class); _failure = true; @@ -33,6 +33,8 @@ if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then { ERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem); _failure = true; + } else { + _requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // convert to config case }; }; diff --git a/addons/tagging/functions/fnc_quickTag.sqf b/addons/tagging/functions/fnc_quickTag.sqf index dde4c02729..bb672ed947 100644 --- a/addons/tagging/functions/fnc_quickTag.sqf +++ b/addons/tagging/functions/fnc_quickTag.sqf @@ -48,6 +48,6 @@ if (GVAR(quickTag) == 3) then { // Tag if !(_possibleTags isEqualTo []) then { - private _availableTags = _possibleTags select {(_x select 2) in ((items _unit) apply {toLower _x})}; + private _availableTags = _possibleTags select {(_x select 2) in (_unit call EFUNC(common,uniqueItems))}; [_unit, selectRandom ((selectRandom _availableTags) select 3)] call FUNC(tag); };