ACE3/addons/common/functions/fnc_getCustomResults_f.sqf
Glowbal 041a4fccc5 Removed CSE text
Changed set count to pushback.
2015-01-17 12:42:10 +01:00

46 lines
1.4 KiB
Plaintext

/**
* fn_getCustomResults_f.sqf
* @Descr: Executes custom results eventhandlers, collects their output and returns this.
* @Author: Glowbal
*
* @Arguments: [arguments ANY, handle STRING]
* @Return: ARRAY Collection of all return values of all executed CustomResult handlers
* @PublicAPI: true
*/
#include "script_component.hpp"
private ["_arguments","_handle","_ehCfg","_eventHandlerCollection","_eventHandlerName","_cfg","_code","_classType", "_return"];
_arguments = _this select 0;
_handle = _this select 1;
_eventHandlerName = ("ace_f_custom_results_eventhandler_" + _handle);
_eventHandlerCollection = missionNamespace getvariable _eventHandlerName;
if (isnil "_eventHandlerCollection") then {
_eventHandlerCollection = [];
// TODO Get a replacement for this
_cfg = (ConfigFile >> "Advanced_Combat_Environment" >> "CustomResults" >> _handle);
if (isClass _cfg) then {
_numberOfEH = count _cfg;
for [{_EHiterator=0}, {(_EHiterator< _numberOfEH)}, {_EHiterator=_EHiterator+1}] do {
_ehCfg = _cfg select _EHiterator;
if (isClass _ehCfg) then {
_classType = (ConfigName _ehCfg);
_code = (compile getText(_ehCfg >> "onCall"));
_eventHandlerCollection pushback [_classType, _code];
true;
};
};
};
missionNamespace setvariable [_eventHandlerName, _eventHandlerCollection];
};
_return = [];
{
_return pushback (_arguments call (_x select 1));
false;
}count _eventHandlerCollection;
_return