Fix interaction addActionToX return values (#4461)

* Fix interaction addActionToX return values

Fix #4460
Fix returning number from pushBack

* Retrun empty array on error
This commit is contained in:
PabstMirror 2016-09-27 11:09:06 -05:00 committed by GitHub
parent 565af1b571
commit 257f1a1b4c
2 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,7 @@
if (!params [["_objectType", "", [""]], ["_typeNum", 0, [0]], ["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {
ERROR("Bad Params");
[]
};
TRACE_4("params",_objectType,_typeNum,_parentPath,_action);
@ -38,6 +39,9 @@ if (param [4, false, [false]]) exitwith {
', _index];
TRACE_2("Added inheritable action",_objectType,_index);
[_objectType, "init", _initEH, true, [], true] call CBA_fnc_addClassEventHandler;
// Return the full path
(_parentPath + [_action select 0])
};
// Ensure the config menu was compiled first
@ -62,10 +66,11 @@ private _parentNode = [_actionTrees, _parentPath] call FUNC(findActionNode);
if (isNil {_parentNode}) exitWith {
ERROR("Failed to add action");
ACE_LOGERROR_4("action (%1) to parent %2 on object %3 [%4]",(_action select 0),_parentPath,_objectType,_typeNum);
[]
};
// Add action node as children of the correct node of action tree
(_parentNode select 1) pushBack [_action,[]];
// Return the full path
(+ _parentPath) pushBack (_action select 0)
(_parentPath + [_action select 0])

View File

@ -21,6 +21,7 @@
if (!params [["_object", objNull, [objNull]], ["_typeNum", 0, [0]], ["_parentPath", [], [[]]], ["_action", [], [[]], 11]]) exitWith {
ERROR("Bad Params");
[]
};
private _varName = [QGVAR(actions),QGVAR(selfActions)] select _typeNum;
@ -38,4 +39,4 @@ if (_parentPath isEqualTo ["ACE_MainActions"]) then {
_actionList pushBack [_action, +_parentPath];
// Return the full path
(+ _parentPath) pushBack (_action select 0)
(_parentPath + [_action select 0])