forked from Bob-Murphy/A3-Antistasi-1.4
-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathfn_garrisonOpLoop.sqf
More file actions
48 lines (36 loc) · 1.56 KB
/
Copy pathfn_garrisonOpLoop.sqf
File metadata and controls
48 lines (36 loc) · 1.56 KB
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
/*
Garrison-local loop to process garrison ops sent by server.
Environment: Scheduled. Runs on server and HCs.
Arguments: None. Uses A3A_garrisonOps array as input.
Copyright 2025 John Jordan. All Rights Reserved.
Used and distributed by the Antistasi Community project with permission.
*/
// spawn only
// HC and server, client allowed for testing?
#include "..\..\script_component.hpp"
FIX_LINE_NUMBERS()
private _updateOps = ["updateStatics", "zoneCheck"];
private _spawnOps = ["spawn", "spawnCiv", "vehAction", "vehActionEnd", "changeSide"];
while {true} do
{
if (A3A_garrisonOps isEqualTo []) then { sleep 0.1; continue };
private _nextOp = A3A_garrisonOps deleteAt 0; // atomic on A3A_garrisonOps
_nextOp params ["_opType", "_params"];
if (_opType in _updateOps and {_nextOp in A3A_garrisonOps}) then {
Debug_2("Skipping %1 (%2) due to duplicates", _opType, _params);
continue;
};
if (!(_opType in _spawnOps) and !(_params#0 in A3A_activeGarrison)) then {
Error_2("Called garrison op %1 while %2 was not spawned", _opType, _params#0);
continue;
};
private _opFunc = missionNamespace getVariable ("A3A_fnc_garrisonLocal_" + _opType);
if (isNil "_opFunc") then {
Error_1("Operation %1 not found", _opType);
continue;
};
// Could just call here, but we protect against flaky code for now
// max 10 garrison ops per second should be plenty with the dupe skipping?
private _handle = _params spawn _opFunc;
waitUntil { sleep 0.1; isNull _handle };
};