2015-01-11 16:42:31 +00:00
/*
* Author: commy2
* Execute a function on every machine. Function will also be called upon JIP (postInit). The arguments are stored in (_this select 0), while the assigned namespace is stored in (_this select 1).
*
2015-09-20 18:25:25 +00:00
* Arguments:
* 0: Function arguments <ARRAY>
* 1: Function to execute, has to be defined on the remote machine first <STRING>
* 2: Namespace to save that variable in <OBJECT, NAMESPACE>
* 3: Name. Will overwrite previously defined functions with that name <STRING>
*
* Return Value:
* None
*
* Public: No
2015-01-11 16:42:31 +00:00
*
2015-09-20 18:25:25 +00:00
* Deprecated
2015-01-11 16:42:31 +00:00
*/
2015-01-13 19:56:02 +00:00
#include "script_component.hpp"
2015-01-11 16:42:31 +00:00
GVAR(remoteFnc) = _this;
2015-09-20 18:25:25 +00:00
params ["_arguments", "_function", "_unit", "_name"];
2015-10-04 02:34:46 +00:00
TRACE_4("params", _arguments, _function, _unit, _name);
2015-09-20 18:25:25 +00:00
_function = call compile _function;
2015-01-11 16:42:31 +00:00
// execute function on every currently connected machine
2015-01-11 18:20:14 +00:00
[[_arguments, _unit], _this select 1, 2] call FUNC(execRemoteFnc);
2015-01-11 16:42:31 +00:00
// save persistent function for JIP
2015-12-12 15:48:54 +00:00
private _persistentFunctions = _unit getVariable ["ACE_PersistentFunctions", []];
2015-01-11 16:42:31 +00:00
// find index to overwrite function with the same name, add to end otherwise
2015-12-12 15:48:54 +00:00
private _index = count _persistentFunctions;
2015-01-11 16:42:31 +00:00
{
2015-05-14 18:06:06 +00:00
if (_x select 2 == _name) exitWith {
_index = _forEachIndex;
};
2015-01-11 16:42:31 +00:00
} forEach _persistentFunctions;
// set new value
_persistentFunctions set [_index, [_arguments, _function, _name]];
// broadcast variable
if (typeName _unit == "NAMESPACE") then {
2015-05-14 18:06:06 +00:00
ACE_PersistentFunctions = _persistentFunctions;
publicVariable "ACE_PersistentFunctions";
2015-01-11 16:42:31 +00:00
} else {
2015-05-14 18:06:06 +00:00
_unit setVariable ["ACE_PersistentFunctions", _persistentFunctions, true];
2015-01-11 16:42:31 +00:00
};