2015-01-13 23:27:42 +00:00
|
|
|
//fnc__handleNetEvent.sqf
|
|
|
|
// internal handler for net events
|
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-05-14 22:12:40 +00:00
|
|
|
private ["_eventName", "_eventArgs", "_eventNames", "_eventIndex", "_eventTargets", "_sentEvents", "_owner", "_serverFlagged", "_events"];
|
|
|
|
//IGNORE_PRIVATE_WARNING("_handleNetEvent");
|
|
|
|
|
2015-01-13 23:27:42 +00:00
|
|
|
|
2015-05-14 18:02:42 +00:00
|
|
|
PARAMS_2(_eventType,_event);
|
2015-01-13 23:27:42 +00:00
|
|
|
|
2015-05-14 18:02:42 +00:00
|
|
|
if (_eventType == "ACEg") then {
|
2015-01-13 23:27:42 +00:00
|
|
|
_eventName = _event select 0;
|
|
|
|
_eventArgs = _event select 1;
|
|
|
|
|
2015-01-14 20:44:32 +00:00
|
|
|
_eventNames = GVAR(events) select 0;
|
2015-01-13 23:27:42 +00:00
|
|
|
_eventIndex = _eventNames find _eventName;
|
2015-05-14 18:02:42 +00:00
|
|
|
if (_eventIndex != -1) then {
|
2015-01-14 20:44:32 +00:00
|
|
|
_events = (GVAR(events) select 1) select _eventIndex;
|
2015-04-02 23:05:21 +00:00
|
|
|
|
|
|
|
#ifdef DEBUG_EVENTS
|
|
|
|
diag_log text format[ARR_2("* Net Event %1",_eventName)];
|
|
|
|
diag_log text format[ARR_2(" args=%1",_eventArgs)];
|
|
|
|
#endif
|
|
|
|
|
2015-01-13 23:27:42 +00:00
|
|
|
{
|
2015-05-14 18:02:42 +00:00
|
|
|
if (!isNil "_x") then {
|
2015-01-13 23:27:42 +00:00
|
|
|
_eventArgs call CALLSTACK_NAMED(_x, format[ARR_3("Net Event %1 ID: %2",_eventName,_forEachIndex)]);
|
2015-04-02 23:05:21 +00:00
|
|
|
#ifdef DEBUG_EVENTS_CALLSTACK
|
|
|
|
diag_log text format[ARR_2(" ID: %1",_forEachIndex)];
|
|
|
|
#endif
|
2015-01-13 23:27:42 +00:00
|
|
|
};
|
|
|
|
} forEach _events;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2015-05-14 18:02:42 +00:00
|
|
|
if (_eventType == "ACEc") then {
|
|
|
|
if (isServer) then {
|
2015-01-13 23:27:42 +00:00
|
|
|
_eventName = _event select 0;
|
|
|
|
_eventTargets = _event select 1;
|
|
|
|
_eventArgs = _event select 2;
|
|
|
|
|
|
|
|
_sentEvents = [];
|
2015-05-14 18:02:42 +00:00
|
|
|
if (!IS_ARRAY(_eventTargets)) then {
|
2015-01-13 23:27:42 +00:00
|
|
|
_eventTargets = [_eventTargets];
|
|
|
|
};
|
2015-01-20 09:54:34 +00:00
|
|
|
|
|
|
|
//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);
|
|
|
|
};
|
|
|
|
|
2015-01-13 23:27:42 +00:00
|
|
|
_serverFlagged = false;
|
|
|
|
{
|
|
|
|
_owner = _x;
|
2015-05-14 18:02:42 +00:00
|
|
|
if (IS_OBJECT(_x)) then {
|
2015-01-13 23:27:42 +00:00
|
|
|
_owner = owner _x;
|
|
|
|
};
|
2015-05-14 18:02:42 +00:00
|
|
|
if (!(_owner in _sentEvents)) then {
|
2015-01-13 23:27:42 +00:00
|
|
|
PUSH(_sentEvents, _owner);
|
|
|
|
ACEg = [_eventName, _eventArgs];
|
2015-05-14 18:02:42 +00:00
|
|
|
if (isDedicated || {_x != ACE_player}) then {
|
|
|
|
if (isDedicated && {local _x} && {!_serverFlagged}) then {
|
2015-01-13 23:27:42 +00:00
|
|
|
_serverFlagged = true;
|
|
|
|
["ACEg", ACEg] call FUNC(_handleNetEvent);
|
|
|
|
} else {
|
|
|
|
_owner publicVariableClient "ACEg";
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
["ACEg", ACEg] call FUNC(_handleNetEvent);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} forEach _eventTargets;
|
|
|
|
};
|
|
|
|
};
|