From e67aefcf51fa033c1f1c47a214d71d4403a5686f Mon Sep 17 00:00:00 2001 From: Brandon Danyluk Date: Tue, 18 May 2021 02:46:30 -0600 Subject: [PATCH] change events to allow for any number of arguments --- addons/iron_dome/XEH_preInit.sqf | 50 ++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/addons/iron_dome/XEH_preInit.sqf b/addons/iron_dome/XEH_preInit.sqf index cb518e5ee5..ffce361076 100644 --- a/addons/iron_dome/XEH_preInit.sqf +++ b/addons/iron_dome/XEH_preInit.sqf @@ -24,19 +24,22 @@ if (isServer) then { GVAR(nonTrackingProjectiles) pushBack _projectile; }] call CBA_fnc_addEventHandler; - [QGVAR(registerLauncher), { - params ["_launcher"]; - GVAR(launchers) pushBackUnique _launcher; - _launcher setVariable [QGVAR(targetList), []]; - _launcher setVariable [QGVAR(launchState), LAUNCH_STATE_IDLE]; - _launcher setVariable [QGVAR(lastLaunchTime), 0]; - _launcher setVariable [QGVAR(engagedTargets), [[], objNull] call CBA_fnc_hashCreate]; - _launcher setVariable [QEGVAR(missileguidance,target), objNull]; + [QGVAR(registerLaunchers), { + { + GVAR(launchers) pushBackUnique _x; + _x setVariable [QGVAR(targetList), []]; + _x setVariable [QGVAR(launchState), LAUNCH_STATE_IDLE]; + _x setVariable [QGVAR(lastLaunchTime), 0]; + _x setVariable [QGVAR(engagedTargets), [[], objNull] call CBA_fnc_hashCreate]; + _x setVariable [QEGVAR(missileguidance,target), objNull]; + } forEach _this; }] call CBA_fnc_addEventHandler; - [QGVAR(registerTracker), { - params ["_tracker", "_range"]; - GVAR(trackers) pushBack [_tracker, _range]; + [QGVAR(registerTrackers), { + { + _x params ["_tracker", "_range"]; + GVAR(trackers) pushBack [_tracker, _range]; + } forEach _this; }] call CBA_fnc_addEventHandler; [QGVAR(registerInterceptor), { @@ -51,23 +54,26 @@ if (isServer) then { // duplicate event to add event handler [QGVAR(registerLauncher), { - params ["_launcher"]; - if !(local _launcher) exitWith {}; - _launcher addEventHandler ["Fired", { - params ["_launcher", "", "", "", "", "", "_projectile"]; - private _target = _launcher getVariable [QEGVAR(missileguidance,target), objNull]; - if !(isNull _target) then { - [QGVAR(registerInterceptor), [_projectile, _target]] call CBA_fnc_serverEvent; + { + if (local _x) then { + _x addEventHandler ["Fired", { + params ["_launcher", "", "", "", "", "", "_projectile"]; + private _target = _launcher getVariable [QEGVAR(missileguidance,target), objNull]; + if !(isNull _target) then { + [QGVAR(registerInterceptor), [_projectile, _target]] call CBA_fnc_serverEvent; + }; + }]; }; - }]; + } forEach _this; }] call CBA_fnc_addEventHandler; // When something is fired, determine if we want to track it. If so, send it to the server for processing GVAR(projectilesToIntercept) = []; -[QGVAR(addProjectileToIntercept), { - params ["_type"]; - GVAR(projectilesToIntercept) pushBackUnique _type; +[QGVAR(addProjectilesToIntercept), { + { + GVAR(projectilesToIntercept) pushBackUnique _x; + } forEach _this; }] call CBA_fnc_addEventHandler; ["All", "fired", {