Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tagging - Cache required items check and use uniqueItems #6582

Merged
merged 2 commits into from
Sep 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion addons/tagging/functions/fnc_addCustomTag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion addons/tagging/functions/fnc_addTagActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 2 additions & 0 deletions addons/tagging/functions/fnc_applyCustomTag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions addons/tagging/functions/fnc_checkTaggable.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate comment as above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦‍♂️ oof

if ((!isNull _object) && {
// If the class is alright, do not exit
if (_object isKindOf "Static") exitWith {false};
Expand Down
4 changes: 3 additions & 1 deletion addons/tagging/functions/fnc_compileConfigTags.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
_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;
} else {
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
};
};

Expand Down
2 changes: 1 addition & 1 deletion addons/tagging/functions/fnc_quickTag.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};