From f588ffa4a063588c5145b8de048d4e34c3506b90 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Mon, 5 Feb 2024 17:42:31 -0800 Subject: [PATCH] many changes. includes rework of baselocation-asset storage format --- defines/BattalionInfo.hpp | 4 +- description.ext | 7 +- framework/CfgFunctions.hpp | 270 +++++++++--------- framework/fbcb2/fn_hintFBCB2AssetStatus.sqf | 31 -- framework/fbcb2/fn_initFBCB2.sqf | 39 --- framework/fbcb2/util/fn_removeDiaryRecord.sqf | 0 .../functions/fn_addCBASettings.sqf | 12 +- .../functions/fn_getAssetsByBase.sqf | 6 +- .../functions/fn_getCallsignFromClassname.sqf | 15 + .../fn_getStartingAndCurrentAssets.sqf | 17 ++ .../functions/fn_getStartingAssetsByBase.sqf | 6 +- .../functions/fn_getVehicleData.sqf | 2 +- .../functions/fn_hintAllApprovedAssets.sqf | 93 ++++++ .../functions/fn_isAssetInRangeOfBase.sqf | 8 + .../functions/fn_removeAssetDiaryRecords.sqf | 8 +- .../functions/fn_removeMarkersOnMap.sqf | 11 +- .../functions/fn_showMarkersOnMap.sqf | 25 +- .../functions/fn_updateAssetDiary.sqf | 214 +++++++++----- .../functions/fn_updateAssetsByBase.sqf | 71 ++--- framework/fbcb2_main/functions/fn_init.sqf | 39 +++ .../functions}/fn_processFBCB2Environment.sqf | 20 +- .../fn_processFBCB2RadioFrequencies.sqf | 37 ++- .../functions}/fn_processFBCB2SmokeColors.sqf | 14 +- framework/fbcb2_main/script_component.hpp | 3 + .../util/fn_createOrUpdateDiaryRecord.sqf | 8 +- .../util}/fn_formatRadioElementForDiary.sqf | 6 +- .../fn_generateElementFrequencyRecordText.sqf | 31 +- framework/init/functions/fn_initServer.sqf | 2 +- framework/reinsert/script_component.hpp | 3 + .../resupply/functions/fn_addCBASettings.sqf | 8 +- .../functions/fn_getApprovedAssetsCfg.sqf | 14 + .../util/functions/fn_getBattalionCfg.sqf | 15 +- 32 files changed, 657 insertions(+), 382 deletions(-) delete mode 100644 framework/fbcb2/fn_hintFBCB2AssetStatus.sqf delete mode 100644 framework/fbcb2/fn_initFBCB2.sqf delete mode 100644 framework/fbcb2/util/fn_removeDiaryRecord.sqf create mode 100644 framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf create mode 100644 framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf create mode 100644 framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf create mode 100644 framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf create mode 100644 framework/fbcb2_main/functions/fn_init.sqf rename framework/{fbcb2 => fbcb2_main/functions}/fn_processFBCB2Environment.sqf (72%) rename framework/{fbcb2 => fbcb2_main/functions}/fn_processFBCB2RadioFrequencies.sqf (63%) rename framework/{fbcb2 => fbcb2_main/functions}/fn_processFBCB2SmokeColors.sqf (78%) create mode 100644 framework/fbcb2_main/script_component.hpp rename framework/{fbcb2 => fbcb2_main}/util/fn_createOrUpdateDiaryRecord.sqf (72%) rename framework/{fbcb2/radioFrequencies => fbcb2_main/util}/fn_formatRadioElementForDiary.sqf (91%) rename framework/{fbcb2/radioFrequencies => fbcb2_main/util}/fn_generateElementFrequencyRecordText.sqf (77%) create mode 100644 framework/reinsert/script_component.hpp create mode 100644 framework/util/functions/fn_getApprovedAssetsCfg.sqf diff --git a/defines/BattalionInfo.hpp b/defines/BattalionInfo.hpp index 52ab77a..58920bc 100644 --- a/defines/BattalionInfo.hpp +++ b/defines/BattalionInfo.hpp @@ -229,8 +229,8 @@ class BattalionInfo { }; }; - class Attack { - callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, ATTACK); + class Armor { + callsign = CALLSIGN_ELEMENT(ECHO_CALLSIGN, ARMOR); textColor = LVL4_TEXT_COLOR; frequencies[] = { {"Contact", {}, {FREQ_ECHO_GROUND, FREQ_ECHO_FLIGHT_CAS}}, diff --git a/description.ext b/description.ext index 558a08f..6355ab9 100644 --- a/description.ext +++ b/description.ext @@ -93,10 +93,9 @@ class Params }; -class cfgFunctions -{ - #include "framework\CfgFunctions.hpp" -}; +// CfgFunctions +#include "framework\CfgFunctions.hpp" + class CfgDebriefingSections { diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index 76ade6b..b2690ff 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -1,146 +1,158 @@ #include "script_mod.hpp" -class PREFIX -{ - class settings - { - file = "framework\settings"; - class setDefaults { postInit = 1; }; - class addCBASettings { postInit = 1; }; - class addAARChatHandler { postInit = 1; }; - class addRespawnChatHandler { postInit = 1; }; +class CfgFunctions { + class PREFIX + { + class settings + { + file = "framework\settings"; + class setDefaults { postInit = 1; }; + class addCBASettings { preInit = 1; }; + class addAARChatHandler { postInit = 1; }; + class addRespawnChatHandler { postInit = 1; }; + }; + + class init + { + file = "framework\init\functions"; + class initServer { postInit = 1;}; //needs refactor + class initPlayerLocal { postInit = 1;}; + }; + + class client { + file = "framework\client"; + class addZenModules { postInit = 1; }; + class addDNI_PlayerFPS { postInit = 1; }; // needs refactor + class bindEventHandlers { postInit = 1; }; + class bindVehicleActions { postInit = 1; }; + class addClientStatsPFH {}; + class addMedicalOverlayPFH { postInit = 1; }; + class calculateClientStats {}; + class bindEmptyGroupGarbageCleanup { postInit = 1; }; + }; + + class server { + file = "framework\server"; + class addServerStatsPFH {}; + class calculateServerStats {}; + class logPlayerInventory {}; + }; + + class ambience { + file = "framework\ambience"; + class flakInitVehicle {}; + class flakEH {}; + }; + + class map + { + file = "framework\map"; + class initMapCopy { postInit = 1; }; + class copyMapFromPlayer {}; //needs refactor + class getPlayerMapMarkers {}; //needs refactor + class loadMapMarkers {}; //needs refactor + class mapMarkerToString {}; //needs refactor + class stringToMapMarker {}; //needs refactor + }; }; - class init - { - file = "framework\init\functions"; - class initServer { postInit = 1;}; //needs refactor - class initPlayerLocal { postInit = 1;}; + + + class DOUBLES(PREFIX,fbcb2_assets) { + class functions { + file = "framework\fbcb2_assets\functions"; + class addCBASettings {preInit=1;}; + class initClient {postInit=1;}; + class initServer {postInit=1;}; + class getAssetsByBase {}; + class getInventory {}; + class getMagsForWeapon {}; + class getStartingAssetsByBase {}; + class getVehicleData {}; + class getWeaponry {}; + class hintAllApprovedAssets {}; + class removeAssetDiaryRecords {}; + class removeMarkersOnMap {}; + class showMarkersOnMap {}; + class updateAssetDiary {}; + class updateAssetsByBase {}; + class getCallsignFromClassname {}; + class getStartingAndCurrentAssets {}; + class isAssetInRangeOfBase {}; + }; }; - class fbcb2 { - file = "framework\fbcb2"; - class initFBCB2 { postInit = 1; }; - class processFBCB2RadioFrequencies {}; - class processFBCB2SmokeColors {}; - class processFBCB2Environment {}; - class hintFBCB2AssetStatus {}; - }; - class fbcb2_util { - file = "framework\fbcb2\util"; - class createOrUpdateDiaryRecord {}; - }; - class fbcb2_radioFrequencies { - file = "framework\fbcb2\radioFrequencies"; - class formatRadioElementForDiary {}; - class generateElementFrequencyRecordText {}; + class DOUBLES(PREFIX,fbcb2_main) { + class functions { + file = "framework\fbcb2_main\functions"; + class init { postInit = 1; }; + + class processFBCB2Environment {}; + class processFBCB2RadioFrequencies {}; + class processFBCB2SmokeColors {}; + }; + class util { + file = "framework\fbcb2_main\util"; + class createOrUpdateDiaryRecord {}; + class formatRadioElementForDiary {}; + class generateElementFrequencyRecordText {}; + }; }; - class client { - file = "framework\client"; - class addZenModules { postInit = 1; }; - class addDNI_PlayerFPS { postInit = 1; }; // needs refactor - class bindEventHandlers { postInit = 1; }; - class bindVehicleActions { postInit = 1; }; - class addClientStatsPFH {}; - class addMedicalOverlayPFH { postInit = 1; }; - class calculateClientStats {}; - class bindEmptyGroupGarbageCleanup { postInit = 1; }; + class DOUBLES(PREFIX,reinsert) { + class server { + file = "framework\reinsert\server"; + class initServer { postInit = 1; }; + class addToQueue {}; + class globalShowQueue {}; + class removeFromQueue {}; + class returnReinsertQueueNotification {}; + class validateQueue {}; + }; + class client { + file = "framework\reinsert\client"; + class initClient { postInit = 1; }; + class addAceSelfActions {}; + class addCheckQueueSelfAction {}; + class requestShowQueue {}; + }; }; - class server { - file = "framework\server"; - class addServerStatsPFH {}; - class calculateServerStats {}; - class logPlayerInventory {}; + class DOUBLES(PREFIX,resupply) { + class functions { + file = "framework\resupply\functions"; + class addCBASettings {preInit=1;}; + class init {postInit=1;}; + class createBox {}; + class getSupplyCratesCfg {}; + class addArsenalObjectSpawnBoxActions {}; + }; }; - class ambience { - file = "framework\ambience"; - class flakInitVehicle {}; - class flakEH {}; + class DOUBLES(PREFIX,util) { + class functions { + file = "framework\util\functions"; + class logMissionInfo { postInit = 1; }; + class addPlayerInfoToArray {}; + class log {}; + class padString {}; + class recurseSubclasses {}; + class getBattalionCfg {}; + class getNameOfBase {}; + class getNearestBase {}; + class getApprovedAssetsCfg {}; + }; }; - class map - { - file = "framework\map"; - class initMapCopy { postInit = 1; }; - class copyMapFromPlayer {}; //needs refactor - class getPlayerMapMarkers {}; //needs refactor - class loadMapMarkers {}; //needs refactor - class mapMarkerToString {}; //needs refactor - class stringToMapMarker {}; //needs refactor + class DOUBLES(PREFIX,vehicleFlags) { + class functions { + file = "framework\vehicleFlags\functions"; + class init {postInit=1;}; + class getActionsFlagCategories {}; + class getVehicleFlagsCfg {}; + class isClassExcluded {}; + }; }; -}; -class DOUBLES(PREFIX,util) { - class functions { - file = "framework\util\functions"; - class logMissionInfo { postInit = 1; }; - class addPlayerInfoToArray {}; - class log {}; - class padString {}; - class recurseSubclasses {}; - class getBattalionCfg {}; - class getNameOfBase {}; - class getNearestBase {}; - }; -}; - -class DOUBLES(PREFIX,resupply) { - class functions { - file = "framework\resupply\functions"; - class init {postInit=1;}; - class createBox {}; - class getSupplyCratesCfg {}; - class addArsenalObjectSpawnBoxActions {}; - class addCBASettings {postInit=1;}; - }; -}; - -class DOUBLES(PREFIX,fbcb2_assets) { - class functions { - file = "framework\fbcb2_assets\functions"; - class init {postInit=1;}; - class updateAssetDiary {}; - class removeAssetDiaryRecords {}; - class getMagsForWeapon {}; - class getWeaponry {}; - class getInventory {}; - class getVehicleData {}; - class getAssetsByBase {}; - class getStartingAssetsByBase {}; - class updateAssetsByBase {}; - class showMarkersOnMap {}; - class removeMarkersOnMap {}; - }; -}; - -class DOUBLES(PREFIX,vehicleFlags) { - class functions { - file = "framework\vehicleFlags\functions"; - class init {postInit=1;}; - class getActionsFlagCategories {}; - class getVehicleFlagsCfg {}; - class isClassExcluded {}; - }; -}; - -class DOUBLES(PREFIX,reinsert) { - class server { - file = "framework\reinsert\server"; - class initServer { postInit = 1; }; - class addToQueue {}; - class globalShowQueue {}; - class removeFromQueue {}; - class returnReinsertQueueNotification {}; - class validateQueue {}; - }; - class client { - file = "framework\reinsert\client"; - class initClient { postInit = 1; }; - class addAceSelfActions {}; - class addCheckQueueSelfAction {}; - class requestShowQueue {}; - }; + }; \ No newline at end of file diff --git a/framework/fbcb2/fn_hintFBCB2AssetStatus.sqf b/framework/fbcb2/fn_hintFBCB2AssetStatus.sqf deleted file mode 100644 index 6571a0b..0000000 --- a/framework/fbcb2/fn_hintFBCB2AssetStatus.sqf +++ /dev/null @@ -1,31 +0,0 @@ -_assetList = param [0, [objNull], [[objNull]]]; - -_text = parseText "MESSAGE"; -_text = composeText [_text, lineBreak ]; - -_text = composeText [_text, parseText "AssetAvailable", lineBreak ]; - -{ - _callSign = _x select 0; - _asset = _x select 1; - _assigned = _x select 2; - _available = 0; //count (getMarkerPos "respawn_west" nearEntities [ _asset, 2000] ); - - _homes = allMissionObjects "ModuleRespawnPosition_F"; - - { - _home = _x; - _available = _available + count( _home nearEntities [ _asset, 750] ); - } forEach _homes; - - - _image = getText(configFile >> "CfgVehicles" >> _asset >> "picture"); - - _name = getText(configFile >> "CfgVehicles" >> _asset >> "displayName") select [0, 24]; - _data = " " + _name + "" + str _available + " [ " + str _assigned +" ]"; - _text = composeText[ _text, parseText _data, lineBreak ]; - - -} foreach _assetList; - -hint _text; diff --git a/framework/fbcb2/fn_initFBCB2.sqf b/framework/fbcb2/fn_initFBCB2.sqf deleted file mode 100644 index 1f3e864..0000000 --- a/framework/fbcb2/fn_initFBCB2.sqf +++ /dev/null @@ -1,39 +0,0 @@ - -if ( !hasInterface ) exitWith {}; - -waitUntil { !isNil "milsim_complete" }; - -milsim_fbcb2_recordTitleColor = "#ff6666"; -milsim_fbcb2_recordTitleFont = "PuristaMedium"; -milsim_fbcb2_recordTitleSize = 20; - -milsim_fbcb2_recordTextHeaderSize = 16; -milsim_fbcb2_recordTextBodySize = 14; - -milsim_fbcb2_subjectStatusID = "FBCB2_Status"; -milsim_fbcb2_subjectIntelID = "FBCB2_Intel"; -milsim_fbcb2_subjectMessagesID = "FBCB2_Messages"; -milsim_fbcb2_subjectFrequenciesID = "FBCB2_Frequencies"; -milsim_fbcb2_subjectAssetsFixedWingID = "FBCB2_Assets_FixedWing"; -milsim_fbcb2_subjectAssetsRotaryID = "FBCB2_Assets_Rotary"; -milsim_fbcb2_subjectAssetsGroundID = "FBCB2_Assets_Ground"; - -player createDiarySubject[milsim_fbcb2_subjectStatusID, "FBCB2 - Status"]; -player createDiarySubject[milsim_fbcb2_subjectMessagesID, "FBCB2 - Messages"]; -player createDiarySubject[milsim_fbcb2_subjectIntelID, "FBCB2 - Intel"]; -player createDiarySubject[milsim_fbcb2_subjectFrequenciesID, "FBCB2 - Frequencies"]; -player createDiarySubject[milsim_fbcb2_subjectAssetsFixedWingID, "FBCB2 - Assets Plane"]; -player createDiarySubject[milsim_fbcb2_subjectAssetsRotaryID, "FBCB2 - Assets Rotary"]; -player createDiarySubject[milsim_fbcb2_subjectAssetsGroundID, "FBCB2 - Assets Ground"]; - -// store records in format: -// [subject, [ -// [title, diaryRecord] -// ]] -milsim_fbcb2_diaryRecords = createHashMap; - -// populate diary -[] call milsim_fnc_processFBCB2RadioFrequencies; -[] call milsim_fnc_processFBCB2SmokeColors; -[] call milsim_fnc_processFBCB2Environment; -[] call milsim_fbcb2_assets_fnc_updateAssetDiary; diff --git a/framework/fbcb2/util/fn_removeDiaryRecord.sqf b/framework/fbcb2/util/fn_removeDiaryRecord.sqf deleted file mode 100644 index e69de29..0000000 diff --git a/framework/fbcb2_assets/functions/fn_addCBASettings.sqf b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf index 5964caf..fe0e0fc 100644 --- a/framework/fbcb2_assets/functions/fn_addCBASettings.sqf +++ b/framework/fbcb2_assets/functions/fn_addCBASettings.sqf @@ -13,7 +13,7 @@ { params ["_value"]; [ - "fbcb2_assets", + QUOTE(COMPONENT), "SETTING CHANGED", [ [ @@ -22,6 +22,12 @@ ], ["newValue", _value] ] - ] call milsim_util_fnc_log; + ] call EFUNC(util,log); } -] call CBA_fnc_addSetting; \ No newline at end of file +] call CBA_fnc_addSetting; + +[ + QUOTE(COMPONENT), + "CREATED SETTINGS", + [] +] call EFUNC(util,log); \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf index 05dcd14..a42bc1c 100644 --- a/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf @@ -1,4 +1,6 @@ +#include "../script_component.hpp" + // return each base with its assets -milsim_baseObjects apply { - [_x, _x getVariable ["milsim_fbcb2_assets_assetsAtThisBase", []]] +GVARMAIN(baseObjects) apply { + [_x, _x getVariable [QGVAR(assetsAtThisBase), []]] }; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf b/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf new file mode 100644 index 0000000..866331c --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_getCallsignFromClassname.sqf @@ -0,0 +1,15 @@ +#include "..\script_component.hpp" + +params [ + ["_className", "", [""]] +]; + +// Get the approved assets config +private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +if (isNull _approvedAssetsCfg) exitWith {""}; + +// Get the asset definition +private _assetDef = (_approvedAssetsCfg >> _className); +if (isClass _assetDef) exitWith {getText(_assetDef >> "callsign")}; + +""; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf new file mode 100644 index 0000000..a939818 --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf @@ -0,0 +1,17 @@ +#include "..\script_component.hpp" + +// get all starting assets at each base and combine to array +private _startingAssetsByBase = call FUNC(getStartingAssetsByBase); +private _startingAssets = []; +{ + _startingAssets append (_x#1); +} forEach _startingAssetsByBase; + +// get all current assets at each base and combine to array +private _assetsByBase = call FUNC(getAssetsByBase); +private _assets = []; +{ + _assets append (_x#1); +} forEach _assetsByBase; + +[_startingAssets, _assets]; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf index 4c83db4..a0f082b 100644 --- a/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_getStartingAssetsByBase.sqf @@ -1,4 +1,6 @@ +#include "../script_component.hpp" + // return each base with its assets -milsim_baseObjects apply { - [_x, _x getVariable ["milsim_fbcb2_assets_assetsStartedAtThisBase", []]] +GVARMAIN(baseObjects) apply { + [_x, _x getVariable [QGVAR(assetsStartedAtThisBase), []]] }; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_getVehicleData.sqf b/framework/fbcb2_assets/functions/fn_getVehicleData.sqf index d7ba851..cf5d7b2 100644 --- a/framework/fbcb2_assets/functions/fn_getVehicleData.sqf +++ b/framework/fbcb2_assets/functions/fn_getVehicleData.sqf @@ -39,7 +39,7 @@ private _pylons = getAllPylonsInfo _vic; /////////////////////////////////////////////// // WRITE TITLE /////////////////////////////////////////////// -_title pushBack format["%1", _dispName]; +_title pushBack format["%1", _dispName]; /////////////////////////////////////////////// // WRITE IMAGE diff --git a/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf b/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf new file mode 100644 index 0000000..7a851fe --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_hintAllApprovedAssets.sqf @@ -0,0 +1,93 @@ +#include "..\script_component.hpp" + +// get vehicles the mission started with at base locations +(call FUNC(getStartingAndCurrentAssets)) params [ + "_startingAssets", + "_currentAssets" +]; + +// get distinct classnames to group by +private _distinctStartingAssetsClassNames = []; +{ + _x params ["_netId", "_cfg"]; + private _className = configName _cfg; + _distinctStartingAssetsClassNames pushBackUnique _className; +} forEach _startingAssets; + +// get the approved assets config to identify callsigns +private _approvedAssetsCfg = call EFUNC(util,getApprovedAssetsCfg); +if (isNull _approvedAssetsCfg) exitWith { + [ + QUOTE(COMPONENT), + "No approved assets defined.", + [] + ] call EFUNC(util,log); + [ + "ERROR: No approved assets defined. See defines/ApprovedAssets.hpp" + ] call BIS_fnc_error; +}; + +_text = parseText "MESSAGE"; +_text = composeText [_text, lineBreak ]; + +_text = composeText [_text, parseText "AssetAvailable", lineBreak ]; + +{ + private _className = _x; + // only approved assets + if (!isClass (_approvedAssetsCfg >> _className)) then {continue}; + + private _callsign = [_className] call FUNC(getCallsignFromClassname); + + private _startingAssetsOfThisType = _startingAssets select { + // select all starting assets of this type + _x params ["_netId", "_cfg"]; + _className isEqualTo (configName _cfg); + }; + private _currentAssetsOfThisType = _currentAssets select { + _x params ["_netId", "_cfg"]; + private _object = _netId call BIS_fnc_objectFromNetId; + // objNull if deleted, then check classname and if alive + !isNull _object && { + _className isEqualTo (typeOf _object) && + alive _object + }; + }; + + (_startingAssetsOfThisType#0) params [ + "_assetNetId", + "_assetCfg" + ]; + + _assigned = count _startingAssetsOfThisType; + _available = count _currentAssetsOfThisType; + // count (getMarkerPos "respawn_west" nearEntities [ _asset, 2000] ); + + + _image = getText(_assetCfg >> "picture"); + + _name = getText(_assetCfg >> "displayName") select [0, 22]; + private _data = format[ + " %2%3 [ %4 ]", + _image, + _name, + _available, + _assigned + ]; + + // private _data = format[ + // " + // %2 + // %3 + // %4", + // _image, + // _name, + // _assigned, + // _available + // ]; + _text = composeText[ _text, parseText _data, lineBreak ]; + + +} foreach _distinctStartingAssetsClassNames; + +hint _text; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf b/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf new file mode 100644 index 0000000..c858c14 --- /dev/null +++ b/framework/fbcb2_assets/functions/fn_isAssetInRangeOfBase.sqf @@ -0,0 +1,8 @@ +#include "..\script_component.hpp" + +params [["_asset", objNull, [objNull]]]; + +private _closestBase = [_asset] call EFUNC(util,getNearestBase); +if (isNull _closestBase) exitWith {false}; + +(_asset distance2D _closestBase) <= GVAR(setting_detectionRangeFromBase) \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf b/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf index 400cd7d..98f41eb 100644 --- a/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf +++ b/framework/fbcb2_assets/functions/fn_removeAssetDiaryRecords.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + if (!hasInterface) exitWith {}; { @@ -10,7 +12,7 @@ if (!hasInterface) exitWith {}; player removeDiaryRecord [_diarySubject, _diaryRecord]; } forEach _records; } forEach [ - milsim_fbcb2_subjectAssetsFixedWingID, - milsim_fbcb2_subjectAssetsRotaryID, - milsim_fbcb2_subjectAssetsGroundID + EGVAR(fbcb2_main,subjectAssetsFixedWingID), + EGVAR(fbcb2_main,subjectAssetsRotaryID), + EGVAR(fbcb2_main,subjectAssetsGroundID) ]; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf b/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf index ef6db27..ea6f78f 100644 --- a/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf +++ b/framework/fbcb2_assets/functions/fn_removeMarkersOnMap.sqf @@ -1,12 +1,11 @@ -private _baseMarkerStoreVar = "milsim_fbcb2_assets_baseMarkerStore"; -private _assetMarkerStoreVar = "milsim_fbcb2_assets_assetMarkerStore"; +#include "..\script_component.hpp" private _baseMarkerStore = localNamespace getVariable [ - _baseMarkerStoreVar, + QGVAR(baseMarkerStore), [] ]; private _assetMarkerStore = localNamespace getVariable [ - _assetMarkerStoreVar, + QGVAR(assetMarkerStore), [] ]; @@ -16,10 +15,10 @@ private _assetMarkerStore = localNamespace getVariable [ } forEach (_baseMarkerStore + _assetMarkerStore); localNamespace setVariable [ - _baseMarkerStoreVar, + QGVAR(baseMarkerStore), [] ]; localNamespace setVariable [ - _assetMarkerStoreVar, + QGVAR(assetMarkerStore), [] ]; diff --git a/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf b/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf index bb7bea4..265f0b6 100644 --- a/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf +++ b/framework/fbcb2_assets/functions/fn_showMarkersOnMap.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + params [ ["_className", "", [""]], ["_markerType", "hd_dot", [""]], @@ -12,11 +14,11 @@ if (count _markerColor isEqualTo 0) exitWith { ["No marker color provided!"] call BIS_fnc_error; }; if (count _assetObjects isEqualTo 0) exitWith { - ["No vehicles provided!"] call BIS_fnc_error; + ["No vehicles to draw markers for!"] call BIS_fnc_error; }; -private _baseMarkerStoreVar = "milsim_fbcb2_assets_baseMarkerStore"; -private _assetMarkerStoreVar = "milsim_fbcb2_assets_assetMarkerStore"; +private _baseMarkerStoreVar = QGVAR(baseMarkerStore); +private _assetMarkerStoreVar = QGVAR(assetMarkerStore); private _baseMarkerStore = localNamespace getVariable [ _baseMarkerStoreVar, @@ -35,15 +37,15 @@ if (not (count _baseMarkerStore > 0)) then { // create a circle marker with range as the detection range of assets _newMarker = createMarkerLocal [ - format["milsim_fbcb2_assets_base_marker_%1", _forEachIndex + 1], + format["%1_%2", QGVAR(baseCircleMarker), _forEachIndex + 1], getPosASL _base ]; _newMarker setMarkerTypeLocal "mil_dot"; _newMarker setMarkerColorLocal "ColorGreen"; _newMarker setMarkerShapeLocal "ELLIPSE"; _newMarker setMarkerSizeLocal [ - milsim_fbcb2_assets_setting_detectionRangeFromBase, - milsim_fbcb2_assets_setting_detectionRangeFromBase + GVAR(setting_detectionRangeFromBase), + GVAR(setting_detectionRangeFromBase) ]; _newMarker setMarkerAlphaLocal 0.5; _newMarker setMarkerTextLocal str(_forEachIndex + 1); @@ -55,19 +57,19 @@ if (not (count _baseMarkerStore > 0)) then { // create a flag marker at base position _newMarker = createMarkerLocal [ - format["milsim_fbcb2_assets_base_flag_marker_%1", _forEachIndex + 1], + format["%1_%2", QGVAR(baseFlagMarker), _forEachIndex + 1], getPosASL _base ]; _newMarker setMarkerTypeLocal "mil_flag"; _newMarker setMarkerColorLocal "ColorGreen"; _newMarker setMarkerSizeLocal [0.7, 0.7]; - _newMarker setMarkerTextLocal ([_base] call milsim_util_fnc_getNameOfBase); + _newMarker setMarkerTextLocal ([_base] call EFUNC(util,getNameOfBase)); _baseMarkerStore pushBack [ _base, _newMarker ]; - } forEach milsim_baseObjects; + } forEach GVARMAIN(baseObjects); localNamespace setVariable [_baseMarkerStoreVar, _baseMarkerStore]; }; @@ -85,9 +87,12 @@ private _start = (count _assetMarkerStore) + 1; > -1 ) then {continue}; + // check if the asset is within base detection range + if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; + // create a marker for the asset private _newMarker = createMarkerLocal [ - format["milsim_fbcb2_assets_marker_%1", _start], + format["%1_%2", QGVAR(assetMarker), _start], getPosASL _asset ]; _newMarker setMarkerAlphaLocal 1; diff --git a/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf index c96fab8..9d5cc7e 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetDiary.sqf @@ -10,101 +10,145 @@ call FUNC(removeMarkersOnMap); // remove existing asset records call FUNC(removeAssetDiaryRecords); -// get all vehicles by base -private _vehiclesByBase = call FUNC(getAssetsByBase); -if (count _vehiclesByBase isEqualTo 0) exitWith {false}; +(call FUNC(getStartingAndCurrentAssets)) params [ + "_startingAssets", + "_currentAssets" +]; -// put vehicles from each base into a single array -private _vehicles = []; -{ - _vehicles append (_x#1); -} forEach _vehiclesByBase; - -if (count _vehicles isEqualTo 0) exitWith {false}; +// get distinct vehicle class names private _distinctVehiclesClassNames = []; { - _distinctVehiclesClassNames pushBackUnique (typeOf _x); -} forEach _vehicles; + _x params ["_netId", "_cfg"]; + private _className = configName _cfg; + _distinctVehiclesClassNames pushBackUnique _className; +} forEach _startingAssets; +// for random color cycling +private _colorSelectionIndex = 0; +private _randomColors = [ + ["ColorRed", "#FF0000", "Red"], + ["ColorGreen", "#00FF00", "Green"], + ["ColorBlue", "#0000FF", "Blue"], + ["ColorYellow", "#FFFF00", "Yellow"], + ["ColorWhite", "#FFFFFF", "White"] +]; + // ForEach unique vehicle class name, we'll find the first and gather its info { private _className = _x; - private _vehiclesOfThisKind = _vehicles select {typeOf _x isEqualTo _className}; - // This should never happen, but... - if (count _vehiclesOfThisKind isEqualTo 0) then {continue}; - - // Take the first vehicle as a representative - private _representativeVehicle = _vehiclesOfThisKind#0; - private _vehicleCfg = configOf _representativeVehicle; private _vehicleCallsign = toUpper ( - _representativeVehicle getVariable [ - QGVAR(callsign), - "NONE ASSIGNED" - ] + [_className] call FUNC(getCallsignFromClassname) ); + // Get all starting assets of this type + private _startingAssetsOfThisType = _startingAssets select { + _x params ["_netId", "_cfg"]; + _className isEqualTo (configName _cfg); + }; + // Get all current assets of this type + private _currentAssetsOfThisType = _currentAssets select { + _x params ["_netId", "_cfg"]; + private _object = _netId call BIS_fnc_objectFromNetId; + // objNull if deleted, then check classname and if alive + !isNull _object && {_className isEqualTo (typeOf _object) && alive _object}; + }; + // This should never happen, but... + if (count _startingAssetsOfThisType isEqualTo 0) then {continue}; + + // Try to find a not null vehicle that can be processed + private _exampleVehicleToProcess = objNull; + private _assetCfg = configNull; + + private _exampleVehicleToProcessIndex = _startingAssetsOfThisType findIf { + _x params ["_netId", "_cfg"]; + !isNull (_netId call BIS_fnc_objectFromNetId); + }; + // If found, get the data + if (_exampleVehicleToProcessIndex > -1) then { + private _exampleData = _startingAssetsOfThisType select _exampleVehicleToProcessIndex; + _assetNetId = _exampleData#0; + _assetCfg = _exampleData#1; + _exampleVehicleToProcess = _assetNetId call BIS_fnc_objectFromNetId; + } else { + // otherwise, we only have the config to work with + private _exampleData = _startingAssetsOfThisType#0; + _assetCfg = _exampleData#1; + }; + + private _parentClassNames = [_assetCfg, true] call BIS_fnc_returnParents; + + + // Process the vehicle for extended info // Exclusion list for display names if ( - ((configOf _representativeVehicle) call BIS_fnc_displayName) + [_assetCfg] call BIS_fnc_displayName in ["Helicopter"] ) then {continue}; // Get the vehicle data - private _processed = [_representativeVehicle] call FUNC(getVehicleData); - - if (isNil "_processed") then {continue}; - _processed params ["_vehicleCfg", "_displayName", "_diaryTextSections"]; + private _processed = [configNull, "", []]; + if (!isNull _exampleVehicleToProcess) then { + _processed = [_exampleVehicleToProcess] call FUNC(getVehicleData); + }; + _processed params ["_processedVehicleCfg", "_displayName", "_diaryTextSections"]; _diaryTextSections params [ - "_title", - "_image", - "_info", - "_capacity" - // "_weapons", - // "_pylonWeapons", - // "_inventory" + ["_title", "", [""]], + ["_image", "", [""]], + ["_info", "", [""]], + ["_capacity", "", [""]] + // ["_weapons", "", [""]], + // ["_pylonWeapons", "", [""]], + // ["_inventory", "", [""]] ]; + // Get what we can from the vehicle cfg + // Create the diary record private _recordText = []; // Add the title and image - _recordText pushBack _title; + if (count _title isEqualTo 0) then { + _title = format["%1", [_assetCfg] call BIS_fnc_displayName]; + }; + _recordText pushBack format[ + "%1", + _title + ]; + if (count _image isEqualTo 0) then { + _image = format["", getText(_assetCfg >> 'editorPreview')]; + }; _recordText pushBack _image; _recordText pushBack "
"; _recordText pushBack format[ "CALLSIGN: %1", _vehicleCallsign ]; + _recordText pushBack format[ + "COUNT STARTED: %1", + count _startingAssetsOfThisType + ]; _recordText pushBack format[ "COUNT ACTIVE: %1", - count _vehiclesOfThisKind + count _currentAssetsOfThisType ]; // Here, we'll create a link to show markers on the map for all vehicles of this kind - private _randomColor = selectRandom [ - ["ColorRed", "#FF0000", "Red"], - ["ColorGreen", "#00FF00", "Green"], - ["ColorBlue", "#0000FF", "Blue"], - ["ColorYellow", "#FFFF00", "Yellow"], - ["ColorWhite", "#FFFFFF", "White"] - ]; - private _vehicleCfg = configFile >> "CfgVehicles" >> _className; // get 'picture' for record - private _icon = getText(_vehicleCfg >> "picture"); + private _icon = getText(_assetCfg >> "picture"); // determine marker type private _markerType = "mil_dot"; switch (true) do { - case (_representativeVehicle isKindOf "Helicopter"): { + case ("Helicopter" in _parentClassNames): { _markerType = "loc_heli"; }; - case (_representativeVehicle isKindOf "Air"): { + case ("Air" in _parentClassNames): { _markerType = "loc_plane"; }; - case (_representativeVehicle isKindOf "Ship"): { + case ("Ship" in _parentClassNames): { _markerType = "loc_boat"; }; - case (_representativeVehicle isKindOf "Car"): { + case ("Car" in _parentClassNames): { _markerType = "loc_car"; }; default { @@ -112,63 +156,92 @@ private _distinctVehiclesClassNames = []; }; }; + private "_randomColor"; + if (_colorSelectionIndex < count _randomColors) then { + _randomColor = _randomColors select _colorSelectionIndex; + INC(_colorSelectionIndex); + } else { + _colorSelectionIndex = 0; + _randomColor = _randomColors select _colorSelectionIndex; + }; + // Link to show markers private _showMarkersText = format[ - "SHOW MARKERS at vehicle positions (in %5)", + "SHOW MARKERS for vehicles at base (in %6)", _className, _markerType, _randomColor#0, - (_vehiclesOfThisKind apply { - format["%1", _x call BIS_fnc_netId] + (_currentAssetsOfThisType apply { + _x params ["_netId", "_cfg"]; + _netId; }), + QFUNC(showMarkersOnMap), format["%2", _randomColor#1, _randomColor#2] ]; _recordText pushBack _showMarkersText; // Link to hide markers - _recordText pushBack "REMOVE ALL MARKERS showing asset positions"; + _recordText pushBack format[ + "REMOVE ALL MARKERS showing asset positions", + QFUNC(removeMarkersOnMap) + ]; // Link to update asset diary entries - _recordText pushBack "UPDATE ENTRIES for all assets"; + _recordText pushBack format[ + "UPDATE ENTRIES for all assets", + QFUNC(updateAssetDiary) + ]; + + // link to display hint with all assets + _recordText pushBack format[ + "SHOW APPROVED ASSET COUNTS via hint", + QFUNC(hintAllApprovedAssets) + ]; _recordText pushBack format[ "%1", "Notes:
- Markers are only displayed on your local machine.
- The REMOVE ALL option will remove all assets' markers from the map.
- - UPDATE ENTRIES will update the asset diary with the latest information (~5 minutes at most)." + - UPDATE ENTRIES will update the asset diary with the latest information.
+ - Markers will only be displayed for assets that are within a certain distance of a base." ]; - // Add info and capacity sections - _recordText pushBack _info; - _recordText pushBack _capacity; + // Add info and capacity sections - exclude if no living examples were found + if (count _info > 0) then { + _recordText pushBack _info; + }; + if (count _capacity > 0) then { + _recordText pushBack _capacity; + }; private _subjectID = ""; switch (true) do { - case (_representativeVehicle isKindOf "Helicopter"): { - _subjectID = EGVAR(fbcb2,subjectAssetsRotaryID); + case ("Helicopter" in _parentClassNames): { + _subjectID = EGVAR(fbcb2_main,subjectAssetsRotaryID); }; - case (_representativeVehicle isKindOf "Air"): { - _subjectID = EGVAR(fbcb2,subjectAssetsFixedWingID); + case ("Air" in _parentClassNames): { + _subjectID = EGVAR(fbcb2_main,subjectAssetsFixedWingID); }; default { - _subjectID = EGVAR(fbcb2,subjectAssetsGroundID); + _subjectID = EGVAR(fbcb2_main,subjectAssetsGroundID); }; }; [ _subjectID, format[ - "%1x %2", - count _vehiclesOfThisKind, - (configOf _representativeVehicle) call BIS_fnc_displayName + "[%1/%2] %3", + count _currentAssetsOfThisType, + count _startingAssetsOfThisType, + (_assetCfg) call BIS_fnc_displayName ], _recordText joinString "
", _icon - ] call milsim_fnc_createOrUpdateDiaryRecord; + ] call EFUNC(fbcb2_main,createOrUpdateDiaryRecord); // "\A3\ui_f\data\igui\cfg\simpleTasks\types\car_ca.paa" } forEach _distinctVehiclesClassNames; @@ -178,8 +251,9 @@ private _distinctVehiclesClassNames = []; QUOTE(COMPONENT), "UPDATED ASSET DIARY", [ - ["assetCount", count _vehicles], - ["distinctAssetCount", count _distinctVehiclesClassNames] + ["startingAssetCount", count _startingAssets], + ["startingAssetCountDistinct", count _distinctVehiclesClassNames], + ["currentassetCount", count _currentAssets] ] ] call EFUNC(util,log); diff --git a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf index 23fdef5..c775bbe 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf @@ -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; \ No newline at end of file +} forEach GVARMAIN(baseObjects); \ No newline at end of file diff --git a/framework/fbcb2_main/functions/fn_init.sqf b/framework/fbcb2_main/functions/fn_init.sqf new file mode 100644 index 0000000..fe1f55f --- /dev/null +++ b/framework/fbcb2_main/functions/fn_init.sqf @@ -0,0 +1,39 @@ +#include "../script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +waitUntil { !isNil QGVARMAIN(complete) }; + +GVAR(recordTitleColor) = "#ff6666"; +GVAR(recordTitleFont) = "PuristaMedium"; +GVAR(recordTitleSize) = 20; + +GVAR(recordTextHeaderSize) = 16; +GVAR(recordTextBodySize) = 14; + +GVAR(subjectStatusID) = "FBCB2_Status"; +GVAR(subjectIntelID) = "FBCB2_Intel"; +GVAR(subjectMessagesID) = "FBCB2_Messages"; +GVAR(subjectFrequenciesID) = "FBCB2_Frequencies"; +GVAR(subjectAssetsFixedWingID) = "FBCB2_Assets_FixedWing"; +GVAR(subjectAssetsRotaryID) = "FBCB2_Assets_Rotary"; +GVAR(subjectAssetsGroundID) = "FBCB2_Assets_Ground"; + +player createDiarySubject[GVAR(subjectStatusID), "FBCB2 Status"]; +player createDiarySubject[GVAR(subjectMessagesID), "FBCB2 Messages"]; +player createDiarySubject[GVAR(subjectIntelID), "FBCB2 Intel"]; +player createDiarySubject[GVAR(subjectFrequenciesID), "FBCB2 Frequencies"]; +player createDiarySubject[GVAR(subjectAssetsFixedWingID), "FBCB2 Planes"]; +player createDiarySubject[GVAR(subjectAssetsRotaryID), "FBCB2 Helicopters"]; +player createDiarySubject[GVAR(subjectAssetsGroundID), "FBCB2 Ground"]; + +// store records in format: +// [subject, [ +// [title, diaryRecord] +// ]] +GVAR(diaryRecords) = createHashMap; + +// run main inits - assets handled in that component +[] call FUNC(processFBCB2RadioFrequencies); +[] call FUNC(processFBCB2SmokeColors); +[] call FUNC(processFBCB2Environment); \ No newline at end of file diff --git a/framework/fbcb2/fn_processFBCB2Environment.sqf b/framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf similarity index 72% rename from framework/fbcb2/fn_processFBCB2Environment.sqf rename to framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf index 91c8bac..1bc6612 100644 --- a/framework/fbcb2/fn_processFBCB2Environment.sqf +++ b/framework/fbcb2_main/functions/fn_processFBCB2Environment.sqf @@ -1,11 +1,13 @@ +#include "..\script_component.hpp" + private _recordTitle = "MDS - INTEL - ENVIRONMENT"; private _text = [ format[ "%4

", - milsim_fbcb2_recordTitleSize, - milsim_fbcb2_recordTitleColor, - milsim_fbcb2_recordTitleFont, + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), _recordTitle ] ]; @@ -19,9 +21,9 @@ private _sunTimes = date call BIS_fnc_sunriseSunsetTime; _text pushBack format[ "Local Sunrise
%5

", - milsim_fbcb2_recordTextHeaderSize, + GVAR(recordTextHeaderSize), _sunriseColor, - milsim_fbcb2_recordTextBodySize, + GVAR(recordTextBodySize), _whiteColor, ([_sunTimes select 0, "HH:MM"] call BIS_fnc_timeToString) ]; @@ -29,9 +31,9 @@ _text pushBack format[ _text pushBack format[ "Local Sunset
%5

", - milsim_fbcb2_recordTextHeaderSize, + GVAR(recordTextHeaderSize), _sunsetColor, - milsim_fbcb2_recordTextBodySize, + GVAR(recordTextBodySize), _whiteColor, ([_sunTimes select 1, "HH:MM"] call BIS_fnc_timeToString) ]; @@ -39,7 +41,7 @@ _text pushBack format[ _text = _text joinString ""; [ - milsim_fbcb2_subjectIntelID, + GVAR(subjectIntelID), _recordTitle, _text -] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file +] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf b/framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf similarity index 63% rename from framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf rename to framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf index 15e26eb..3a633da 100644 --- a/framework/fbcb2/fn_processFBCB2RadioFrequencies.sqf +++ b/framework/fbcb2_main/functions/fn_processFBCB2RadioFrequencies.sqf @@ -1,11 +1,28 @@ // updated 2024-02-01 by IndigoFox // now reads from the battalion config structure to generate the diary entries +#include "../script_component.hpp" + //////////////////////////////////////// // Get info from missionConfigFile //////////////////////////////////////// -private _battalionInfoCfg = call milsim_util_fnc_getBattalionCfg; +private _battalionInfoCfg = call EFUNC(util,getBattalionCfg); +if (isNull _battalionInfoCfg) exitWith { + [ + QUOTE(COMPONENT), + "Null Battalion Config", + [] + ] call EFUNC(util,log); +}; + private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; +if (count _battalionElementCfgs == 0) exitWith { + [ + QUOTE(COMPONENT), + "ERROR: No battalion elements found. Check that the battalion config is correctly structured. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.", + [] + ] call EFUNC(util,log); +}; //////////////////////////////////////// // Define formatting constants @@ -29,22 +46,28 @@ private _FREQ_TEXT_COLOR = "#CCCCCC"; reverse _battalionElementCfgs; { + diag_log text format[ + "[%1] <%2> Processing battalion element %3", + QUOTE(PREFIX), + _fnc_scriptName, + configName _x + ]; // recursively generate diary text for all child elements of battalion-level elements - private _diaryTitleText = [_x, true] call milsim_fnc_generateElementFrequencyRecordText; + private _diaryTitleText = [_x, true] call FUNC(generateElementFrequencyRecordText); [ - milsim_fbcb2_subjectFrequenciesID, + GVAR(subjectFrequenciesID), _diaryTitleText#0, _diaryTitleText#1 - ] call milsim_fnc_createOrUpdateDiaryRecord; + ] call FUNC(createOrUpdateDiaryRecord); } forEach _battalionElementCfgs; // add the battalion command to the top of the list // don't process child elements -private _diaryTitleText = [_battalionInfoCfg >> "Command", false] call milsim_fnc_generateElementFrequencyRecordText; +private _diaryTitleText = [_battalionInfoCfg >> "Command", false] call FUNC(generateElementFrequencyRecordText); [ - milsim_fbcb2_subjectFrequenciesID, + GVAR(subjectFrequenciesID), _diaryTitleText#0, _diaryTitleText#1 -] call milsim_fnc_createOrUpdateDiaryRecord; +] call FUNC(createOrUpdateDiaryRecord); true; \ No newline at end of file diff --git a/framework/fbcb2/fn_processFBCB2SmokeColors.sqf b/framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf similarity index 78% rename from framework/fbcb2/fn_processFBCB2SmokeColors.sqf rename to framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf index 1797d06..7622d46 100644 --- a/framework/fbcb2/fn_processFBCB2SmokeColors.sqf +++ b/framework/fbcb2_main/functions/fn_processFBCB2SmokeColors.sqf @@ -1,12 +1,14 @@ +#include "../script_component.hpp" + private _recordTitle = "MDS - INTEL - SMOKES"; private _text = [ // Title format[ "%4", - milsim_fbcb2_recordTitleSize, - milsim_fbcb2_recordTitleColor, - milsim_fbcb2_recordTitleFont, + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), _recordTitle ] ]; @@ -25,7 +27,7 @@ private _smokeColors = [ _x params ["_color", "_name", "_description"]; _text pushBack format[ "%3 - %4", - milsim_fbcb2_recordTextHeaderSize, + GVAR(recordTextHeaderSize), _color, _name, _description @@ -35,7 +37,7 @@ private _smokeColors = [ _text = _text joinString "

"; [ - milsim_fbcb2_subjectIntelID, + GVAR(subjectIntelID), _recordTitle, _text -] call milsim_fnc_createOrUpdateDiaryRecord; \ No newline at end of file +] call FUNC(createOrUpdateDiaryRecord); \ No newline at end of file diff --git a/framework/fbcb2_main/script_component.hpp b/framework/fbcb2_main/script_component.hpp new file mode 100644 index 0000000..ef7f377 --- /dev/null +++ b/framework/fbcb2_main/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT fbcb2_main +#define COMPONENT_BEAUTIFIED FBCB2 - Main +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf similarity index 72% rename from framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf rename to framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf index 6cd8330..e828493 100644 --- a/framework/fbcb2/util/fn_createOrUpdateDiaryRecord.sqf +++ b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf @@ -1,14 +1,16 @@ +#include "../script_component.hpp" + if (!hasInterface) exitWith {}; params [ - ["_subjectID", milsim_fbcb2_subjectStatusID, [""]], + ["_subjectID", GVAR(subjectStatusID), [""]], ["_recordTitle", "", [""]], ["_recordText", "", [""]], ["_recordIcon", "", [""]] ]; // Check if already created -private _subjectRecords = milsim_fbcb2_diaryRecords getOrDefault [_subjectID, createHashMap, true]; +private _subjectRecords = GVAR(diaryRecords) getOrDefault [_subjectID, createHashMap, true]; private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecordNull, true]; if (!isNull _existingRecord) then { @@ -24,5 +26,5 @@ if (!isNull _existingRecord) then { ] ]; _subjectRecords set [_recordTitle, _new]; - milsim_fbcb2_diaryRecords set [_subjectID, _subjectRecords]; + GVAR(diaryRecords) set [_subjectID, _subjectRecords]; }; \ No newline at end of file diff --git a/framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf b/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf similarity index 91% rename from framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf rename to framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf index fce0c35..223de2a 100644 --- a/framework/fbcb2/radioFrequencies/fn_formatRadioElementForDiary.sqf +++ b/framework/fbcb2_main/util/fn_formatRadioElementForDiary.sqf @@ -1,4 +1,6 @@ // called from milsim_fnc_processFBCB2RadioFrequencies +#include "../script_component.hpp" + params ["_cfg", ["_indentCount", 1, [5]]]; ////////////////////////////////////////////////////// @@ -62,8 +64,8 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - [_role, "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, - [_srStr, "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, + [_role, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), + [_srStr, "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), _lrStr ]; } forEach (getArray (_cfg >> "frequencies")); diff --git a/framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf similarity index 77% rename from framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf rename to framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf index b7a8986..ee57bbe 100644 --- a/framework/fbcb2/radioFrequencies/fn_generateElementFrequencyRecordText.sqf +++ b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf @@ -1,5 +1,8 @@ // called from milsim_fnc_processFBCB2RadioFrequencies ONLY // this function is called recursively to process all child elements of a battalion element in missionConfigFile + +#include "../script_component.hpp" + params [ ["_elementCfg", configNull, [configNull]], ["_shouldProcessChildCfgs", true] @@ -40,9 +43,9 @@ _freqLeadingSpace = _freqLeadingSpace joinString ""; private _headers = [ format[ "%4", - milsim_fbcb2_recordTitleSize, - milsim_fbcb2_recordTitleColor, - milsim_fbcb2_recordTitleFont, + GVAR(recordTitleSize), + GVAR(recordTitleColor), + GVAR(recordTitleFont), _recordTitle ], format[ @@ -51,8 +54,8 @@ private _headers = [ _ELEMENT_FREQ_SIZE, _ELEMENT_FREQ_FONT, _FREQ_TEXT_COLOR, - ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, - ["SR", "right", " ", _FREQ_PAD_LENGTH] call milsim_util_fnc_padString, + ["ROLE", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), + ["SR", "right", " ", _FREQ_PAD_LENGTH] call EFUNC(util,padString), "LR" ] ]; @@ -65,16 +68,28 @@ private _allText = []; // get all child elements recursively and format them if (_shouldProcessChildCfgs) then { + diag_log text format[ + "[%1] <%2> Processing %3", + QUOTE(PREFIX), + _fnc_scriptName, + configName _battalionElement + ]; [_battalionElement, { params ["_cfg", "_recurseCounter"]; // add config - private _lines = [_cfg, _recurseCounter+1] call milsim_fnc_formatRadioElementForDiary; + private _lines = [_cfg, _recurseCounter+1] call FUNC(formatRadioElementForDiary); // private _lines = [_cfg, _indentCount] call t; _allText pushBack (_lines joinString "
"); - }] call milsim_util_fnc_recurseSubclasses; + }] call EFUNC(util,recurseSubclasses); } else { + diag_log text format[ + "[%1] <%2> Processing %3", + QUOTE(PREFIX), + _fnc_scriptName, + configName _battalionElement + ]; // or if the param was false, just add the battalion element - private _lines = [_battalionElement, 1] call milsim_fnc_formatRadioElementForDiary; + private _lines = [_battalionElement, 1] call FUNC(formatRadioElementForDiary); // private _lines = [_cfg, _indentCount] call t; _allText pushBack (_lines joinString "
"); }; diff --git a/framework/init/functions/fn_initServer.sqf b/framework/init/functions/fn_initServer.sqf index 5ad0adf..2933428 100644 --- a/framework/init/functions/fn_initServer.sqf +++ b/framework/init/functions/fn_initServer.sqf @@ -2,7 +2,7 @@ if (!isServer) exitWith {}; -milsim_baseObjects = allMissionObjects "ModuleRespawnPosition_F"; +GVARMAIN(baseObjects) = allMissionObjects "ModuleRespawnPosition_F"; publicVariable "milsim_baseObjects"; // Initializes the Dynamic Groups framework and groups diff --git a/framework/reinsert/script_component.hpp b/framework/reinsert/script_component.hpp new file mode 100644 index 0000000..770e8d7 --- /dev/null +++ b/framework/reinsert/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT fbcb2_reinsert +#define COMPONENT_BEAUTIFIED FBCB2 - Reinsertion +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/resupply/functions/fn_addCBASettings.sqf b/framework/resupply/functions/fn_addCBASettings.sqf index ec8a7f1..898f60d 100644 --- a/framework/resupply/functions/fn_addCBASettings.sqf +++ b/framework/resupply/functions/fn_addCBASettings.sqf @@ -22,4 +22,10 @@ ] call EFUNC(util,log); }, true // requires mission restart -] call CBA_fnc_addSetting; \ No newline at end of file +] call CBA_fnc_addSetting; + +[ + QUOTE(COMPONENT), + "CREATED SETTINGS", + [] +] call EFUNC(util,log); \ No newline at end of file diff --git a/framework/util/functions/fn_getApprovedAssetsCfg.sqf b/framework/util/functions/fn_getApprovedAssetsCfg.sqf new file mode 100644 index 0000000..a3c8a09 --- /dev/null +++ b/framework/util/functions/fn_getApprovedAssetsCfg.sqf @@ -0,0 +1,14 @@ +#include "../script_component.hpp" + +private _approvedAssetsCfg = (missionConfigFile >> "ApprovedAssets"); + +if (!IS_CONFIG(_approvedAssetsCfg) || {!isClass _approvedAssetsCfg}) exitWith { + [ + QUOTE(COMPONENT), + "ERROR: Approved assets config not found. Check that the config is present and correctly named in the mission config file. See defines/ApprovedAssets.hpp and framework/util/functions/getApprovedAssetsCfg.sqf.", + [] + ] call EFUNC(util,log); + configNull; +}; + +_approvedAssetsCfg; \ No newline at end of file diff --git a/framework/util/functions/fn_getBattalionCfg.sqf b/framework/util/functions/fn_getBattalionCfg.sqf index b239a24..9286427 100644 --- a/framework/util/functions/fn_getBattalionCfg.sqf +++ b/framework/util/functions/fn_getBattalionCfg.sqf @@ -1 +1,14 @@ -(missionConfigFile >> "BattalionInfo") \ No newline at end of file +#include "../script_component.hpp" + +private _battalionInfoCfg = (missionConfigFile >> "BattalionInfo"); + +if (!IS_CONFIG(_battalionInfoCfg) || {!isClass _battalionInfoCfg}) exitWith { + [ + QUOTE(COMPONENT), + "ERROR: Battalion config not found. Check that the battalion config is present and correctly named in the mission config file. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf.", + [] + ] call EFUNC(util,log); + configNull; +}; + +_battalionInfoCfg; \ No newline at end of file