From d902d1182a2f3078c9a35da680d1d83d1a639fea Mon Sep 17 00:00:00 2001 From: jonpas Date: Sat, 21 May 2016 19:59:44 +0200 Subject: [PATCH] Replace ace_common_fnc_execRemoteFunc with events --- addons/common/XEH_postInit.sqf | 8 ++++++++ addons/common/functions/fnc_checkPBOs.sqf | 3 ++- addons/common/functions/fnc_onAnswerRequest.sqf | 2 +- addons/common/functions/fnc_sendRequest.sqf | 2 +- addons/common/functions/fnc_serverLog.sqf | 2 +- addons/common/scripts/checkVersionNumber.sqf | 8 ++++---- addons/explosives/XEH_postInit.sqf | 1 + addons/explosives/functions/fnc_startDefuse.sqf | 2 +- addons/repair/XEH_postInit.sqf | 2 ++ addons/repair/functions/fnc_useItem.sqf | 2 +- addons/respawn/XEH_postInit.sqf | 2 ++ addons/respawn/functions/fnc_handleKilled.sqf | 2 +- addons/spectator/XEH_postInit.sqf | 2 ++ .../spectator/functions/fnc_respawnTemplate.sqf | 2 +- .../spectator/functions/fnc_stageSpectator.sqf | 2 +- addons/switchunits/XEH_postInit.sqf | 8 ++++++++ addons/switchunits/functions/fnc_switchUnit.sqf | 16 ++-------------- 17 files changed, 39 insertions(+), 27 deletions(-) diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 88012a7884..c3cda091d8 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -163,9 +163,17 @@ if (isServer) then { ["setVectorDirAndUp", {(_this select 0) setVectorDirAndUp (_this select 1)}] call FUNC(addEventHandler); ["setVanillaHitPointDamage", {(_this select 0) setHitPointDamage (_this select 1)}] call FUNC(addEventHandler); +// Request framework +[QGVAR(requestCallback), FUNC(requestCallback)] call FUNC(addEventHandler); +[QGVAR(receiveRequest), FUNC(receiveRequest)] call FUNC(addEventHandler); + +[QGVAR(systemChatGlobal), {systemChat _this}] call FUNC(addEventHandler); + if (isServer) then { ["hideObjectGlobal", {(_this select 0) hideObjectGlobal (_this select 1)}] call FUNC(addEventHandler); ["enableSimulationGlobal", {(_this select 0) enableSimulationGlobal (_this select 1)}] call FUNC(addEventHandler); + ["setOwner", {(_this select 0) setOwner (_this select 1)}] call FUNC(addEventHandler); + [QGVAR(serverLog), FUNC(serverLog)] call FUNC(addEventHandler); }; diff --git a/addons/common/functions/fnc_checkPBOs.sqf b/addons/common/functions/fnc_checkPBOs.sqf index f447d126af..991b4e11f9 100644 --- a/addons/common/functions/fnc_checkPBOs.sqf +++ b/addons/common/functions/fnc_checkPBOs.sqf @@ -61,7 +61,8 @@ if (!isServer) then { _error = _error + "Newer version; "; }; - //[_error, "{systemChat _this}"] call FUNC(execRemoteFnc); + //[QGVAR(systemChatGlobal), _error] call FUNC(globalEvent); + ACE_LOGERROR(_error); if (_mode < 2) then { diff --git a/addons/common/functions/fnc_onAnswerRequest.sqf b/addons/common/functions/fnc_onAnswerRequest.sqf index d88969b059..e462a4bbf8 100644 --- a/addons/common/functions/fnc_onAnswerRequest.sqf +++ b/addons/common/functions/fnc_onAnswerRequest.sqf @@ -20,7 +20,7 @@ if (!isNil "_info") then { _info params ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"]; private _replyParams = [_info, _accepted]; - [_replyParams, QFUNC(requestCallback), _caller, false] call FUNC(execRemoteFnc); + [QGVAR(requestCallback), _caller, _replyParams] call FUNC(objectEvent); _unit setVariable [_id, nil]; }; diff --git a/addons/common/functions/fnc_sendRequest.sqf b/addons/common/functions/fnc_sendRequest.sqf index c8d2ef7e2b..6df60cf24d 100644 --- a/addons/common/functions/fnc_sendRequest.sqf +++ b/addons/common/functions/fnc_sendRequest.sqf @@ -20,7 +20,7 @@ params ["_caller", "_target", "_requestID", "_requestMessage", "_callBack"]; if (isPlayer _target) then { // Pass request on to target locality for player accept/decline. - [[_caller, _target, _requestID, _requestMessage, _callBack], QFUNC(receiveRequest), _target, false] call FUNC(execRemoteFnc); + [QGVAR(receiveRequest), _target, [_caller, _target, _requestID, _requestMessage, _callBack]] call FUNC(objectEvent); } else { // accept it, since it's an AI. [_caller, _target, true] call compile _callBack; diff --git a/addons/common/functions/fnc_serverLog.sqf b/addons/common/functions/fnc_serverLog.sqf index 2525f81c95..ca4ba69f5d 100644 --- a/addons/common/functions/fnc_serverLog.sqf +++ b/addons/common/functions/fnc_serverLog.sqf @@ -20,5 +20,5 @@ params [["_msg", "", [""]]]; if (isServer) then { diag_log text _msg; } else { - [_this, QFUNC(serverLog), 1] call FUNC(execRemoteFnc); + [QGVAR(serverLog), _this] call FUNC(serverEvent); }; diff --git a/addons/common/scripts/checkVersionNumber.sqf b/addons/common/scripts/checkVersionNumber.sqf index 07bd443a06..7b1fbca291 100644 --- a/addons/common/scripts/checkVersionNumber.sqf +++ b/addons/common/scripts/checkVersionNumber.sqf @@ -100,7 +100,7 @@ if (!isServer) then { _error = _error call _fnc_cutComma; diag_log text _error; - [_error, "{systemChat _this}"] call FUNC(execRemoteFnc); + [QGVAR(systemChatGlobal), _error] call FUNC(globalEvent); }; _missingAddonServer = false; @@ -117,7 +117,7 @@ if (!isServer) then { _error = _error call _fnc_cutComma; diag_log text _error; - [_error, "{systemChat _this}"] call FUNC(execRemoteFnc); + [QGVAR(systemChatGlobal), _error] call FUNC(globalEvent); }; _oldVersionClient = false; @@ -134,7 +134,7 @@ if (!isServer) then { _error = _error call _fnc_cutComma; diag_log text _error; - [_error, "{systemChat _this}"] call FUNC(execRemoteFnc); + [QGVAR(systemChatGlobal), _error] call FUNC(globalEvent); }; _oldVersionServer = false; @@ -151,7 +151,7 @@ if (!isServer) then { _error = _error call _fnc_cutComma; diag_log text _error; - [_error, "{systemChat _this}"] call FUNC(execRemoteFnc); + [QGVAR(systemChatGlobal), _error] call FUNC(globalEvent); }; ACE_Version_ClientErrors = [_missingAddon, _missingAddonServer, _oldVersionClient, _oldVersionServer]; diff --git a/addons/explosives/XEH_postInit.sqf b/addons/explosives/XEH_postInit.sqf index fe12a88b7f..f81cef5f79 100644 --- a/addons/explosives/XEH_postInit.sqf +++ b/addons/explosives/XEH_postInit.sqf @@ -17,6 +17,7 @@ //Event for setting explosive placement angle/pitch: [QGVAR(place), {_this call FUNC(setPosition)}] call EFUNC(common,addEventHandler); +[QGVAR(startDefuse), FUNC(startDefuse)] call EFUNC(common,addEventHandler); //When getting knocked out in medical, trigger deadman explosives: //Event is global, only run on server (ref: ace_medical_fnc_setUnconscious) diff --git a/addons/explosives/functions/fnc_startDefuse.sqf b/addons/explosives/functions/fnc_startDefuse.sqf index 84d7274069..ed5a419e3c 100644 --- a/addons/explosives/functions/fnc_startDefuse.sqf +++ b/addons/explosives/functions/fnc_startDefuse.sqf @@ -44,7 +44,7 @@ if (STANCE _unit == "Prone") then { if (ACE_player != _unit) then { // If the unit is a player, call the function on the player. if (isPlayer _unit) then { - [[_unit, _target], QFUNC(startDefuse), _unit] call EFUNC(common,execRemoteFnc); + [QGVAR(startDefuse), _unit, [_unit, _target]] call EFUNC(common,objectEvent); } else { _unit playActionNow _actionToPlay; _unit disableAI "MOVE"; diff --git a/addons/repair/XEH_postInit.sqf b/addons/repair/XEH_postInit.sqf index 44ca157b0c..a18e19fe37 100644 --- a/addons/repair/XEH_postInit.sqf +++ b/addons/repair/XEH_postInit.sqf @@ -5,3 +5,5 @@ // wheels ["setWheelHitPointDamage", {(_this select 0) setHitPointDamage [_this select 1, _this select 2]}] call EFUNC(common,addEventHandler); + +[QGVAR(useItem), EFUNC(common,useItem)] call EFUNC(common,addEventHandler); diff --git a/addons/repair/functions/fnc_useItem.sqf b/addons/repair/functions/fnc_useItem.sqf index 024ee76c29..c486ed50a0 100644 --- a/addons/repair/functions/fnc_useItem.sqf +++ b/addons/repair/functions/fnc_useItem.sqf @@ -20,7 +20,7 @@ params ["_unit", "_item"]; TRACE_2("params",_unit,_item); if ([_unit, _item] call EFUNC(common,hasItem)) exitWith { - [[_unit, _item], QUOTE(EFUNC(common,useItem)), _unit] call EFUNC(common,execRemoteFnc); /* TODO Replace by event system */ + [QGVAR(useItem), _unit, [_unit, _item]] call EFUNC(common,objectEvent); [true, _unit]; }; diff --git a/addons/respawn/XEH_postInit.sqf b/addons/respawn/XEH_postInit.sqf index 22be7b86ac..dc112b388e 100644 --- a/addons/respawn/XEH_postInit.sqf +++ b/addons/respawn/XEH_postInit.sqf @@ -3,3 +3,5 @@ ["rallypointMoved", {_this call FUNC(updateRallypoint)}] call EFUNC(common,addEventhandler); ["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); // hide enemy rallypoint markers + +[QGVAR(showFriendlyFireMessageEvent), DFUNC(showFriendlyFireMessage)] call EFUNC(common,addEventHandler); diff --git a/addons/respawn/functions/fnc_handleKilled.sqf b/addons/respawn/functions/fnc_handleKilled.sqf index 2b9509f39d..aa53c6741a 100644 --- a/addons/respawn/functions/fnc_handleKilled.sqf +++ b/addons/respawn/functions/fnc_handleKilled.sqf @@ -25,5 +25,5 @@ if (ACE_player == _unit && {GVAR(SavePreDeathGear)}) then { }; if (missionNamespace getVariable [QGVAR(showFriendlyFireMessage), false]) then { - [_this, QUOTE(DFUNC(showFriendlyFireMessage)), 2] call EFUNC(common,execRemoteFnc); + [QGVAR(showFriendlyFireMessageEvent), _this] call EFUNC(common,objectEvent); }; diff --git a/addons/spectator/XEH_postInit.sqf b/addons/spectator/XEH_postInit.sqf index 43c812d1a2..ea3e6a5510 100644 --- a/addons/spectator/XEH_postInit.sqf +++ b/addons/spectator/XEH_postInit.sqf @@ -27,3 +27,5 @@ if (isServer) then { [false] call FUNC(setSpectator); }; }] call EFUNC(common,addEventHandler); + +[QGVAR(stageSpectator), FUNC(stageSpectator)] call EFUNC(common,addEventHandler); diff --git a/addons/spectator/functions/fnc_respawnTemplate.sqf b/addons/spectator/functions/fnc_respawnTemplate.sqf index 4584a1fc3c..fde8ef05ad 100644 --- a/addons/spectator/functions/fnc_respawnTemplate.sqf +++ b/addons/spectator/functions/fnc_respawnTemplate.sqf @@ -23,7 +23,7 @@ private ["_vision","_pos"]; // When all are dead with respawn type "None" the mission should end if ((_respawn == 0) && {{alive _x} count allPlayers <= 0}) exitWith { - [["endDeath",false],"BIS_fnc_endMission"] call EFUNC(common,execRemoteFnc); + ["BIS_fnc_endMission", ["endDeath", false]] call EFUNC(common,globalEvent); }; // Some environment information can be used for the initial camera attributes diff --git a/addons/spectator/functions/fnc_stageSpectator.sqf b/addons/spectator/functions/fnc_stageSpectator.sqf index 926ac008dc..0b2caa2c70 100644 --- a/addons/spectator/functions/fnc_stageSpectator.sqf +++ b/addons/spectator/functions/fnc_stageSpectator.sqf @@ -27,7 +27,7 @@ params [["_unit",player,[objNull]], ["_set",true,[true]]]; if !(_set || (GETVAR(_unit,GVAR(isStaged),false))) exitWith {}; if !(local _unit) exitWith { - [[_unit, _set], QFUNC(stageSpectator), _unit] call EFUNC(common,execRemoteFnc); + [QGVAR(stageSpectator), _unit, [_unit, _set]] call EFUNC(common,objectEvent); }; // Prevent unit falling into water diff --git a/addons/switchunits/XEH_postInit.sqf b/addons/switchunits/XEH_postInit.sqf index 5928804d7b..d5020391e6 100644 --- a/addons/switchunits/XEH_postInit.sqf +++ b/addons/switchunits/XEH_postInit.sqf @@ -27,3 +27,11 @@ if (missionNamespace getVariable [QGVAR(EnableSwitchUnits), false]) then { }; }] call EFUNC(common,addEventhandler); }; + +if (isServer) then { + [QGVAR(switchLocality), { + params ["_unit", "_player"]; + _unit setVariable [QGVAR(OriginalOwner), owner _unit, true]; + _unit setOwner (owner _player); + }] call EFUNC(common,addEventHandler); +}; diff --git a/addons/switchunits/functions/fnc_switchUnit.sqf b/addons/switchunits/functions/fnc_switchUnit.sqf index a26b2d474a..64cc77c221 100644 --- a/addons/switchunits/functions/fnc_switchUnit.sqf +++ b/addons/switchunits/functions/fnc_switchUnit.sqf @@ -40,14 +40,7 @@ if (_leave) exitWith { // should switch locality // This doesn't work anymore, because one's now able to switch to units from a different side //[_unit] joinSilent group player; -[ - [_unit, player], - QUOTE({ - (_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; - (_this select 0) setOwner owner (_this select 1) - }), - 1 -] call EFUNC(common,execRemoteFnc); +[QGVAR(switchLocality), [_unit, player]] call EFUNC(common,serverEvent); [{ params ["_args", "_pfhId"]; @@ -79,12 +72,7 @@ if (_leave) exitWith { // set owner back to original owner private _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1]; if (_oldOwner > -1) then { - [ - [_oldUnit, _oldOwner], - QUOTE({ - (_this select 0) setOwner (_this select 1) - }), 1 - ] call EFUNC(common,execRemoteFnc); + ["setOwner", [_oldUnit, _oldOwner]] call EFUNC(common,serverEvent); }; [localize LSTRING(SwitchedUnit)] call EFUNC(common,displayTextStructured);