ACE3/addons/common/functions/fnc__handleNetEvent.sqf

85 lines
2.4 KiB
Plaintext
Raw Normal View History

2015-09-18 05:42:10 +00:00
/*
* Author: jaynus
* Internal net event handler.
*
* Arguments:
* None
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
2015-09-18 05:42:10 +00:00
params ["_eventType", "_event"];
2015-05-14 18:02:42 +00:00
if (_eventType == "ACEg") then {
2015-09-18 05:42:10 +00:00
_event params ["_eventName", "_eventArgs"];
GVAR(events) params ["_eventNames"];
2015-09-18 05:42:10 +00:00
private _eventIndex = _eventNames find _eventName;
2015-09-18 05:42:10 +00:00
2015-05-14 18:02:42 +00:00
if (_eventIndex != -1) then {
private _events = (GVAR(events) select 1) select _eventIndex;
#ifdef DEBUG_EVENTS
2015-08-26 15:39:44 +00:00
ACE_LOGINFO_1("* Net Event %1",_eventName);
ACE_LOGINFO_1(" args=%1",_eventArgs);
#endif
{
2015-05-14 18:02:42 +00:00
if (!isNil "_x") then {
2015-09-16 00:26:37 +00:00
_eventArgs call CALLSTACK_NAMED(_x, FORMAT_2("Net Event %1 ID: %2",_eventName,_forEachIndex));
#ifdef DEBUG_EVENTS_CALLSTACK
2015-08-26 15:39:44 +00:00
ACE_LOGINFO_1(" ID: %1",_forEachIndex);
#endif
};
} forEach _events;
};
};
2015-05-14 18:02:42 +00:00
if (_eventType == "ACEc") then {
if (isServer) then {
2015-09-18 05:42:10 +00:00
_event params ["_eventName", "_eventTargets", "_eventArgs"];
private _sentEvents = [];
2015-05-14 18:02:42 +00:00
if (!IS_ARRAY(_eventTargets)) then {
_eventTargets = [_eventTargets];
};
2015-01-20 09:54:34 +00:00
//If not multiplayer, and there are targets, then just run localy
2015-09-18 05:53:36 +00:00
if (!isMultiplayer && {count _eventTargets > 0}) exitWith {
2015-09-18 05:42:10 +00:00
ACEg = [_eventName, _eventArgs];
["ACEg", ACEg] call FUNC(_handleNetEvent);
2015-01-20 09:54:34 +00:00
};
private _serverFlagged = false;
{
private _owner = _x;
2015-05-14 18:02:42 +00:00
if (IS_OBJECT(_x)) then {
2015-09-18 05:42:10 +00:00
_owner = owner _x;
};
2015-09-18 05:53:36 +00:00
if !(_owner in _sentEvents) then {
_sentEvents pushBack _owner;
ACEg = [_eventName, _eventArgs];
2015-09-18 05:53:36 +00:00
2015-05-14 18:02:42 +00:00
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);
};
};
2015-09-20 20:29:38 +00:00
false
} count _eventTargets;
};
};