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

Attach - Optimize creating children actions #6345

Merged
merged 2 commits into from
May 31, 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
4 changes: 2 additions & 2 deletions addons/attach/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class GVAR(AttachVehicle) { \
displayName = CSTRING(AttachDetach); \
condition = QUOTE(_this call FUNC(canAttach)); \
insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions)); \
insertChildren = QUOTE(_this call FUNC(getChildrenActions)); \
exceptions[] = {"isNotSwimming"}; \
showDisabled = 0; \
priority = 0; \
Expand Down Expand Up @@ -54,7 +54,7 @@ class CfgVehicles {
class GVAR(Attach) {
displayName = CSTRING(AttachDetach);
condition = QUOTE(_this call FUNC(canAttach));
insertChildren = QUOTE(_this call FUNC(getChildrenAttachActions));
insertChildren = QUOTE(_this call FUNC(getChildrenActions));
exceptions[] = {"isNotDragging", "isNotSwimming"};
showDisabled = 0;
priority = 5;
Expand Down
3 changes: 1 addition & 2 deletions addons/attach/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

PREP(attach);
PREP(canAttach);
PREP(canDetach);
PREP(detach);
PREP(getChildrenAttachActions);
PREP(getChildrenActions);
PREP(handleGetIn);
PREP(handleGetOut);
PREP(handleKilled);
Expand Down
48 changes: 48 additions & 0 deletions addons/attach/functions/fnc_getChildrenActions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Author: Garth de Wet (LH), PabstMirror, mharis001
* Returns children actions for attachable items.
*
* Arguments:
* 0: Target <OBJECT>
* 1: Player <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* [_target, _player] call ace_attach_fnc_getChildrenActions
*
* Public: No
*/
#include "script_component.hpp"

params ["_target", "_player"];
TRACE_2("params",_target,_player);

private _cfgMagazines = configFile >> "CfgMagazines";
private _cfgWeapons = configFile >> "CfgWeapons";

private _actions = [];

private _magazines = magazines _player;
{
private _config = _cfgMagazines >> _x;
if (getText (_config >> "ACE_Attachable") != "") then {
private _displayName = getText (_config >> "displayName");
private _picture = getText (_config >> "picture");
private _action = [_x, _displayName, _picture, {[{_this call FUNC(attach)}, _this] call CBA_fnc_execNextFrame}, {true}, {}, _x] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
};
} forEach (_magazines arrayIntersect _magazines);

{
private _config = _cfgWeapons >> _x;
if (getText (_config >> "ACE_Attachable") != "") then {
private _displayName = getText (_config >> "displayName");
private _picture = getText (_config >> "picture");
private _action = [_x, _displayName, _picture, {[{_this call FUNC(attach)}, _this] call CBA_fnc_execNextFrame}, {true}, {}, _x] call EFUNC(interact_menu,createAction);
_actions pushBack [_action, [], _target];
};
} forEach ([_player, false] call CBA_fnc_uniqueUnitItems);

_actions
52 changes: 0 additions & 52 deletions addons/attach/functions/fnc_getChildrenAttachActions.sqf

This file was deleted.