mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Common - Allow multiple events to clear a cached call (#9770)
This commit is contained in:
parent
1e1d1d63f2
commit
d6eb6b981c
@ -9,7 +9,7 @@
|
||||
* 2: Namespace to store the cache on <NAMESPACE>
|
||||
* 3: Cache uid <STRING>
|
||||
* 4: Max duration of the cache <NUMBER>
|
||||
* 5: Event that clears the cache (default: nil) <STRING>
|
||||
* 5: Events that clear the cache (default: nil) <STRING or ARRAY of STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Result of the function <ANY>
|
||||
@ -20,13 +20,18 @@
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_params", "_function", "_namespace", "_uid", "_duration", "_event"];
|
||||
params ["_params", "_function", "_namespace", "_uid", "_duration", "_events"];
|
||||
|
||||
if ((_namespace getVariable [_uid, [-99999]]) select 0 < diag_tickTime) then {
|
||||
_namespace setVariable [_uid, [diag_tickTime + _duration, _params call _function]];
|
||||
|
||||
// Does the cache need to be cleared on an event?
|
||||
if (!isNil "_event") then {
|
||||
if (!isNil "_events") then {
|
||||
if (_events isEqualType "") then {
|
||||
_events = [_events];
|
||||
};
|
||||
{
|
||||
private _event = _x;
|
||||
private _varName = format [QGVAR(clearCache_%1), _event];
|
||||
private _cacheList = missionNamespace getVariable _varName;
|
||||
|
||||
@ -52,9 +57,9 @@ if ((_namespace getVariable [_uid, [-99999]]) select 0 < diag_tickTime) then {
|
||||
missionNamespace setVariable [_varName, []];
|
||||
}] call CBA_fnc_addEventHandler;
|
||||
};
|
||||
|
||||
// Add this cache to the list of the event
|
||||
_cacheList pushBack [_namespace, _uid];
|
||||
} forEach _events;
|
||||
};
|
||||
|
||||
#ifdef DEBUG_MODE_FULL
|
||||
|
Loading…
Reference in New Issue
Block a user