2015-09-18 05:42:10 +00:00
|
|
|
/*
|
|
|
|
* Author: jaynus
|
|
|
|
* Internal net event handler.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-13 23:27:42 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-09-18 05:42:10 +00:00
|
|
|
params ["_eventType", "_event"];
|
2015-01-13 23:27:42 +00:00
|
|
|
|
2015-05-14 18:02:42 +00:00
|
|
|
if (_eventType == "ACEg") then {
|
2015-09-18 05:42:10 +00:00
|
|
|
_event params ["_eventName", "_eventArgs"];
|
|
|
|
|
|
|
|
private ["_eventNames", "_eventIndex"];
|
2015-08-26 13:20:11 +00:00
|
|
|
|
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-09-18 05:42:10 +00:00
|
|
|
|
2015-05-14 18:02:42 +00:00
|
|
|
if (_eventIndex != -1) then {
|
2015-09-18 05:42:10 +00:00
|
|
|
private "_events";
|
2015-01-14 20:44:32 +00:00
|
|
|
_events = (GVAR(events) select 1) select _eventIndex;
|
2015-08-26 13:20:11 +00:00
|
|
|
|
2015-04-02 23:05:21 +00:00
|
|
|
#ifdef DEBUG_EVENTS
|
2015-08-26 15:39:44 +00:00
|
|
|
ACE_LOGINFO_1("* Net Event %1",_eventName);
|
|
|
|
ACE_LOGINFO_1(" args=%1",_eventArgs);
|
2015-04-02 23:05:21 +00:00
|
|
|
#endif
|
2015-08-26 13:20:11 +00:00
|
|
|
|
2015-01-13 23:27:42 +00:00
|
|
|
{
|
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));
|
2015-04-02 23:05:21 +00:00
|
|
|
#ifdef DEBUG_EVENTS_CALLSTACK
|
2015-08-26 15:39:44 +00:00
|
|
|
ACE_LOGINFO_1(" ID: %1",_forEachIndex);
|
2015-04-02 23:05:21 +00:00
|
|
|
#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-09-18 05:42:10 +00:00
|
|
|
_event params ["_eventName", "_eventTargets", "_eventArgs"];
|
|
|
|
|
|
|
|
private ["_sentEvents", "_owner", "_serverFlagged"];
|
2015-08-26 13:20:11 +00:00
|
|
|
|
2015-01-13 23:27:42 +00:00
|
|
|
_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
|
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
|
|
|
};
|
|
|
|
|
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-09-18 05:42:10 +00:00
|
|
|
_owner = owner _x;
|
2015-01-13 23:27:42 +00:00
|
|
|
};
|
2015-09-18 05:53:36 +00:00
|
|
|
if !(_owner in _sentEvents) then {
|
|
|
|
_sentEvents pushBack _owner;
|
2015-01-13 23:27:42 +00:00
|
|
|
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 {
|
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);
|
|
|
|
};
|
|
|
|
};
|
2015-09-20 20:29:38 +00:00
|
|
|
false
|
|
|
|
} count _eventTargets;
|
2015-01-13 23:27:42 +00:00
|
|
|
};
|
2015-08-26 13:20:11 +00:00
|
|
|
};
|