diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 3dea56a98d..971d6cc722 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -235,7 +235,6 @@ PREP(dumpPerformanceCounters); PREP(dumpArray); PREP(globalEvent); -PREP(_handleNetEvent); PREP(addEventHandler); PREP(objectEvent); PREP(targetEvent); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 88012a7884..86a86918e4 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -173,10 +173,6 @@ if (isServer) then { // Set up remote execution ////////////////////////////////////////////////// -// ACE events -"ACEg" addPublicVariableEventHandler {_this call FUNC(_handleNetEvent)}; -"ACEc" addPublicVariableEventHandler {_this call FUNC(_handleNetEvent)}; - // Synced ACE events // Handle JIP scenario if (!isServer) then { diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index dea4e64538..8b16777781 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -5,10 +5,6 @@ ADDON = false; #include "XEH_PREP.hpp" -//ACE events global variables -GVAR(eventsLocation) = createLocation ["ACE_HashLocation", [-10000,-10000,-10000], 0, 0]; -GVAR(eventsLocation) setText QGVAR(eventsLocation); - // backwards comp DFUNC(canUseWeapon) = { ACE_DEPRECATED("ace_common_fnc_canUseWeapon","3.7.0","CBA_fnc_canUseWeapon"); diff --git a/addons/common/functions/fnc__handleNetEvent.sqf b/addons/common/functions/fnc__handleNetEvent.sqf deleted file mode 100644 index 54cef66228..0000000000 --- a/addons/common/functions/fnc__handleNetEvent.sqf +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Author: jaynus - * Internal net event handler. - * - * Arguments: - * None - * - * Return Value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -params ["_eventType", "_event"]; - -if (_eventType == "ACEg") then { - _event params ["_eventName", "_eventArgs"]; - - private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - if (!isNil "_eventFunctions") then { - - #ifdef DEBUG_EVENTS - ACE_LOGINFO_1("* Net Event %1",_eventName); - ACE_LOGINFO_1(" args=%1",_eventArgs); - #endif - - { - if (!isNil "_x") then { - _eventArgs call CALLSTACK_NAMED(_x, FORMAT_2("Net Event %1 ID: %2",_eventName,_forEachIndex)); - #ifdef DEBUG_EVENTS_CALLSTACK - ACE_LOGINFO_1(" ID: %1",_forEachIndex); - #endif - }; - } forEach _eventFunctions; - }; -}; - -if (_eventType == "ACEc") then { - if (isServer) then { - _event params ["_eventName", "_eventTargets", "_eventArgs"]; - - private _sentEvents = []; - - if (!IS_ARRAY(_eventTargets)) then { - _eventTargets = [_eventTargets]; - }; - - //If not multiplayer, and there are targets, then just run localy - if (!isMultiplayer && {count _eventTargets > 0}) exitWith { - ACEg = [_eventName, _eventArgs]; - ["ACEg", ACEg] call FUNC(_handleNetEvent); - }; - - private _serverFlagged = false; - - { - private _owner = _x; - - if (IS_OBJECT(_x)) then { - _owner = owner _x; - }; - if !(_owner in _sentEvents) then { - _sentEvents pushBack _owner; - ACEg = [_eventName, _eventArgs]; - - if (isDedicated || {_x != ACE_player}) then { - if (isDedicated && {local _x} && {!_serverFlagged}) then { - _serverFlagged = true; - ["ACEg", ACEg] call FUNC(_handleNetEvent); - } else { - _owner publicVariableClient "ACEg"; - }; - } else { - ["ACEg", ACEg] call FUNC(_handleNetEvent); - }; - }; - false - } count _eventTargets; - }; -}; diff --git a/addons/common/functions/fnc_addEventHandler.sqf b/addons/common/functions/fnc_addEventHandler.sqf index e7df00f5ff..4f285dd449 100644 --- a/addons/common/functions/fnc_addEventHandler.sqf +++ b/addons/common/functions/fnc_addEventHandler.sqf @@ -1,25 +1,5 @@ -/* - * Author: Nou - * Add an event handler. - * - * Arguments: - * 0: Event name - * 1: Event code - * - * Return Value: - * Event handler ID number (for use with fnc_removeEventHandler) - * - * Public: Yes - */ #include "script_component.hpp" -params ["_eventName", "_eventCode"]; +_this call CBA_fnc_addEventHandler; -private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - -if (isNil "_eventFunctions") then { - _eventFunctions = []; - GVAR(eventsLocation) setVariable [_eventName, _eventFunctions]; -}; - -_eventFunctions pushBack _eventCode // Return event function count +ACE_DEPRECATED("ace_common_fnc_addEventHandler","3.8.0","CBA_fnc_addEventHandler"); diff --git a/addons/common/functions/fnc_globalEvent.sqf b/addons/common/functions/fnc_globalEvent.sqf index 126419b553..cbd586c39c 100644 --- a/addons/common/functions/fnc_globalEvent.sqf +++ b/addons/common/functions/fnc_globalEvent.sqf @@ -1,21 +1,5 @@ -/* - * Author: Nou - * Execute a global event on all clients, including self. - * - * Arguments: - * 0: Event name - * 1: Event args - * - * Return Value: - * None - * - * Public: Yes - */ #include "script_component.hpp" -params ["_eventName", "_eventArgs"]; +_this call CBA_fnc_globalEvent; -ACEg = [_eventName, _eventArgs]; -publicVariable "ACEg"; - -["ACEg", ACEg] call FUNC(_handleNetEvent); +ACE_DEPRECATED("ace_common_fnc_globalEvent","3.8.0","CBA_fnc_globalEvent"); diff --git a/addons/common/functions/fnc_localEvent.sqf b/addons/common/functions/fnc_localEvent.sqf index bf17cc0d0e..84b0aa4898 100644 --- a/addons/common/functions/fnc_localEvent.sqf +++ b/addons/common/functions/fnc_localEvent.sqf @@ -1,36 +1,5 @@ -/* - * Author: Nou - * Execute a local event on this client only. - * - * Arguments: - * 0: Event name (string) - * 1: Event args (any) - * - * Return Value: - * None - * - * Public: No - */ #include "script_component.hpp" -params ["_eventName", "_eventArgs"]; +_this call CBA_fnc_localEvent; -private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - -if (!isNil "_eventFunctions") then { - - #ifdef DEBUG_EVENTS - ACE_LOGINFO_1("* Local Event: %1",_eventName); - ACE_LOGINFO_1(" args=%1",_eventArgs); - #endif - - { - if (!isNil "_x") then { - _eventArgs call CALLSTACK_NAMED(_x,FORMAT_2("Local Event %1 ID: %2",_eventName,_forEachIndex)); - - #ifdef DEBUG_EVENTS_CALLSTACK - ACE_LOGINFO_1(" ID: %1",_forEachIndex); - #endif - }; - } forEach _eventFunctions; -}; +ACE_DEPRECATED("ace_common_fnc_localEvent","3.8.0","CBA_fnc_localEvent"); diff --git a/addons/common/functions/fnc_objectEvent.sqf b/addons/common/functions/fnc_objectEvent.sqf index 2015ad77dc..ed9029df65 100644 --- a/addons/common/functions/fnc_objectEvent.sqf +++ b/addons/common/functions/fnc_objectEvent.sqf @@ -1,34 +1,7 @@ -/* - * Author: PabstMirror - * Execute an event where object is local. - * If local there is no network traffic/delay (Unlike targetEvent) - * - * Arguments: - * 0: Event name (STRING) - * 1: Event target - * 2: Event args - * - * Return Value: - * None - * - * Example: - * ["doThing", vehicle player, []] call ace_common_fnc_objectEvent - * - * Public: Yes - */ #include "script_component.hpp" params ["_eventName", "_eventTarget", "_eventArgs"]; -#ifdef DEBUG_EVENTS - ACE_LOGINFO_2("* Object Event: %1 - %2",_eventName,_eventTarget); - ACE_LOGINFO_1(" args=%1",_eventArgs); -#endif +[_eventName, _eventArgs, _eventTargets] call CBA_fnc_targetEvent; -if (local _eventTarget) then { - [_eventName, _eventArgs] call FUNC(localEvent); -} else { - _this call FUNC(targetEvent); -}; - -nil +ACE_DEPRECATED("ace_common_fnc_objectEvent","3.8.0","CBA_fnc_targetEvent"); diff --git a/addons/common/functions/fnc_removeAllEventHandlers.sqf b/addons/common/functions/fnc_removeAllEventHandlers.sqf index ed1cce278c..ca4db8db0a 100644 --- a/addons/common/functions/fnc_removeAllEventHandlers.sqf +++ b/addons/common/functions/fnc_removeAllEventHandlers.sqf @@ -1,17 +1,8 @@ -/* - * Author: Nou - * Remove all events of a certain event type. - * - * Argument: - * 0: Event name - * - * Return Value: - * None - * - * Public: Yes - */ #include "script_component.hpp" params ["_eventName"]; -GVAR(eventsLocation) setVariable [_eventName, nil]; +CBA_events_eventNamespace setVariable [_eventName,nil]; +CBA_events_eventHashes setVariable [_eventName,nil]; + +ACE_DEPRECATED("ace_common_fnc_removeAllEventHandlers","3.8.0","N/A (remove events individually w/ CBA_fnc_removeEventHandler)"); diff --git a/addons/common/functions/fnc_removeEventHandler.sqf b/addons/common/functions/fnc_removeEventHandler.sqf index a0b5ed5333..b241aae833 100644 --- a/addons/common/functions/fnc_removeEventHandler.sqf +++ b/addons/common/functions/fnc_removeEventHandler.sqf @@ -1,23 +1,5 @@ -/* - * Author: Nou - * Remove an event handler. - * - * Argument: - * 0: Event name - * 1: Event code - * - * Return Value: - * None - * - * Public: Yes - */ #include "script_component.hpp" -params ["_eventName", "_eventCodeIndex"]; +_this call CBA_fnc_removeEventHandler; -private _eventFunctions = GVAR(eventsLocation) getVariable _eventName; - -if (isNil "_eventFunctions") exitWith {TRACE_1("eventName not found",_eventName);}; -if ((_eventCodeIndex < 0) || {(count _eventFunctions) <= _eventCodeIndex}) exitWith {TRACE_2("index out of bounds",_eventName,_eventCodeIndex);}; - -_eventFunctions set [_eventCodeIndex, nil]; +ACE_DEPRECATED("ace_common_fnc_removeEventHandler","3.8.0","CBA_fnc_removeEventHandler"); diff --git a/addons/common/functions/fnc_serverEvent.sqf b/addons/common/functions/fnc_serverEvent.sqf index 65ab0da2a7..7fbb3d21a6 100644 --- a/addons/common/functions/fnc_serverEvent.sqf +++ b/addons/common/functions/fnc_serverEvent.sqf @@ -1,29 +1,5 @@ -/* - * Author: Nou - * Execute a event only on the server. - * - * Argument: - * 0: Event name - * 1: Event args - * - * Return Value: - * None - * - * Public: Yes - */ #include "script_component.hpp" -params ["_eventName", "_eventArgs"]; +_this call CBA_fnc_serverEvent; -#ifdef DEBUG_EVENTS - ACE_LOGINFO_1("* Server Event: %1",_eventName); - ACE_LOGINFO_1(" args=%1",_eventArgs); -#endif - -ACEg = [_eventName, _eventArgs]; - -if (!isServer) then { - publicVariableServer "ACEg"; -} else { - ["ACEg", ACEg] call FUNC(_handleNetEvent); -}; +ACE_DEPRECATED("ace_common_fnc_serverEvent","3.8.0","CBA_fnc_serverEvent"); diff --git a/addons/common/functions/fnc_targetEvent.sqf b/addons/common/functions/fnc_targetEvent.sqf index b9802f0835..e78f193370 100644 --- a/addons/common/functions/fnc_targetEvent.sqf +++ b/addons/common/functions/fnc_targetEvent.sqf @@ -1,33 +1,7 @@ -/* - * Author: Nou - * Execute a event only on specific clients. - * - * Arguments: - * 0: Event name (STRING) - * 1: Event targets - * 2: Event args - * - * Note: If local executor is in list of targets, event will execute with - * network delay, and not immediatly. - * - * Return Value: - * None - * - * Public: Yes - */ #include "script_component.hpp" params ["_eventName", "_eventTargets", "_eventArgs"]; -#ifdef DEBUG_EVENTS - ACE_LOGINFO_2("* Target Event: %1 - %2",_eventName,_eventTargets); - ACE_LOGINFO_1(" args=%1",_eventArgs); -#endif +[_eventName,_eventArgs,_eventTargets] call CBA_fnc_targetEvent; -ACEc = [_eventName, _eventTargets, _eventArgs]; - -if (!isServer) then { - publicVariableServer "ACEc"; -} else { - ["ACEc", ACEc] call FUNC(_handleNetEvent); -}; +ACE_DEPRECATED("ace_common_fnc_targetEvent","3.8.0","CBA_fnc_targetEvent"); diff --git a/addons/common/tests/script_component.hpp b/addons/common/tests/script_component.hpp deleted file mode 100644 index 6a1bf9154d..0000000000 --- a/addons/common/tests/script_component.hpp +++ /dev/null @@ -1 +0,0 @@ -#include "\z\ace\addons\common\script_component.hpp" diff --git a/addons/common/tests/test_eventHandlers.sqf b/addons/common/tests/test_eventHandlers.sqf deleted file mode 100644 index 5a75cb0a06..0000000000 --- a/addons/common/tests/test_eventHandlers.sqf +++ /dev/null @@ -1,78 +0,0 @@ -// ---------------------------------------------------------------------------- -#define DEBUG_MODE_FULL -#include "script_component.hpp" - -#ifndef TEST_DEFINED_AND_OP -if (true) exitWith {}; -#endif - -// ---------------------------------------------------------------------------- - -LOG('Testing EventHandlers'); - -TEST_DEFINED(QFUNC(_handleNetEvent),""); -TEST_DEFINED(QFUNC(addEventHandler),""); -TEST_DEFINED(QFUNC(localEvent),""); -TEST_DEFINED(QFUNC(targetEvent),""); -TEST_DEFINED(QFUNC(globalEvent),""); -TEST_DEFINED(QFUNC(serverEvent),""); -TEST_DEFINED(QFUNC(removeAllEventHandlers),""); -TEST_DEFINED(QFUNC(removeEventHandler),""); - -private _result = ["A", {}] call ace_common_fnc_addEventHandler; -private _expected = 0; -TEST_DEFINED_AND_OP(_result,==,_expected,"Adding first A EH"); - -_result = ["A", {GVAR(test_A2) = _this}] call ace_common_fnc_addEventHandler; -_expected = 1; -TEST_DEFINED_AND_OP(_result,==,_expected,"Adding second A EH"); - -_result = ["A", {GVAR(test_A3) = _this}] call ace_common_fnc_addEventHandler; -_expected = 2; -TEST_DEFINED_AND_OP(_result,==,_expected,"Adding third A EH"); - -GVAR(test_A2) = -1; -["A", 11] call FUNC(localEvent); -_expected = 11; -_result = GVAR(test_A2); -TEST_DEFINED_AND_OP(_result,==,_expected,"Test Local Event"); - -//Remove 2nd EH -["A", 1] call FUNC(removeEventHandler); - -GVAR(test_A2) = -1; -GVAR(test_A3) = -1; -["A", 22] call FUNC(localEvent); -_expected = -1; -_result = GVAR(test_A2); -TEST_DEFINED_AND_OP(_result,==,_expected,"Test 2nd (removed) EH"); -_expected = 22; -_result = GVAR(test_A3); -TEST_DEFINED_AND_OP(_result,==,_expected,"Test 3rd Event"); - -//Remove All EH: -["A"] call FUNC(removeAllEventHandlers); - -GVAR(test_A3) = -1; -["A", 77] call FUNC(localEvent); -_expected = -1; -_result = GVAR(test_A3); -TEST_DEFINED_AND_OP(_result,==,_expected,"Test 3rd is removed after removeAll"); - -//Much harder to test network events -TRACE_2("testing network events",isServer,isDedicated); - -["B", {GVAR(test_B) = _this}] call ace_common_fnc_addEventHandler; - -GVAR(test_B) = -1; -["B", 33] call FUNC(globalEvent); -_expected = 33; -_result = GVAR(test_B); -TEST_DEFINED_AND_OP(_result,==,_expected,"Test globalEvent"); - -GVAR(test_B) = -1; -["B", 44] call FUNC(serverEvent); -_expected = if (isServer) then {44} else {-1}; -_result = GVAR(test_B); -TEST_DEFINED_AND_OP(_result,==,_expected,"Test serverEvent"); -