From 91b982e06eacf2b7a4124e8993a68e8b2b1aebb8 Mon Sep 17 00:00:00 2001 From: IndigoFox Date: Tue, 6 Feb 2024 17:36:01 -0800 Subject: [PATCH] ready for dedi -- improvements to resupply, triageIcons too --- framework/CfgFunctions.hpp | 63 +++++--- .../functions/fn_addMedicalOverlayPFH.sqf | 99 ------------- .../fn_bindEmptyGroupGarbageCleanup.sqf | 26 +++- .../client/functions/fn_bindEventHandlers.sqf | 6 +- .../functions/fn_bindVehicleActions.sqf | 2 +- .../common/functions/fn_addCBASettings.sqf | 23 --- .../functions/fn_addPlayerInfoToArray.sqf | 4 +- ...entory.sqf => fn_checkPlayerInventory.sqf} | 4 +- framework/common/functions/fn_log.sqf | 8 +- .../common/functions/fn_logMissionInfo.sqf | 1 + ...Base.sqf => fn_getCurrentAssetsByBase.sqf} | 0 .../fn_getStartingAndCurrentAssets.sqf | 2 +- .../fbcb2_assets/functions/fn_initClient.sqf | 20 ++- .../fbcb2_assets/functions/fn_initServer.sqf | 2 - .../functions/fn_updateAssetsByBase.sqf | 65 +++------ .../functions/fn_addFrequenciesRecord.sqf | 14 +- .../{fn_init.sqf => fn_initClient.sqf} | 8 +- .../util/fn_createOrUpdateDiaryRecord.sqf | 23 ++- .../fn_generateElementFrequencyRecordText.sqf | 3 +- .../init/functions/fn_addAARChatHandler.sqf | 2 + framework/init/functions/fn_initClient.sqf | 34 +++++ .../init/functions/fn_initPlayerLocal.sqf | 23 --- framework/init/functions/fn_initServer.sqf | 27 ++-- .../functions/fn_addCBASettings.sqf | 2 +- .../functions/fn_calculateClientStats.sqf | 31 ++-- .../functions/fn_calculateServerStats.sqf | 36 ++++- .../reinsert/functions/fn_addCBASettings.sqf | 34 ++--- .../reinsert/server/fn_globalShowQueue.sqf | 2 +- .../reinsert/server/fn_removeFromQueue.sqf | 33 +++-- .../fn_returnReinsertQueueNotification.sqf | 10 +- .../reinsert/server/fn_validateQueue.sqf | 25 ++-- .../fn_addArsenalObjectSpawnBoxActions.sqf | 21 ++- .../resupply/functions/fn_addCBASettings.sqf | 4 + framework/resupply/functions/fn_init.sqf | 12 -- .../resupply/functions/fn_initClient.sqf | 13 ++ framework/script_mod.hpp | 4 +- framework/server/script_component.hpp | 3 - .../functions/fn_addCBASettings.sqf | 138 ++++++++++++++++++ .../functions/fn_addDrawIconsPFH.sqf | 62 ++++++++ .../functions/fn_addGetEntitiesPFH.sqf | 18 +++ .../triageIcons/functions/fn_initClient.sqf | 12 ++ .../triageIcons/functions/fn_updateColors.sqf | 18 +++ framework/triageIcons/script_component.hpp | 3 + .../{fn_init.sqf => fn_initClient.sqf} | 0 44 files changed, 586 insertions(+), 354 deletions(-) delete mode 100644 framework/client/functions/fn_addMedicalOverlayPFH.sqf rename framework/common/functions/{fn_logPlayerInventory.sqf => fn_checkPlayerInventory.sqf} (97%) rename framework/fbcb2_assets/functions/{fn_getAssetsByBase.sqf => fn_getCurrentAssetsByBase.sqf} (100%) rename framework/fbcb2_main/functions/{fn_init.sqf => fn_initClient.sqf} (92%) create mode 100644 framework/init/functions/fn_initClient.sqf delete mode 100644 framework/init/functions/fn_initPlayerLocal.sqf delete mode 100644 framework/resupply/functions/fn_init.sqf create mode 100644 framework/resupply/functions/fn_initClient.sqf delete mode 100644 framework/server/script_component.hpp create mode 100644 framework/triageIcons/functions/fn_addCBASettings.sqf create mode 100644 framework/triageIcons/functions/fn_addDrawIconsPFH.sqf create mode 100644 framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf create mode 100644 framework/triageIcons/functions/fn_initClient.sqf create mode 100644 framework/triageIcons/functions/fn_updateColors.sqf create mode 100644 framework/triageIcons/script_component.hpp rename framework/vehicleFlags/functions/{fn_init.sqf => fn_initClient.sqf} (100%) diff --git a/framework/CfgFunctions.hpp b/framework/CfgFunctions.hpp index 57a566e..d9e5f96 100644 --- a/framework/CfgFunctions.hpp +++ b/framework/CfgFunctions.hpp @@ -1,6 +1,19 @@ #include "script_mod.hpp" class CfgFunctions { + + class DOUBLES(PREFIX,init) { + class functions { + file = "framework\init\functions"; + class initServer { postInit = 1;}; + class initClient { postInit = 1;}; + class setDefaults { postInit = 1; }; + class addAARChatHandler { postInit = 1; }; + class addRespawnChatHandler { postInit = 1; }; + }; + }; + + class PREFIX { class ambience { file = "framework\ambience"; @@ -22,7 +35,6 @@ class CfgFunctions { class DOUBLES(PREFIX,client) { class functions { file = "framework\client\functions"; - class addMedicalOverlayPFH { postInit = 1; }; class addZenModules { postInit = 1; }; class bindEmptyGroupGarbageCleanup { postInit = 1; }; class bindEventHandlers { postInit = 1; }; @@ -35,14 +47,14 @@ class CfgFunctions { class functions { file = "framework\common\functions"; class addCBASettings { preInit = 1; }; - class logMissionInfo { postInit = 1; }; + class logMissionInfo {}; class addPlayerInfoToArray {}; class getApprovedAssetsCfg {}; class getBattalionCfg {}; class getNameOfBase {}; class getNearestBase {}; class log {}; - class logPlayerInventory {}; + class checkPlayerInventory {}; class logSettingChanged {}; class padString {}; class recurseSubclasses {}; @@ -53,30 +65,30 @@ class CfgFunctions { class functions { file = "framework\fbcb2_assets\functions"; class addCBASettings {preInit=1;}; - class initClient {postInit=1;}; - class initServer {postInit=1;}; - class getAssetsByBase {}; + class initServer {}; + class initClient {}; + class getCallsignFromClassname {}; + class getCurrentAssetsByBase {}; class getInventory {}; class getMagsForWeapon {}; + class getStartingAndCurrentAssets {}; class getStartingAssetsByBase {}; class getVehicleData {}; class getWeaponry {}; class hintAllApprovedAssets {}; + class isAssetInRangeOfBase {}; class removeAssetDiaryRecords {}; class removeMarkersOnMap {}; class showMarkersOnMap {}; class updateAssetDiary {}; class updateAssetsByBase {}; - class getCallsignFromClassname {}; - class getStartingAndCurrentAssets {}; - class isAssetInRangeOfBase {}; }; }; class DOUBLES(PREFIX,fbcb2_main) { class functions { file = "framework\fbcb2_main\functions"; - class init { postInit = 1; }; + class initClient {}; class addEnvironmentRecord {}; class addFrequenciesRecord {}; class addSignalColorsRecord {}; @@ -89,21 +101,13 @@ class CfgFunctions { }; }; - class DOUBLES(PREFIX,init) { - file = "framework\init\functions"; - class addAARChatHandler { postInit = 1; }; - class addRespawnChatHandler { postInit = 1; }; - class initServer { postInit = 1;}; - class initPlayerLocal { postInit = 1;}; - class setDefaults { postInit = 1; }; - }; - class DOUBLES(PREFIX,performance) { class functions { file = "framework\performance\functions"; class addCBASettings {preInit=1;}; - class init {postInit=1;}; class addDNI_PlayerFPS { postInit = 1; }; + + // PFHs managed in addCBASettings onChange code class addClientStatsPFH {}; class calculateClientStats {}; class addServerStatsPFH {}; @@ -118,7 +122,7 @@ class CfgFunctions { }; class server { file = "framework\reinsert\server"; - class initServer { postInit = 1; }; + class initServer {}; class addToQueue {}; class globalShowQueue {}; class removeFromQueue {}; @@ -127,7 +131,7 @@ class CfgFunctions { }; class client { file = "framework\reinsert\client"; - class initClient { postInit = 1; }; + class initClient {}; class addAceSelfActions {}; class addCheckQueueSelfAction {}; class requestShowQueue {}; @@ -138,17 +142,28 @@ class CfgFunctions { class functions { file = "framework\resupply\functions"; class addCBASettings {preInit=1;}; - class init {postInit=1;}; + class initClient {}; class createBox {}; class getSupplyCratesCfg {}; class addArsenalObjectSpawnBoxActions {}; }; }; + class DOUBLES(PREFIX,triageIcons) { + class functions { + file = "framework\triageIcons\functions"; + class addCBASettings {preInit=1;}; + class initClient {}; + class addDrawIconsPFH {}; + class addGetEntitiesPFH {}; + class updateColors {}; + }; + }; + class DOUBLES(PREFIX,vehicleFlags) { class functions { file = "framework\vehicleFlags\functions"; - class init {postInit=1;}; + class initClient {}; class getActionsFlagCategories {}; class getVehicleFlagsCfg {}; class isClassExcluded {}; diff --git a/framework/client/functions/fn_addMedicalOverlayPFH.sqf b/framework/client/functions/fn_addMedicalOverlayPFH.sqf deleted file mode 100644 index bf3d6b3..0000000 --- a/framework/client/functions/fn_addMedicalOverlayPFH.sqf +++ /dev/null @@ -1,99 +0,0 @@ -/* - -milsim_fnc_addMedicalOverlayPFH - -Author: IndigoFox - -Description: - Affects players with medical permissions. Will see a 3D colored dot over nearby (5-10m) - unconscious players who are not in a vehicle - which indicates their current ACE Triage Card status. - Designed to increase efficiency of CCPs. - -*/ - -// Force setting if CBA doesn't work? -if (isNil "milsim_client_medState3D_enabled") then { - milsim_client_medState3D_enabled = true; -}; -if (isNil "milsim_client_medState3D_drawRange") then { - milsim_client_medState3D_drawRange = 10; -}; - -// List of units to draw icons for -milsim_client_medState3D_drawTargets = []; - -// ACE Triage colors, for consistency across UIs and functions -// #define TRIAGE_COLOR_NONE 0.5, 0.5, 0.5, 0.1 -// #define TRIAGE_COLOR_MINIMAL 0, 0.5, 0, 0.9 -// #define TRIAGE_COLOR_DELAYED 1, 0.84, 0, 0.9 -// #define TRIAGE_COLOR_IMMEDIATE 1, 0, 0, 0.9 -// #define TRIAGE_COLOR_DECEASED 0, 0, 0, 0.9 - -// ACE Triage colors, for consistency across UIs and functions -milsim_client_medState3D_colors = [ - [0, 0.5, 0, 0.9], // TRIAGE_COLOR_MINIMAL - [1, 0.84, 0, 0.9], // TRIAGE_COLOR_DELAYED - [1, 0, 0, 0.9], // TRIAGE_COLOR_IMMEDIATE - [0.15, 0.15, 0.15, 0.9], // TRIAGE_COLOR_DECEASED - [0.5, 0.5, 0.5, 0] // TRIAGE_COLOR_NONE -]; - -// Per-frame handler to draw icons -// cleanup -if (!isNil "milsim_client_medState3D_pfh") then { - [milsim_client_medState3D_pfh] call CBA_fnc_removePerFrameHandler; -}; -// add pfh -milsim_client_medState3D_pfh = [{ - // if disabled, skip processing - if (!milsim_client_medState3D_enabled) exitWith {false}; - // if no targets, skip processing - if (count milsim_client_medState3D_drawTargets == 0) exitWith {false}; - if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {false}; - { - // distance within 10 meters - if (player distance _x > milsim_client_medState3D_drawRange) then {continue}; - // check unit not null, not conscious, and not in a vehicle - if ( - !(_x getVariable ["ACE_isUnconscious", false]) || - !isNull (objectParent _x) - ) then {continue}; - - // color based on triage level - private _triageLevel = _x getVariable ["ace_medical_triageLevel", -1]; - if (_triageLevel == -1) then {continue}; - private _color = milsim_client_medState3D_colors select ( - (_x getVariable ["ace_medical_triageLevel", -1]) -1 - ); - // draw position, slightly above the prone unit - private _drawPos = (visiblePosition _x) vectorAdd [0, 0, 0.5]; - // draw icon - drawIcon3D [ - "\A3\ui_f\data\map\markers\military\dot_CA.paa", // icon texture - _color, // color - _drawPos, // position AGL - 1, // width - 1, // height - 0 // angle - // further params optional, omitted - ]; - } forEach milsim_client_medState3D_drawTargets; -}, 0, []] call CBA_fnc_addPerFrameHandler; - -// subroutine to gather nearest 50 units every 5 seconds and store in milsim_client_medState3D_drawTargets -// cleanup -if (!isNil "milsim_client_medState3D_drawTargetsPfh") then { - [milsim_client_medState3D_drawTargetsPfh] call CBA_fnc_removePerFrameHandler; -}; -// add pfh -milsim_client_medState3D_drawTargetsPfh = [{ - milsim_client_medState3D_drawTargets = ( - (allUnits + allDeadMen) select { - _x isKindOf "CAManBase" && - player distance _x < 50 && - !isNull _x && - player isNotEqualTo _x - } - ); -}, 5, false] call CBA_fnc_addPerFrameHandler; diff --git a/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf b/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf index 7cb7771..4833821 100644 --- a/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf +++ b/framework/client/functions/fn_bindEmptyGroupGarbageCleanup.sqf @@ -1,4 +1,11 @@ -diag_log text format ["[MILSIM] (client) initializing empty group deletion PFH"]; +#include "..\script_component.hpp" + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "Initializing empty group deletion PFH", + [] +] call EFUNC(common,log); _emptyGroupPFH = [ { @@ -12,8 +19,21 @@ _emptyGroupPFH = [ }, 300, [], - { diag_log text format ["[MILSIM] (client) Empty Group Deletion PFH loaded"] }, - { diag_log text format ["[MILSIM] (client) Empty Group Deletion"] }, + { + [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Empty group deletion PFH loaded", + [] + ] call EFUNC(common,log); + }, + { [ + LEVEL_INFO, + QUOTE(COMPONENT), + "Empty group deletion PFH unloaded", + [] + ] call EFUNC(common,log); + }, { true }, { false }, [] diff --git a/framework/client/functions/fn_bindEventHandlers.sqf b/framework/client/functions/fn_bindEventHandlers.sqf index ed2ee97..802c2c5 100644 --- a/framework/client/functions/fn_bindEventHandlers.sqf +++ b/framework/client/functions/fn_bindEventHandlers.sqf @@ -8,7 +8,7 @@ player addEventHandler["Respawn", private _killer = _corpse getVariable ["ace_medical_causeOfDeath", "#scripted"]; if (_killer == "respawn_button") then { [ - LEVEL_INFO + LEVEL_INFO, QUOTE(COMPONENT), "RESPAWNED WHILE UNCONSCIOUS", [_unit] call EFUNC(common,addPlayerInfoToArray) @@ -46,11 +46,11 @@ addMissionEventHandler ["HandleChatMessage", ["ace_arsenal_displayClosed", { - [player] remoteExec [QEFUNC(common,logPlayerInventory), 2]; + [player] remoteExec [QEFUNC(common,checkPlayerInventory), 2]; }] call CBA_fnc_addEventHandler; [missionNamespace, "arsenalClosed", { - [player] remoteExec [QEFUNC(common,logPlayerInventory), 2]; + [player] remoteExec [QEFUNC(common,checkPlayerInventory), 2]; }] call BIS_fnc_addScriptedEventHandler; diag_log text "[MILSIM] (client) event handlers bound"; diff --git a/framework/client/functions/fn_bindVehicleActions.sqf b/framework/client/functions/fn_bindVehicleActions.sqf index ccf502f..6947457 100644 --- a/framework/client/functions/fn_bindVehicleActions.sqf +++ b/framework/client/functions/fn_bindVehicleActions.sqf @@ -56,7 +56,7 @@ _patchTire = "Patching" ] call ace_common_fnc_progressBar }, - { ( alive _target ) && ( [_player, "ToolKit"] call ace_common_fnc_hasItem ) && ( getDammage _target > 0.2 ) && ( _target getVariable["milsim_ace_repair_wheel_canPatch", true] ) } + { ( alive _target ) && ( [_player, "ToolKit"] call ace_common_fnc_hasItem ) && ( damage _target > 0.2 ) && ( _target getVariable["milsim_ace_repair_wheel_canPatch", true] ) } ] call ace_interact_menu_fnc_createAction; ["ACE_Wheel", 0, ["ACE_MainActions"], _patchTire, true] call ace_interact_menu_fnc_addActionToClass; diff --git a/framework/common/functions/fn_addCBASettings.sqf b/framework/common/functions/fn_addCBASettings.sqf index 9457034..700f1ae 100644 --- a/framework/common/functions/fn_addCBASettings.sqf +++ b/framework/common/functions/fn_addCBASettings.sqf @@ -22,29 +22,6 @@ [QGVARMAIN(sideChat), false] call CBA_settings_fnc_set; - -//--------------------- -// Medical Overlay -//--------------------- - -[ - "milsim_client_medState3D_enabled", // variable - "CHECKBOX", // type - ["Enable 3D Triage Card State", "Draws a colored dot over units within 10m indicating current ACE Triage State"], // title - ["17th Battalion", "Medical"], // category - true // default value -] call CBA_fnc_addSetting; - -[ - "milsim_client_medState3D_drawRange", // variable - "LIST", // type - ["Range To Draw Icons", "Determines range at which dots are visible"], // title - ["17th Battalion", "Medical"], // category - [[2, 4, 6, 8, 10], ["2", "4", "6", "8", "10"], 4] // option values, option labels, default index -] call CBA_fnc_addSetting; - - - diag_log text "[MILSIM] (settings) Custom CBA settings initialized"; nil; \ No newline at end of file diff --git a/framework/common/functions/fn_addPlayerInfoToArray.sqf b/framework/common/functions/fn_addPlayerInfoToArray.sqf index 3035094..353410c 100644 --- a/framework/common/functions/fn_addPlayerInfoToArray.sqf +++ b/framework/common/functions/fn_addPlayerInfoToArray.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" -params [["_playerObj", objNull], ["_arrayToModify", [], [[]]]]; +params [["_playerObj", objNull, [nil, objNull]], ["_arrayToModify", [], [[]]]]; if (isNull _playerObj) exitWith {_arrayToModify}; @@ -10,7 +10,7 @@ if (isNull _playerObj) exitWith {_arrayToModify}; ["playerName", name _playerObj], ["playerUID", getPlayerUID _playerObj], ["playerGroup", groupId (group _playerObj)], - ["playerNetID", [_playerObj] call BIS_fnc_netId] + ["playerNetID", _playerObj call BIS_fnc_netId] ]; _arrayToModify; \ No newline at end of file diff --git a/framework/common/functions/fn_logPlayerInventory.sqf b/framework/common/functions/fn_checkPlayerInventory.sqf similarity index 97% rename from framework/common/functions/fn_logPlayerInventory.sqf rename to framework/common/functions/fn_checkPlayerInventory.sqf index 97951de..14874ae 100644 --- a/framework/common/functions/fn_logPlayerInventory.sqf +++ b/framework/common/functions/fn_checkPlayerInventory.sqf @@ -1,5 +1,5 @@ /* - Function: milsim_util_fnc_logPlayerInventory + Function: milsim_common_fnc_checkPlayerInventory Description: Checks a player's inventory for non-compliant items and logs results to all machines. @@ -21,7 +21,7 @@ params [ if (!isPlayer _player) exitWith { [ - LEVEL_ERROR + LEVEL_ERROR, QUOTE(COMPONENT), "PARAM PLAYER IS NOT A PLAYER", [["player", _player]] diff --git a/framework/common/functions/fn_log.sqf b/framework/common/functions/fn_log.sqf index 975633c..716c0df 100644 --- a/framework/common/functions/fn_log.sqf +++ b/framework/common/functions/fn_log.sqf @@ -1,5 +1,5 @@ /* - Function: milsim_util_fnc_log + Function: milsim_common_fnc_log Description: Used to log messages to the server RPT file. @@ -19,13 +19,13 @@ params [ ["_data", [], [[]]] ]; -if (_logLevel < LOG_LEVEL) exitWith {}; +if (_logLevel < DEBUG_MODE) exitWith {}; private _hash = createHashMapFromArray _data; // Replace square brackets with round brackets to avoid parsing issues. -_message regexReplace ["\[", "("]; -_message regexReplace ["\]", ")"]; +_message regexReplace ['(\[)', "("]; +_message regexReplace ['(\])', ")"]; private _json = [_hash] call CBA_fnc_encodeJSON; _log = format ["[%1] [%2] [%3] [%4] :: %5", QUOTE(PREFIX), _component, _fnc_scriptNameParent, _message, _json]; diff --git a/framework/common/functions/fn_logMissionInfo.sqf b/framework/common/functions/fn_logMissionInfo.sqf index 1da141c..ecba52c 100644 --- a/framework/common/functions/fn_logMissionInfo.sqf +++ b/framework/common/functions/fn_logMissionInfo.sqf @@ -1,6 +1,7 @@ #include "..\script_component.hpp" [ + LEVEL_INFO, QUOTE(COMPONENT), "MISSION INFO", [ diff --git a/framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_getCurrentAssetsByBase.sqf similarity index 100% rename from framework/fbcb2_assets/functions/fn_getAssetsByBase.sqf rename to framework/fbcb2_assets/functions/fn_getCurrentAssetsByBase.sqf diff --git a/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf index a939818..76daf37 100644 --- a/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf +++ b/framework/fbcb2_assets/functions/fn_getStartingAndCurrentAssets.sqf @@ -8,7 +8,7 @@ private _startingAssets = []; } forEach _startingAssetsByBase; // get all current assets at each base and combine to array -private _assetsByBase = call FUNC(getAssetsByBase); +private _assetsByBase = call FUNC(getCurrentAssetsByBase); private _assets = []; { _assets append (_x#1); diff --git a/framework/fbcb2_assets/functions/fn_initClient.sqf b/framework/fbcb2_assets/functions/fn_initClient.sqf index 57d6474..62dfbf3 100644 --- a/framework/fbcb2_assets/functions/fn_initClient.sqf +++ b/framework/fbcb2_assets/functions/fn_initClient.sqf @@ -2,15 +2,27 @@ if (!hasInterface) exitWith {}; +call FUNC(updateAssetDiary); + // once the server has published that assets have been gathered and distributed to bases (respawn modules), // we can update the asset diary on our end using that data -[{missionNamespace getVariable [QGVAR(serverAssetsReady), false]}, { - call FUNC(updateAssetDiary); -}] call CBA_fnc_waitUntilAndExecute; +[QGVAR(assetsGathered), { + [ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "Received gathered base asset data from server", + [] + ] call EFUNC(common,log); + + // update the asset diary with the data we've received + FUNC(updateAssetDiary); +}] call CBA_fnc_addEventHandlerArgs; [ LEVEL_DEBUG, QUOTE(COMPONENT), "postInit complete", [] -] call EFUNC(common,log); \ No newline at end of file +] call EFUNC(common,log); + +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/fbcb2_assets/functions/fn_initServer.sqf b/framework/fbcb2_assets/functions/fn_initServer.sqf index 15dab32..14dfcbd 100644 --- a/framework/fbcb2_assets/functions/fn_initServer.sqf +++ b/framework/fbcb2_assets/functions/fn_initServer.sqf @@ -5,8 +5,6 @@ if (!isServer) exitWith {}; // init asset stores at bases [true] call FUNC(updateAssetsByBase); -missionNamespace setVariable [QGVAR(serverAssetsReady), true, true]; - // starting 5 minutes after postInit, update asset stores every 5 minutes [{ [ diff --git a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf index d48bc5a..dc0e2e7 100644 --- a/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf +++ b/framework/fbcb2_assets/functions/fn_updateAssetsByBase.sqf @@ -7,6 +7,8 @@ params [ if (!isServer) exitWith {}; +GVARMAIN(baseObjects) = allMissionObjects "ModuleRespawnPosition_F"; + // Get all approved assets on map, find the closest base // Then determine if it's within range // If it is, add it to the base's assets list @@ -14,12 +16,14 @@ if (!isServer) exitWith {}; private _allVehicles = vehicles; private _allSaved = []; -private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase); private _assetsStartedAtThisBaseVar = QGVAR(assetsStartedAtThisBase); +private _assetsAtThisBaseVar = QGVAR(assetsAtThisBase); private _approvedAssetsCfg = call EFUNC(common,getApprovedAssetsCfg); if (isNull _approvedAssetsCfg) exitWith {}; +private _currentBaseAssetsGathered = GVARMAIN(baseObjects) apply {[_x, []]};; + { private _className = configName _x; private _callsign = getText(_x >> "callsign"); @@ -27,68 +31,34 @@ if (isNull _approvedAssetsCfg) exitWith {}; { private _asset = _x; - // avoid duplicates - if (_asset in _allSaved) then {continue}; - + // ignore assets beyond the range of bases if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; // add to base's assets list private _closestBase = [_asset] call EFUNC(common,getNearestBase); - private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; - _baseAssets pushBackUnique [ + private _closestBaseCurrentAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _closestBase })#0#1; + _closestBaseCurrentAssets pushBackUnique [ _asset call BIS_fnc_netId, configOf _asset ]; - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsAtThisBaseVar, - _baseAssets - ]; - - // if this is the init, set the base's assets started at this base - if (_isInit) then { - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsStartedAtThisBaseVar, - _baseAssets - ]; - }; - - _allSaved pushBack _asset; } forEach _found; } forEach (_approvedAssetsCfg call BIS_fnc_returnChildren); // Add all ground vehicles (LandVehicle) { private _asset = _x; - // avoid duplicates - if (_asset in _allSaved) then {continue}; + // ignore assets beyond the range of bases if (not ([_asset] call FUNC(isAssetInRangeOfBase))) then {continue}; - // add to base's assets list private _closestBase = [_asset] call EFUNC(common,getNearestBase); - private _baseAssets = _closestBase getVariable [_assetsAtThisBaseVar, []]; - _baseAssets pushBackUnique [ + private _closestBaseCurrentAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _closestBase })#0#1; + _closestBaseCurrentAssets pushBackUnique [ _asset call BIS_fnc_netId, configOf _asset ]; - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsAtThisBaseVar, - _baseAssets - ]; - - // if this is the init, set the base's assets started at this base - if (_isInit) then { - // broadcast later so we're not spamming network - _closestBase setVariable [ - _assetsStartedAtThisBaseVar, - _baseAssets - ]; - }; } forEach (_allVehicles select { _x isKindOf "LandVehicle" }); //////////////////////////////////////////////////////////////////////// @@ -97,16 +67,17 @@ if (isNull _approvedAssetsCfg) exitWith {}; { private _base = _x; - // save current assets - private _baseAssets = _base getVariable [_assetsAtThisBaseVar, []]; - _base setVariable [_assetsAtThisBaseVar, _baseAssets, true]; + private _thisBaseCurrentAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _base })#0#1; + _base setVariable [_assetsAtThisBaseVar, _thisBaseCurrentAssets, true]; - // if init, save starting assets if (_isInit) then { - _base setVariable [_assetsStartedAtThisBaseVar, _baseAssets, true]; + _base setVariable [_assetsStartedAtThisBaseVar, _thisBaseCurrentAssets, true]; }; } forEach GVARMAIN(baseObjects); +// send a CBA event to let other scripts know that assets have been gathered +[{[QGVAR(assetsGathered)] call CBA_fnc_globalEvent;}, 2] call CBA_fnc_waitAndExecute; + //////////////////////////////////////////////////////////////////////// // log starting assets if init // log current assets if requested (for end of mission counts) @@ -117,7 +88,7 @@ if !(_isInit || _logCurrentAssets) exitWith {}; private _base = _x; // get current assets - private _baseAssets = _base getVariable [_assetsAtThisBaseVar, []]; + private _baseAssets = (_currentBaseAssetsGathered select { _x select 0 isEqualTo _base })#0#1; // prepare key value for logging private _baseAssetsHashesPrep = _baseAssets apply { diff --git a/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf b/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf index 64f1ca4..9f5cccb 100644 --- a/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf +++ b/framework/fbcb2_main/functions/fn_addFrequenciesRecord.sqf @@ -14,6 +14,7 @@ if (isNull _battalionInfoCfg) exitWith { "Null Battalion Config", [] ] call EFUNC(common,log); + ["Null Battalion Config"] call BIS_fnc_error; }; private _battalionElementCfgs = [_battalionInfoCfg >> "Command"] call BIS_fnc_returnChildren; @@ -24,6 +25,7 @@ if (count _battalionElementCfgs == 0) exitWith { "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(common,log); + ["ERROR: No battalion elements found. Check that the battalion config is correctly structured. See defines/BattalionInfo.hpp and framework/util/functions/getBattalionCfg.sqf."] call BIS_fnc_error; }; //////////////////////////////////////// @@ -48,12 +50,12 @@ private _FREQ_TEXT_COLOR = "#CCCCCC"; reverse _battalionElementCfgs; { - diag_log text format[ - "[%1] <%2> Processing battalion element %3", - QUOTE(PREFIX), - _fnc_scriptName, - configName _x - ]; + [ + LEVEL_TRACE, + QUOTE(COMPONENT), + format["Processing battalion element %1", configName _x], + [] + ] call EFUNC(common,log); // recursively generate diary text for all child elements of battalion-level elements private _diaryTitleText = [_x, true] call FUNC(generateElementFrequencyRecordText); [ diff --git a/framework/fbcb2_main/functions/fn_init.sqf b/framework/fbcb2_main/functions/fn_initClient.sqf similarity index 92% rename from framework/fbcb2_main/functions/fn_init.sqf rename to framework/fbcb2_main/functions/fn_initClient.sqf index 473123d..b2f717b 100644 --- a/framework/fbcb2_main/functions/fn_init.sqf +++ b/framework/fbcb2_main/functions/fn_initClient.sqf @@ -2,8 +2,6 @@ if ( !hasInterface ) exitWith {}; -waitUntil { !isNil QGVARMAIN(complete) }; - GVAR(recordTitleColor) = "#ff6666"; GVAR(recordTitleFont) = "PuristaMedium"; GVAR(recordTitleSize) = 20; @@ -33,7 +31,7 @@ player createDiarySubject[GVAR(subjectAssetsGroundID), "FBCB2 Ground"]; // ]] GVAR(diaryRecords) = createHashMap; -// run main inits - assets handled in that component +// run main inits [] call FUNC(addFrequenciesRecord); [] call FUNC(addSignalColorsRecord); [] call FUNC(addEnvironmentRecord); @@ -51,4 +49,6 @@ GVAR(diaryRecords) = createHashMap; QUOTE(COMPONENT), "postInit complete", [] -] call EFUNC(common,log); \ No newline at end of file +] call EFUNC(common,log); + +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf index 824c271..7f04abb 100644 --- a/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf +++ b/framework/fbcb2_main/util/fn_createOrUpdateDiaryRecord.sqf @@ -15,9 +15,16 @@ private _existingRecord = _subjectRecords getOrDefault [_recordTitle, diaryRecor if (!isNull _existingRecord) then { player setDiaryRecordText [[_subjectID, _existingRecord], [_recordTitle, _recordText, _recordIcon]]; - if (DEBUG_ENABLED) then { - systemChat format ["Updated diary record: %1", _recordTitle]; - }; + + [ + LEVEL_DEBUG, + QUOTE(COMPONENT), + format ["Updated diary record: %1", _recordTitle], + [ + ["subjectID", _subjectID], + ["recordTitle", _recordTitle] + ] + ] call EFUNC(common,log); } else { private _new = player createDiaryRecord [ _subjectID, @@ -29,4 +36,14 @@ if (!isNull _existingRecord) then { ]; _subjectRecords set [_recordTitle, _new]; GVAR(diaryRecords) set [_subjectID, _subjectRecords]; + + [ + LEVEL_DEBUG, + QUOTE(COMPONENT), + format ["Created diary record: %1", _recordTitle], + [ + ["subjectID", _subjectID], + ["recordTitle", _recordTitle] + ] + ] call EFUNC(common,log); }; \ No newline at end of file diff --git a/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf index d63b328..b329279 100644 --- a/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf +++ b/framework/fbcb2_main/util/fn_generateElementFrequencyRecordText.sqf @@ -71,7 +71,8 @@ if (_shouldProcessChildCfgs) then { [ LEVEL_TRACE, QUOTE(COMPONENT), - "Processing child elements for battalion element %1" + "Processing child elements for battalion element %1", + [] ] call EFUNC(common,log); [_battalionElement, { diff --git a/framework/init/functions/fn_addAARChatHandler.sqf b/framework/init/functions/fn_addAARChatHandler.sqf index a0e8135..10f3979 100644 --- a/framework/init/functions/fn_addAARChatHandler.sqf +++ b/framework/init/functions/fn_addAARChatHandler.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + [ "saveaar", { diff --git a/framework/init/functions/fn_initClient.sqf b/framework/init/functions/fn_initClient.sqf new file mode 100644 index 0000000..a7d106a --- /dev/null +++ b/framework/init/functions/fn_initClient.sqf @@ -0,0 +1,34 @@ +#include "..\script_component.hpp" + +if ( !hasInterface ) exitWith {}; + +["milsim_logText", { + params [["_strArray", [""], [[]]]]; + { + diag_log text _x; + } forEach _strArray; +}] call CBA_fnc_addEventHandler; + +// make sure the server has finished init +waitUntil {!isNil QGVARMAIN(complete)}; + +["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; + + +// initialize other modules +call EFUNC(reinsert,initClient); +call EFUNC(resupply,initClient); +call EFUNC(triageIcons,initClient); +call EFUNC(vehicleFlags,initClient); +call EFUNC(fbcb2_main,initClient); +call EFUNC(fbcb2_assets,initClient); + + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); + +nil; \ No newline at end of file diff --git a/framework/init/functions/fn_initPlayerLocal.sqf b/framework/init/functions/fn_initPlayerLocal.sqf deleted file mode 100644 index e1bf330..0000000 --- a/framework/init/functions/fn_initPlayerLocal.sqf +++ /dev/null @@ -1,23 +0,0 @@ -#include "..\script_component.hpp" - -if ( !hasInterface ) exitWith {}; - -if (!isServer) then { - ["milsim_logText", { - params [["_strArray", [""], [[]]]]; - { - diag_log text _x; - } forEach _strArray; - }] call CBA_fnc_addEventHandler; -}; - -["InitializePlayer", [player, true]] call BIS_fnc_dynamicGroups; - -[ - LEVEL_DEBUG, - QUOTE(COMPONENT), - "postInit complete", - [] -] call EFUNC(common,log); - -nil; \ No newline at end of file diff --git a/framework/init/functions/fn_initServer.sqf b/framework/init/functions/fn_initServer.sqf index 0b0e4cb..84e2666 100644 --- a/framework/init/functions/fn_initServer.sqf +++ b/framework/init/functions/fn_initServer.sqf @@ -2,23 +2,30 @@ if (!isServer) exitWith {}; - // array of all respawn modules in the mission representing "bases" GVARMAIN(baseObjects) = allMissionObjects "ModuleRespawnPosition_F"; -publicVariable "milsim_baseObjects"; +publicVariable QGVARMAIN(baseObjects); // Initializes the Dynamic Groups framework and groups ["Initialize", [true]] call BIS_fnc_dynamicGroups; -["milsim_logText", { - params [["_strArray", [""], [[]]]]; - { - diag_log text _x; - } forEach _strArray; -}] call CBA_fnc_addEventHandler; +if (isDedicated) then { + ["milsim_logText", { + params [["_strArray", [""], [[]]]]; + { + diag_log text _x; + } forEach _strArray; + }] call CBA_fnc_addEventHandler; +}; -missionNamespace setVariable [QGVARMAIN(complete), true]; -publicVariable QGVARMAIN(complete); + +// initialize other modules +call EFUNC(common,logMissionInfo); +call EFUNC(fbcb2_assets,initServer); +call EFUNC(reinsert,initServer); + +// declare init complete to other modules +missionNamespace setVariable [QGVARMAIN(complete), true, true]; [ LEVEL_INFO, diff --git a/framework/performance/functions/fn_addCBASettings.sqf b/framework/performance/functions/fn_addCBASettings.sqf index e1564d7..405e72c 100644 --- a/framework/performance/functions/fn_addCBASettings.sqf +++ b/framework/performance/functions/fn_addCBASettings.sqf @@ -8,7 +8,7 @@ QGVAR(server_cps_enable), "CHECKBOX", "Server CPS Metrics Enabled", - ["17th Battalion", "Server Metrics"], + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], true, true, { diff --git a/framework/performance/functions/fn_calculateClientStats.sqf b/framework/performance/functions/fn_calculateClientStats.sqf index 0db20a2..24bd75c 100644 --- a/framework/performance/functions/fn_calculateClientStats.sqf +++ b/framework/performance/functions/fn_calculateClientStats.sqf @@ -10,13 +10,8 @@ _counter = _counter + 1; }; // in an empty mission, the _counter may go well over 2000 times per frame! - [ - LEVEL_INFO, - QUOTE(COMPONENT), - format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)], - [["playerRawCPS", _counter / (diag_frameNo - _frameNo)]] - ] call EFUNC(common,log); - player setVariable [QGVAR(player_raw_cps), _counter / (diag_frameNo - _frameNo), true]; + private _rawCPS = _counter / (diag_frameNo - _frameNo); + player setVariable [QGVAR(player_raw_cps), _rawCPS, true]; // with suspension private _counter = 0; @@ -28,13 +23,23 @@ uiSleep 0.001; // waits at least 1 frame }; // _counter says one per frame, as expected + private _playerCPS = _counter / (diag_frameNo - _frameNo); + player setVariable [QGVAR(player_cps), _playerCPS, true]; + + // log to RPT [ - LEVEL_INFO, - QUOTE(COMPONENT), - format ["Average Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)], - [["playerCPS", _counter / (diag_frameNo - _frameNo)]] - ] call EFUNC(common,log); - player setVariable [QGVAR(player_cps), _counter / (diag_frameNo - _frameNo), true]; + + {_this call EFUNC(common,log);}, + [ + LEVEL_INFO, + QUOTE(COMPONENT), + format ["Average Execution: %1 times per frame", _playerCPS], + [ + ["playerRawCPS", _rawCPS], + ["playerCPS", _playerCPS] + ] + ] + ] call CBA_fnc_directCall; }; nil; \ No newline at end of file diff --git a/framework/performance/functions/fn_calculateServerStats.sqf b/framework/performance/functions/fn_calculateServerStats.sqf index 5f58b67..b0ec77d 100644 --- a/framework/performance/functions/fn_calculateServerStats.sqf +++ b/framework/performance/functions/fn_calculateServerStats.sqf @@ -1,3 +1,5 @@ +#include "..\script_component.hpp" + [] spawn { // warning: while loop without suspension executes multiple times per frame private _counter = 0; @@ -8,10 +10,9 @@ _counter = _counter + 1; }; - diag_log text format ["[MILSIM] (server) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; - - missionNamespace setVariable ["milsim_raw_cps", _counter / (diag_frameNo - _frameNo)]; - publicVariable "milsim_raw_cps"; + private _rawCPS = _counter / (diag_frameNo - _frameNo); + missionNamespace setVariable [QGVAR(server_raw_cps), _rawCPS]; + publicVariable QGVAR(server_raw_cps); // with suspension private _counter = 0; @@ -23,12 +24,31 @@ uiSleep 0.001; // waits at least 1 frame }; - diag_log text format ["[MILSIM] (server) Average Server Execution: %1 times per frame", _counter / (diag_frameNo - _frameNo)]; + private _serverCPS = _counter / (diag_frameNo - _frameNo); + missionNamespace setVariable [QGVAR(server_cps), _counter / (diag_frameNo - _frameNo)]; + publicVariable QGVAR(server_cps); - missionNamespace setVariable ["milsim_cps", _counter / (diag_frameNo - _frameNo)]; - publicVariable "milsim_cps"; + // log to RPT + [ + + {_this call EFUNC(common,log);}, + [ + LEVEL_INFO, + QUOTE(COMPONENT), + format ["Average Server Execution: %1 times per frame", _serverCPS], + [ + ["serverRawCPS", _rawCPS], + ["serverCPS", _serverCPS] + ] + ] + ] call CBA_fnc_directCall; - ["milsim_serverEfficiency", [ [ ["float", "milsim_raw_cps", missionNamespace getVariable ["milsim_raw_cps", -1]], ["float", "milsim_cps", missionNamespace getVariable ["milsim_cps", -1]] ] ] ] call CBA_fnc_localEvent; + [QGVARMAIN(serverEfficiency), [ + [ + ["float", QGVAR(server_raw_cps), missionNamespace getVariable [QGVAR(server_raw_cps), -1]], + ["float", QGVAR(server_cps), missionNamespace getVariable [QGVAR(server_cps), -1]] + ] + ]] call CBA_fnc_localEvent; }; nil; \ No newline at end of file diff --git a/framework/reinsert/functions/fn_addCBASettings.sqf b/framework/reinsert/functions/fn_addCBASettings.sqf index f00dcdf..b605d6a 100644 --- a/framework/reinsert/functions/fn_addCBASettings.sqf +++ b/framework/reinsert/functions/fn_addCBASettings.sqf @@ -34,10 +34,26 @@ } ] call CBA_fnc_addSetting; +[ + QGVAR(setting_maxWait), // variable + "TIME", // type + ["Max Wait Before Global Notify", "How long should at least one person be waiting before prompting a global notification."], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [60*5, 60*30, 60*20], // [_min, _max, _default] + true, + { + params ["_value"]; + [ + QGVAR(setting_maxWait), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + [ QGVAR(setting_pilotForcedCheckEnabled), // variable "CHECKBOX", // type - ["Enabled", "Whether or not pilots are forced to view the contents of the reinsertion queue per interval"], // title + ["Force Queue Checks for Pilots", "Whether or not pilots are forced to view the contents of the reinsertion queue per interval"], // title [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category false, // default value true, // global setting @@ -65,19 +81,3 @@ ] call EFUNC(common,logSettingChanged); } ] call CBA_fnc_addSetting; - -[ - QGVAR(setting_maxWait), // variable - "TIME", // type - ["Max Wait Threshold", "How long should at least one person be waiting before prompting a global notification."], // title - [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category - [60*5, 60*30, 60*20], // [_min, _max, _default] - true, - { - params ["_value"]; - [ - QGVAR(setting_maxWait), - _value - ] call EFUNC(common,logSettingChanged); - } -] call CBA_fnc_addSetting; diff --git a/framework/reinsert/server/fn_globalShowQueue.sqf b/framework/reinsert/server/fn_globalShowQueue.sqf index 1300266..def6061 100644 --- a/framework/reinsert/server/fn_globalShowQueue.sqf +++ b/framework/reinsert/server/fn_globalShowQueue.sqf @@ -43,7 +43,7 @@ if (count _timeoutPlayers > 0) then { _playerLines pushBack ([format [ "%1: %2 [%3]", groupID (group (_player)), - name (_player), + name _player, [diag_tickTime - (_timeFiled), "MM:SS"] call BIS_fnc_secondsToString ], 0.8, [0.8, 0.8, 0.8, 1]]); diff --git a/framework/reinsert/server/fn_removeFromQueue.sqf b/framework/reinsert/server/fn_removeFromQueue.sqf index dc73e27..4a76c82 100644 --- a/framework/reinsert/server/fn_removeFromQueue.sqf +++ b/framework/reinsert/server/fn_removeFromQueue.sqf @@ -4,21 +4,23 @@ params [["_player", objNull, [objNull]]]; if (!isServer) exitWith { [ - "respawn_reinsertion", + LEVEL_ERROR, + QUOTE(COMPONENT), "ATTEMPTED RUN ON CLIENT", [ ["player", _player] ] - ] call milsim_util_fnc_log; + ] call EFUNC(common,log); }; if (isNull _player) exitWith { [ - "respawn_reinsertion", + LEVEL_ERROR, + QUOTE(COMPONENT), "NULL PARAMETERS", [ ["player", _player] ] - ] call milsim_util_fnc_log; + ] call EFUNC(common,log); }; // get entries for this player from queue @@ -43,17 +45,16 @@ publicVariable QGVAR(reinsertionQueue); // get the closest base to the player private _nearestBase = [_player] call EFUNC(common,getNearestBase); // log to rpt -private _logParams = [ - ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], - ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], - ["closestBaseDistance", _player distance _nearestBase], - ["maxDistanceSetting", _maxRangeToReady], - ["inQueueDuration", diag_tickTime - _timeFiled] -]; -_logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray); [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "PLAYER RESCINDED REQUEST", - _logParams -] call milsim_util_fnc_log; \ No newline at end of file + [_player, [ + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], + ["filedAtBaseDistance", _player distance _base], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], + ["closestBaseDistance", _player distance _nearestBase], + ["maxDistanceSetting", _maxRangeToReady], + ["inQueueDuration", diag_tickTime - _timeFiled] + ]] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf index 4dacf3c..14c04df 100644 --- a/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf +++ b/framework/reinsert/server/fn_returnReinsertQueueNotification.sqf @@ -7,6 +7,8 @@ Author: IndigoFox */ +#include "..\script_component.hpp" + if (not isRemoteExecuted) exitWith { diag_log text format ["[milsim] (respawn_reinsertion) SHOW QUEUE NOT REMOTE EXECUTED"]; }; @@ -25,12 +27,12 @@ if (isNull _userObject) exitWith { }; // log to rpt -private _logParams = [_userObject, []] call EFUNC(common,addPlayerInfoToArray); [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "SHOW QUEUE REQUESTED", - _logParams -] call milsim_util_fnc_log; + [_userObject] call EFUNC(common,addPlayerInfoToArray) +] call EFUNC(common,log); private _queue = missionNamespace getVariable [QGVAR(reinsertionQueue), []]; // get base objects from queue diff --git a/framework/reinsert/server/fn_validateQueue.sqf b/framework/reinsert/server/fn_validateQueue.sqf index 2ea508b..9d3be7f 100644 --- a/framework/reinsert/server/fn_validateQueue.sqf +++ b/framework/reinsert/server/fn_validateQueue.sqf @@ -15,8 +15,6 @@ private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeT if (not _isCloseEnoughToAnyBase || not (alive _player)) then { // don't include player in updated queue // log to rpt - private _logParams = ; - _logParams = ; [ LEVEL_INFO, QUOTE(COMPONENT), @@ -38,20 +36,19 @@ private _maxRangeToReady = missionNamespace getVariable [QGVAR(setting_maxRangeT _stillValid pushBackUnique [_player, _nearestBase, _timeFiled]; // if player's base has changed, log to rpt if (_base != _nearestBase) then { - private _logParams = [ - ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], - ["filedAtBaseDistance", _player distance _base], - ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], - ["closestBaseDistance", _player distance _nearestBase], - ["maxDistanceSetting", _maxRangeToReady], - ["inQueueDuration", diag_tickTime - _timeFiled] - ]; - _logParams = [_player, _logParams] call EFUNC(common,addPlayerInfoToArray); [ - "respawn_reinsertion", + LEVEL_INFO, + QUOTE(COMPONENT), "PLAYER BASE WAS UPDATED", - _logParams - ] call milsim_util_fnc_log; + [_player, [ + ["filedAtBase", [_base] call EFUNC(common,getNameOfBase)], + ["filedAtBaseDistance", _player distance _base], + ["closestBase", [_nearestBase] call EFUNC(common,getNameOfBase)], + ["closestBaseDistance", _player distance _nearestBase], + ["maxDistanceSetting", _maxRangeToReady], + ["inQueueDuration", diag_tickTime - _timeFiled] + ]] call EFUNC(common,addPlayerInfoToArray) + ] call EFUNC(common,log); }; } forEach GVAR(reinsertionQueue); diff --git a/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf index 1e9d62b..299b1b5 100644 --- a/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf +++ b/framework/resupply/functions/fn_addArsenalObjectSpawnBoxActions.sqf @@ -16,11 +16,29 @@ private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; { // add scroll wheel action to spawn different supply box types private _arsenalBox = _x; + + // always remove old actions if they exist + private _actionIDs = _arsenalBox getVariable [QGVAR(supplyCrateActionIDs), []]; { + _arsenalBox removeAction _x; + } forEach _actionIDs; + _arsenalBox setVariable [QGVAR(supplyCrateActionIDs), []]; + + + // if setting disabled, skip adding actions + if (not ( + [QGVAR(setting_allowSupplyBoxScrollWheelSpawning)] call CBA_settings_fnc_get + )) then {continue}; + + + { // add an action for each supply crate type private _cfg = _x; private _supplyCrateDisplayName = (_cfg >> "displayName") call BIS_fnc_getCfgData; - _arsenalBox addAction [format ["Spawn %1", _supplyCrateDisplayName], { + + + + private _actionID = _arsenalBox addAction [format ["Spawn %1", _supplyCrateDisplayName], { params ["_target", "_caller", "_actionId", "_arguments"]; _arguments params ["_supplyCrateCfg"]; [ @@ -29,5 +47,6 @@ private _supplyCrateTypesCfgs = _supplyCratesCfg call BIS_fnc_returnChildren; getPos _target ] call FUNC(createBox); }, [_cfg], 0, false, true, "", ""]; + (_arsenalBox getVariable [QGVAR(supplyCrateActionIDs), []]) pushBack _actionID; } forEach _supplyCrateTypesCfgs; } forEach _arsenalBoxes; \ No newline at end of file diff --git a/framework/resupply/functions/fn_addCBASettings.sqf b/framework/resupply/functions/fn_addCBASettings.sqf index 7a664fc..acfe0b9 100644 --- a/framework/resupply/functions/fn_addCBASettings.sqf +++ b/framework/resupply/functions/fn_addCBASettings.sqf @@ -13,6 +13,10 @@ QGVAR(setting_allowSupplyBoxScrollWheelSpawning), _value ] call EFUNC(common,logSettingChanged); + + if (_value && hasInterface && time > 0) then { + [] call FUNC(addArsenalObjectSpawnBoxActions); + }; }, true // requires mission restart ] call CBA_fnc_addSetting; diff --git a/framework/resupply/functions/fn_init.sqf b/framework/resupply/functions/fn_init.sqf deleted file mode 100644 index ddb55b6..0000000 --- a/framework/resupply/functions/fn_init.sqf +++ /dev/null @@ -1,12 +0,0 @@ -#include "..\script_component.hpp" - -// 5 seconds after the client is loaded, add the resupply action to all arsenal boxes -[ - {time > 5}, - { - if (missionNamespace getVariable [ - QGVAR(setting_allowSupplyBoxScrollWheelSpawning), - false - ]) then {call FUNC(addSpawnBoxActions)} - } -] call CBA_fnc_waitUntilAndExecute; \ No newline at end of file diff --git a/framework/resupply/functions/fn_initClient.sqf b/framework/resupply/functions/fn_initClient.sqf new file mode 100644 index 0000000..a78233f --- /dev/null +++ b/framework/resupply/functions/fn_initClient.sqf @@ -0,0 +1,13 @@ +#include "..\script_component.hpp" + +if (!hasInterface) exitWith {}; + +call FUNC(addArsenalObjectSpawnBoxActions); + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/script_mod.hpp b/framework/script_mod.hpp index cb0aa97..21deabe 100644 --- a/framework/script_mod.hpp +++ b/framework/script_mod.hpp @@ -7,8 +7,8 @@ #define VERSION_AR MAJOR,MINOR,PATCHLVL // #define DEBUG_MODE -1 // TRACE -#define DEBUG_MODE 0 // DEBUG -// #define DEBUG_MODE 1 // INFO +// #define DEBUG_MODE 0 // DEBUG +#define DEBUG_MODE 1 // INFO // #define DEBUG_MODE 2 // WARNING // #define DEBUG_MODE 3 // ERROR diff --git a/framework/server/script_component.hpp b/framework/server/script_component.hpp deleted file mode 100644 index d7cf7de..0000000 --- a/framework/server/script_component.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#define COMPONENT server -#define COMPONENT_BEAUTIFIED Server -#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/triageIcons/functions/fn_addCBASettings.sqf b/framework/triageIcons/functions/fn_addCBASettings.sqf new file mode 100644 index 0000000..c683fae --- /dev/null +++ b/framework/triageIcons/functions/fn_addCBASettings.sqf @@ -0,0 +1,138 @@ +#include "..\script_component.hpp" + +//--------------------- +// Medical Overlay +//--------------------- + +[ + QGVAR(setting_enabled), // variable + "CHECKBOX", // type + ["Enable 3D Triage Card State", "Draws a colored dot over units within Xm indicating current ACE Triage State"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + true, // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_enabled), + _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(addGetEntitiesPFH); + call FUNC(addDrawIconsPFH); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_drawRange), // variable + "LIST", // type + ["Range To Draw Icons", "Determines range at which dots are visible"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [[2, 4, 6, 8, 10], ["2", "4", "6", "8", "10"], 4], // option values, option labels, default index + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_drawRange), + _value + ] call EFUNC(common,logSettingChanged); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorMinimal), // variable + "COLOR", // type + ["Minimal State Color", "Color of the dot for MINIMAL state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0, 0.5, 0], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorMinimal), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorDelayed), // variable + "COLOR", // type + ["Delayed State Color", "Color of the dot for DELAYED state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [1, 0.84, 0], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorDelayed), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorImmediate), // variable + "COLOR", // type + ["Immediate State Color", "Color of the dot for IMMEDIATE state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [1, 0, 0], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorImmediate), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorDeceased), // variable + "COLOR", // type + ["Deceased State Color", "Color of the dot for DECEASED state"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0.15, 0.15, 0.15], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorDeceased), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + +[ + QGVAR(setting_colorNone), // variable + "COLOR", // type + ["None State Color", "Color of the dot for NONE state, when a card is not set"], // title + [QUOTE(SETTINGS_GROUP_NAME), QUOTE(COMPONENT_BEAUTIFIED)], // category + [0.5, 0.5, 0.5], // default value + false, // isGlobal + { + params ["_value"]; + [ + QGVAR(setting_colorNone), + str _value + ] call EFUNC(common,logSettingChanged); + + call FUNC(updateColors); + } +] call CBA_fnc_addSetting; + + +[ + LEVEL_INFO, + QUOTE(COMPONENT), + "CREATED SETTINGS", + [] +] call EFUNC(common,log); \ No newline at end of file diff --git a/framework/triageIcons/functions/fn_addDrawIconsPFH.sqf b/framework/triageIcons/functions/fn_addDrawIconsPFH.sqf new file mode 100644 index 0000000..6478264 --- /dev/null +++ b/framework/triageIcons/functions/fn_addDrawIconsPFH.sqf @@ -0,0 +1,62 @@ +/* + +milsim_fnc_addMedicalOverlayPFH + +Author: IndigoFox + +Description: + Affects players with medical permissions. Will see a 3D colored dot over nearby (5-10m) + unconscious players who are not in a vehicle + which indicates their current ACE Triage Card status. + Designed to increase efficiency of CCPs. + +*/ + +#include "..\script_component.hpp" + + +// Per-frame handler to draw icons +// cleanup +if (!isNil QGVAR(drawIconsPfh)) then { + [GVAR(drawIconsPfh)] call CBA_fnc_removePerFrameHandler; +}; +// add pfh +GVAR(drawIconsPfh) = [{ + // if disabled, skip processing + if (!GVAR(setting_enabled)) exitWith {false}; + // if no targets, skip processing + if (count GVAR(drawTargets) == 0) exitWith {false}; + // if the player doesn't have medical perms, skip processing + if !([player] call ace_medical_treatment_fnc_isMedic) exitWith {false}; + { + private _unit = _x; + // distance within X meters + if (player distance _unit > GVAR(setting_drawRange)) then {continue}; + // check unit not null, not conscious, and not in a vehicle + if ( + !(_unit getVariable ["ACE_isUnconscious", false]) || + !isNull (objectParent _unit) + ) then {continue}; + + // color based on triage level + private _triageLevel = _unit getVariable ["ace_medical_triageLevel", 4]; + if (_triageLevel == -1) then {continue}; + private _color = GVAR(colors) select (_triageLevel - 1); + _color set [3, 0.9]; // set alpha + // draw position, slightly above the prone unit + private _drawPos = (visiblePosition _unit) vectorAdd [0, 0, 0.5]; + // draw icon + drawIcon3D [ + "\A3\ui_f\data\map\markers\military\dot_CA.paa", // icon texture + _color, // color + _drawPos, // position AGL + 1, // width + 1, // height + 0, // angle + "", // text + true // outline + // further params optional, omitted + ]; + } forEach GVAR(drawTargets); +}, 0, []] call CBA_fnc_addPerFrameHandler; + diff --git a/framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf b/framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf new file mode 100644 index 0000000..781227e --- /dev/null +++ b/framework/triageIcons/functions/fn_addGetEntitiesPFH.sqf @@ -0,0 +1,18 @@ +#include "..\script_component.hpp" + +// subroutine to gather nearest 50 units every 5 seconds and store in GVAR(drawTargets) +// cleanup +if (!isNil QGVAR(getEntitiesPFH)) then { + [GVAR(getEntitiesPFH)] call CBA_fnc_removePerFrameHandler; +}; +// add pfh +GVAR(getEntitiesPFH) = [{ + GVAR(drawTargets) = ( + (allUnits + allDeadMen) select { + _x isKindOf "CAManBase" && + player distance _x < 50 && + !isNull _x && + player isNotEqualTo _x + } + ); +}, 10] call CBA_fnc_addPerFrameHandler; diff --git a/framework/triageIcons/functions/fn_initClient.sqf b/framework/triageIcons/functions/fn_initClient.sqf new file mode 100644 index 0000000..79b48ec --- /dev/null +++ b/framework/triageIcons/functions/fn_initClient.sqf @@ -0,0 +1,12 @@ +#include "..\script_component.hpp" + +// List of units to draw icons for +GVAR(drawTargets) = []; + +[ + LEVEL_DEBUG, + QUOTE(COMPONENT), + "postInit complete", + [] +] call EFUNC(common,log); +localNamespace setVariable [QGVAR(complete), true]; \ No newline at end of file diff --git a/framework/triageIcons/functions/fn_updateColors.sqf b/framework/triageIcons/functions/fn_updateColors.sqf new file mode 100644 index 0000000..874c9b3 --- /dev/null +++ b/framework/triageIcons/functions/fn_updateColors.sqf @@ -0,0 +1,18 @@ +#include "..\script_component.hpp" + +// ACE Triage colors, for consistency across UIs and functions +// GVAR(colors) = [ +// (([QGVAR(setting_colorMinimal)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_MINIMAL +// (([QGVAR(setting_colorDelayed)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_DELAYED +// (([QGVAR(setting_colorImmediate)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_IMMEDIATE +// (([QGVAR(setting_colorDeceased)] call CBA_settings_fnc_get) + 0.9), // TRIAGE_COLOR_DECEASED +// (([QGVAR(setting_colorNone)] call CBA_settings_fnc_get) + 0) // TRIAGE_COLOR_NONE +// ]; + +GVAR(colors) = [ + ([QGVAR(setting_colorMinimal)] call CBA_settings_fnc_get), // TRIAGE_COLOR_MINIMAL + ([QGVAR(setting_colorDelayed)] call CBA_settings_fnc_get), // TRIAGE_COLOR_DELAYED + ([QGVAR(setting_colorImmediate)] call CBA_settings_fnc_get), // TRIAGE_COLOR_IMMEDIATE + ([QGVAR(setting_colorDeceased)] call CBA_settings_fnc_get), // TRIAGE_COLOR_DECEASED + ([QGVAR(setting_colorNone)] call CBA_settings_fnc_get) // TRIAGE_COLOR_NONE +]; \ No newline at end of file diff --git a/framework/triageIcons/script_component.hpp b/framework/triageIcons/script_component.hpp new file mode 100644 index 0000000..17b82f3 --- /dev/null +++ b/framework/triageIcons/script_component.hpp @@ -0,0 +1,3 @@ +#define COMPONENT triageIcons +#define COMPONENT_BEAUTIFIED Triage Icons +#include "../script_mod.hpp" \ No newline at end of file diff --git a/framework/vehicleFlags/functions/fn_init.sqf b/framework/vehicleFlags/functions/fn_initClient.sqf similarity index 100% rename from framework/vehicleFlags/functions/fn_init.sqf rename to framework/vehicleFlags/functions/fn_initClient.sqf