forked from IDI-Systems/acre2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnc_clientIntentToGarbageCollect.sqf
56 lines (49 loc) · 2.06 KB
/
fnc_clientIntentToGarbageCollect.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "script_component.hpp"
/*
* Author: ACRE2Team
* Handles an intent to garbage collect message on the client side. Will create a PFH to monitor the local inventory and periodically send messages to the server to indiciate if the radio is still in use this will prevent it from being garbage collected.
*
* Arguments:
* 0: Radio ID <STRING>
*
* Return Value:
* None
*
* Example:
* ["acre_prc152_id_1"] call acre_sys_server_fnc_clientIntentToGarbageCollect
*
* Public: No
*/
params ["_radioId"];
_radioId = toLower _radioId;
private _radioList = ([] call EFUNC(sys_data,getPlayerRadioList)) apply {toLower _x};
if (_radioId in _radioList) then {
if (EGVAR(sys_core,arsenalOpen)) then {
TRACE_1("Server attempted garbage collect while open Arsenal",_radioId);
} else {
WARNING_1("Server attempted to garbage collect radio '%1' but it still exists locally.",_radioId);
};
// Send event to server - so it is logged to server RPT as well.
GVAR(radioGCWatchList) pushBackUnique _radioId;
if (GVAR(clientGCPFHID) == -1) then {
GVAR(clientGCPFHID) = [{
private _radioList = ([] call EFUNC(sys_data,getPlayerRadioList)) apply {toLower _x};
GVAR(radioGCWatchList) = GVAR(radioGCWatchList) select {
if !(_x in _radioList) then {
// Local player no longer has radio - send event to restart the GC process should another desynced player recieve it.
[QGVAR(removeGCQueue), [_x]] call CALLSTACK(CBA_fnc_serverEvent);
false;
} else {
true;
};
};
{
[QGVAR(stopRadioGarbageCollect), [acre_player, _x, EGVAR(sys_core,arsenalOpen)]] call CALLSTACK(CBA_fnc_serverEvent);
} forEach GVAR(radioGCWatchList);
if (GVAR(radioGCWatchList) isEqualTo []) then {
[_this select 1] call CBA_fnc_removePerFrameHandler;
GVAR(clientGCPFHID) = -1;
};
}, 10, []] call CBA_fnc_addPerFrameHandler;
};
};