many changes. includes rework of baselocation-asset storage format

This commit is contained in:
2024-02-05 17:42:31 -08:00
parent f450f4611b
commit f588ffa4a0
32 changed files with 657 additions and 382 deletions

View File

@@ -17,32 +17,29 @@ private _allSaved = [];
private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase);
private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase);
private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg);
if (isNull _approvedAssetsCfg) exitWith {};
{
private _className = configName _x;
private _callsign = getText(_x >> "callsign");
private _found = _allVehicles select { typeOf _x == _className };
{
private _asset = _x;
// avoid duplicates
if (_asset in _allSaved) then {continue};
private _closestBase = [_asset] call EFUNC(util,getNearestBase);
if (isNull _closestBase) then {
// no base found
continue;
};
if (
_asset distance _closestBase >
milsim_fbcb2_assets_setting_detectionRangeFromBase
) then {
// not within range
continue;
};
_asset setVariable [QGVAR(callsign), _callsign, true];
if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue};
// add to base's assets list
private _closestBase = [_asset] call EFUNC(util,getNearestBase);
private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []];
_baseAssets pushBackUnique _asset;
_baseAssets pushBackUnique [
_asset call BIS_fnc_netId,
configOf _asset
];
// broadcast later so we're not spamming network
_closestBase setVariable [
_assetsAtThisBaseVar,
@@ -60,7 +57,7 @@ private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase);
_allSaved pushBack _asset;
} forEach _found;
} forEach ((missionConfigFile >> "ApprovedAssets") call BIS_fnc_returnChildren);
} forEach (_approvedAssetsCfg call BIS_fnc_returnChildren);
// Add all ground vehicles (LandVehicle)
{
@@ -68,23 +65,16 @@ private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase);
// avoid duplicates
if (_asset in _allSaved) then {continue};
private _closestBase = [_asset] call EFUNC(util,getNearestBase);
if (isNull _closestBase) then {
// no base found
continue;
};
if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue};
if (
_asset distance _closestBase >
GVAR(setting_detectionRangeFromBase)
) then {
// not within range
continue;
};
// add to base's assets list
private _closestBase = [_asset] call EFUNC(util,getNearestBase);
private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []];
_baseAssets pushBackUnique _asset;
_baseAssets pushBackUnique [
_asset call BIS_fnc_netId,
configOf _asset
];
// broadcast later so we're not spamming network
_closestBase setVariable [
_assetsAtThisBaseVar,
@@ -115,7 +105,7 @@ private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase);
if (_isInit) then {
_base setVariable [_assetsStartedAtThisBaseVar, _baseAssets, true];
};
} forEach milsim_baseObjects;
} forEach GVARMAIN(baseObjects);
////////////////////////////////////////////////////////////////////////
// log starting assets if init
@@ -131,14 +121,11 @@ if !(_isInit || _logCurrentAssets) exitWith {};
// prepare key value for logging
private _baseAssetsHashesPrep = _baseAssets apply {
private _asset = _x;
_x params ["_netId", "_cfg"];
[
["callsign", _asset getVariable [
QGVAR(callsign),
"N/A"
]],
["className", typeOf _asset],
["displayName", (configOf _asset) call BIS_fnc_displayName]
["callsign", [configName _cfg] call FUNC(getCallsignFromClassname)],
["className", configName _cfg],
["displayName", [_cfg] call BIS_fnc_displayName]
];
};
@@ -155,13 +142,13 @@ if !(_isInit || _logCurrentAssets) exitWith {};
if (_logCurrentAssets) then {
{
[
"fbcb2_assets",
QUOTE(COMPONENT),
"CURRENT ASSETS",
[
["baseName", [[_base] call milsim_util_fnc_getNameOfBase]],
["baseName", [[_base] call EFUNC(util,getNameOfBase)]],
["asset", _x]
]
] call milsim_util_fnc_log;
] call EFUNC(util,log);
} forEach _baseAssetsHashes;
};
@@ -172,10 +159,10 @@ if !(_isInit || _logCurrentAssets) exitWith {};
"fbcb2_assets",
"STARTING ASSETS",
[
["baseName", [[_base] call milsim_util_fnc_getNameOfBase]],
["baseName", [[_base] call EFUNC(util,getNameOfBase)]],
["asset", _x]
]
] call milsim_util_fnc_log;
] call EFUNC(util,log);
} forEach _baseAssetsHashes;
};
} forEach milsim_baseObjects;
} forEach GVARMAIN(baseObjects);