From a352acb126e03198c3ee0bb9750d1bcda9429632 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Tue, 23 Jul 2024 18:14:50 +0200 Subject: [PATCH 01/15] Fix Initialized Flag being set before completed Rack Init --- addons/sys_rack/fnc_addRackOnReturn.sqf | 4 ++++ addons/sys_rack/fnc_initVehicle.sqf | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/addons/sys_rack/fnc_addRackOnReturn.sqf b/addons/sys_rack/fnc_addRackOnReturn.sqf index 24c4e8fd5..264438af6 100644 --- a/addons/sys_rack/fnc_addRackOnReturn.sqf +++ b/addons/sys_rack/fnc_addRackOnReturn.sqf @@ -59,6 +59,10 @@ if (_idx != -1) then { _vehicle setVariable [QGVAR(queue), _queue]; }; +if (_queue isEqualTo []) then { + _vehicle setVariable [QGVAR(initialized), true, true]; +}; + if (!_handled) then { WARNING_2("Recieved new rack ID (%1) for vehicle (%2) but no entry in queue rack.",_rackId,typeOf _vehicle); }; diff --git a/addons/sys_rack/fnc_initVehicle.sqf b/addons/sys_rack/fnc_initVehicle.sqf index 25faf5787..786d288a1 100644 --- a/addons/sys_rack/fnc_initVehicle.sqf +++ b/addons/sys_rack/fnc_initVehicle.sqf @@ -19,7 +19,12 @@ params ["_vehicle"]; private _initialized = _vehicle getVariable [QGVAR(initialized), false]; if (!_initialized) then { - private _racks = configOf _vehicle >> "AcreRacks"; + private _racks = configProperties [(configOf _vehicle >> "AcreRacks"), "isClass _x", true]; + + // Set initialized flag if vehicle config has no defined Racks + if (_racks isEqualTo []) exitWith { + _vehicle setVariable [QGVAR(initialized), true, true]; + }; { private _componentName = getText (_x >> "componentName"); @@ -37,7 +42,5 @@ if (!_initialized) then { }; [_vehicle, _componentName, _displayName, _shortName, _isRadioRemovable, _allowed, _disabled, _mountedRadio, _components, _intercoms] call FUNC(addRack); - } forEach (configProperties [_racks, "isClass _x", true]); - - _vehicle setVariable [QGVAR(initialized), true, true]; + } forEach _racks; }; From 471a0582f440d30a514da8a5c0dc23265f676bd0 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Tue, 23 Jul 2024 20:49:46 +0200 Subject: [PATCH 02/15] Fix typo and whitespace --- addons/api/fnc_removeRackFromVehicle.sqf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/api/fnc_removeRackFromVehicle.sqf b/addons/api/fnc_removeRackFromVehicle.sqf index 01bb33d2c..e453b6fc7 100644 --- a/addons/api/fnc_removeRackFromVehicle.sqf +++ b/addons/api/fnc_removeRackFromVehicle.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: ACRE2Team - * Initialises all racks in the vehicle. Must be executed in the server. + * Removes a specific Rack from a vehicle. Must be executed in the server. * * Arguments: * 0: Vehicle (default: objNull) @@ -54,4 +54,3 @@ if (isDedicated) then { [QEGVAR(sys_rack,removeVehicleRacks), [_vehicle, _rackId], _player] call CBA_fnc_targetEvent; true - From b896061052bc4ec9abb92c158915167edb8073af Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Tue, 23 Jul 2024 20:55:10 +0200 Subject: [PATCH 03/15] Guarantee Rack addition after Forced Initialization --- addons/api/fnc_addRackToVehicle.sqf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/api/fnc_addRackToVehicle.sqf b/addons/api/fnc_addRackToVehicle.sqf index ee7105bf0..29debef8f 100644 --- a/addons/api/fnc_addRackToVehicle.sqf +++ b/addons/api/fnc_addRackToVehicle.sqf @@ -132,6 +132,8 @@ private _selectPlayer = { [{ params ["_selectPlayer", "_condition", "_vehicle"]; + if !([_vehicle] call FUNC(areVehicleRacksInitialized)) exitWith {false}; + private _player = [_condition, _vehicle] call _selectPlayer; !isNil "_player" From 713ec165641d024c8859e9c36945d46241e29c93 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Tue, 23 Jul 2024 21:00:04 +0200 Subject: [PATCH 04/15] Add API fnc_removeAllRacksFromVehicle --- addons/api/CfgFunctions.hpp | 1 + addons/api/fnc_removeAllRacksFromVehicle.sqf | 67 ++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 addons/api/fnc_removeAllRacksFromVehicle.sqf diff --git a/addons/api/CfgFunctions.hpp b/addons/api/CfgFunctions.hpp index a202bd0ca..c5631acfc 100644 --- a/addons/api/CfgFunctions.hpp +++ b/addons/api/CfgFunctions.hpp @@ -67,6 +67,7 @@ class CfgFunctions { PATHTO_FNC(initVehicleRacks); PATHTO_FNC(isRackRadioRemovable); PATHTO_FNC(mountRackRadio); + PATHTO_FNC(removeAllRacksFromVehicle); PATHTO_FNC(removeRackFromVehicle); PATHTO_FNC(unmountRackRadio); }; diff --git a/addons/api/fnc_removeAllRacksFromVehicle.sqf b/addons/api/fnc_removeAllRacksFromVehicle.sqf new file mode 100644 index 000000000..2edf7cad5 --- /dev/null +++ b/addons/api/fnc_removeAllRacksFromVehicle.sqf @@ -0,0 +1,67 @@ +#include "script_component.hpp" +/* + * Author: mrschick + * Removes all Racks from a vehicle. Must be executed in the server. + * + * Arguments: + * 0: Vehicle (default: objNull) + * 1: Condition called with argument "_unit" for rack init. If a longer function is given, it should be precompiled. (default: {}) + * + * Return Value: + * Racks removed successfully + * + * Example: + * [cursorTarget, {}] call acre_api_fnc_removeAllRacksFromVehicle + * + * Public: Yes + */ + +params [ + ["_vehicle", objNull, [objNull]], + ["_condition", {}, [{}]] +]; + +if (!isServer) exitWith { + WARNING("Function must be called on the server."); + false +}; + +if (isNull _vehicle) exitWith { + WARNING_1("Trying to remove a rack from an undefined vehicle %1",_vehicle); + false +}; + +private _success = true; + +if (!([_vehicle] call FUNC(areVehicleRacksInitialized))) then { + WARNING_1("Forcing initialisation of vehicle %1 in order to remove all racks",_vehicle); + _success = [_vehicle, _condition] call EFUNC(api,initVehicleRacks); +}; + +if (!_success) exitWith { + WARNING_1("Vehicle %1 failed to initialise",_vehicle); +}; + +// A player must do the action of removing a rack +private _player = objNull; + +if (isDedicated) then { + // Pick the first player + _player = (allPlayers - entities "HeadlessClient_F") select 0; +} else { + _player = acre_player; +}; + +[{ + params ["_vehicle", "_player"]; + [_vehicle] call FUNC(areVehicleRacksInitialized) +}, { + params ["_vehicle", "_player"]; + + private _racks = [_vehicle] call FUNC(getVehicleRacks); + for "_i" from (count _racks) - 1 to 0 step -1 do { + [QEGVAR(sys_rack,removeVehicleRacks), [_vehicle, _racks select _i], _player] call CBA_fnc_targetEvent; + }; +}, [_vehicle, _player]] call CBA_fnc_waitUntilAndExecute; + +true From 633b7b4387a6337b780f983bffe74bb730a62f73 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Wed, 24 Jul 2024 23:26:12 +0200 Subject: [PATCH 05/15] Add API fnc_replaceRacksOnVehicle --- addons/api/CfgFunctions.hpp | 1 + addons/api/fnc_replaceRacksOnVehicle.sqf | 74 ++++++++++++++++++++++++ addons/sys_rack/fnc_initVehicle.sqf | 28 ++++++++- 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 addons/api/fnc_replaceRacksOnVehicle.sqf diff --git a/addons/api/CfgFunctions.hpp b/addons/api/CfgFunctions.hpp index c5631acfc..5eb452c5d 100644 --- a/addons/api/CfgFunctions.hpp +++ b/addons/api/CfgFunctions.hpp @@ -69,6 +69,7 @@ class CfgFunctions { PATHTO_FNC(mountRackRadio); PATHTO_FNC(removeAllRacksFromVehicle); PATHTO_FNC(removeRackFromVehicle); + PATHTO_FNC(replaceRacksOnVehicle); PATHTO_FNC(unmountRackRadio); }; diff --git a/addons/api/fnc_replaceRacksOnVehicle.sqf b/addons/api/fnc_replaceRacksOnVehicle.sqf new file mode 100644 index 000000000..ebd683601 --- /dev/null +++ b/addons/api/fnc_replaceRacksOnVehicle.sqf @@ -0,0 +1,74 @@ +#include "script_component.hpp" +/* + * Author: mrschick + * Replaces all config-defined Racks on a vehicle with a different class of Rack, while keeping the same name, allowedPositions, etc. + * Must be executed in the server. + * + * Arguments: + * 0: Vehicle (default: objNull) + * 1: Rack classname to remove (default: "") + * 2: Rack classname to add (default: "") + * 3: Condition called with argument "_unit" for rack init. If a longer function is given, it should be precompiled. (default: {}) + * + * Return Value: + * Racks replaced successfully + * + * Example: + * [cursorTarget, "ACRE_VRC103", "ACRE_VRC64", {}] call acre_api_fnc_replaceRacksOnVehicle + * + * Public: Yes + */ + +params [ + ["_vehicle", objNull, [objNull]], + ["_fromRack", "", [""]], + ["_toRack", "", [""]], + ["_condition", {}, [{}]] +]; + +if (!isServer) exitWith { + WARNING("Function must be called on the server."); + false +}; + +if (isNull _vehicle) exitWith { + WARNING_1("Trying to remove a rack from an undefined vehicle %1",_vehicle); + false +}; + +if (_fromRack == "" || {_toRack == ""}) exitWith { + WARNING_1("Racks to replace on vehicle %1 were not defined",_vehicle); + false +}; + +if (_fromRack == _toRack) exitWith { + WARNING_1("Racks on vehicle %1 and intended replacements are the same",_vehicle); + false +}; + +// Store the desired Rack replacement as an object var which will be handled by sys_rack/fnc_initVehicle on the next initialization +_vehicle setVariable [QEGVAR(sys_rack,replaceRacks), [_fromRack, _toRack], true]; + +if ([_vehicle] call FUNC(areVehicleRacksInitialized)) then { + // If Racks have already been initialized, revert the initialization to run this function again + [_vehicle, _condition] call FUNC(removeAllRacksFromVehicle); + + [{ + params ["_vehicle"]; + (_vehicle getVariable [QEGVAR(sys_rack,vehicleRacks), []]) isEqualTo [] + }, { + params ["_vehicle"]; + + _vehicle setVariable [QEGVAR(sys_rack,initialized), false, true]; + + private _success = true; + WARNING_1("Forcing initialisation of vehicle %1 in order to alter all racks",_vehicle); + _success = [_vehicle, _condition] call EFUNC(api,initVehicleRacks); + + if (!_success) exitWith { + WARNING_1("Vehicle %1 failed to initialise",_vehicle); + }; + }, [_vehicle]] call CBA_fnc_waitUntilAndExecute; +}; + +true diff --git a/addons/sys_rack/fnc_initVehicle.sqf b/addons/sys_rack/fnc_initVehicle.sqf index 786d288a1..05bba18eb 100644 --- a/addons/sys_rack/fnc_initVehicle.sqf +++ b/addons/sys_rack/fnc_initVehicle.sqf @@ -26,14 +26,38 @@ if (!_initialized) then { _vehicle setVariable [QGVAR(initialized), true, true]; }; + // Handle acre_api_fnc_replaceRacksOnVehicle having defined a Rack class to replace + private _replaceVar = _vehicle getVariable [QGVAR(replaceRacks), false]; + private ["_fromRack", "_toRack"]; + if (_replaceVar isEqualType []) then { + _fromRack = _replaceVar select 0; + _toRack = _replaceVar select 1; + _vehicle setVariable [QGVAR(replaceRacks), false, true]; + }; + { private _componentName = getText (_x >> "componentName"); + + private ["_componentName", "_components", "_mountedRadio"]; + if (!isNil "_toRack" && {_componentName == _fromRack}) then { + private _toRackConfig = configFile >> "CfgAcreRacks" >> _toRack; + _componentName = _toRack; + _components = getArray (_toRackConfig >> "defaultComponents"); + _mountedRadio = switch (_toRack) do { + case "ACRE_VRC64": { "ACRE_PRC77" }; + case "ACRE_VRC103": { "ACRE_PRC117F" }; + case "ACRE_SEM90": { "ACRE_SEM70" }; + default { "" }; + }; + } else { + _components = getArray (_x >> "defaultComponents"); + _mountedRadio = getText (_x >> "mountedRadio"); + }; + private _displayName = getText (_x >> "displayName"); private _shortName = getText (_x >> "shortName"); private _allowed = [_vehicle, getArray (_x >> "allowedPositions")] call EFUNC(sys_core,processVehicleSystemAccessArray); private _disabled = [_vehicle, getArray (_x >> "disabledPositions")] call EFUNC(sys_core,processVehicleSystemAccessArray); - private _components = getArray (_x >> "defaultComponents"); - private _mountedRadio = getText (_x >> "mountedRadio"); private _isRadioRemovable = getNumber (_x >> "isRadioRemovable") == 1; private _intercoms = [_vehicle, _x] call FUNC(configWiredIntercoms); From 1c46a44788d4730b13b1e4edd5e546d624aeb44b Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Thu, 25 Jul 2024 15:29:48 +0200 Subject: [PATCH 06/15] Better italian+german short dash names --- addons/sys_rack/stringtable.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/sys_rack/stringtable.xml b/addons/sys_rack/stringtable.xml index b4cac421c..0e0a56613 100644 --- a/addons/sys_rack/stringtable.xml +++ b/addons/sys_rack/stringtable.xml @@ -152,13 +152,13 @@ Dash - Cruscotto + Crus. DB 儀器版面 下 仪器版面 下 Panel Panneau - Anschluss + An. Панель Painel Panel @@ -186,7 +186,7 @@ 仪器.下 P.Inf P. inf - Unten + An.U Н-я панель P. Inf. A.Pan @@ -214,7 +214,7 @@ 仪器.上 P.Sup P. sup - Oben + An.O В-я панель P. Sup. Ü.Pan From a2ddda4a876590ba28997a1432b52a4e364f5206 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:30:59 +0200 Subject: [PATCH 07/15] Fix typo in docs --- addons/api/fnc_removeRackFromVehicle.sqf | 2 +- addons/api/fnc_replaceRacksOnVehicle.sqf | 2 +- docs/_includes/custom/functions-list-api.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/api/fnc_removeRackFromVehicle.sqf b/addons/api/fnc_removeRackFromVehicle.sqf index e453b6fc7..c71c77f1b 100644 --- a/addons/api/fnc_removeRackFromVehicle.sqf +++ b/addons/api/fnc_removeRackFromVehicle.sqf @@ -1,7 +1,7 @@ #include "script_component.hpp" /* * Author: ACRE2Team - * Removes a specific Rack from a vehicle. Must be executed in the server. + * Removes a specific Rack from a vehicle. Must be executed on the server. * * Arguments: * 0: Vehicle (default: objNull) diff --git a/addons/api/fnc_replaceRacksOnVehicle.sqf b/addons/api/fnc_replaceRacksOnVehicle.sqf index ebd683601..278c08594 100644 --- a/addons/api/fnc_replaceRacksOnVehicle.sqf +++ b/addons/api/fnc_replaceRacksOnVehicle.sqf @@ -2,7 +2,7 @@ /* * Author: mrschick * Replaces all config-defined Racks on a vehicle with a different class of Rack, while keeping the same name, allowedPositions, etc. - * Must be executed in the server. + * Must be executed on the server. * * Arguments: * 0: Vehicle (default: objNull) diff --git a/docs/_includes/custom/functions-list-api.html b/docs/_includes/custom/functions-list-api.html index 725621f99..a40dd617f 100644 --- a/docs/_includes/custom/functions-list-api.html +++ b/docs/_includes/custom/functions-list-api.html @@ -1641,7 +1641,7 @@ ### acre_api_fnc_removeRackFromVehicle __Description__ -Initialises all racks in the vehicle. Must be executed in the server. +Removes a specific Rack from a vehicle. Must be executed on the server. __Parameters__ From 5810369c13d70afcf65c0ee9ba7a5cf4d4f24ead Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 29 Jul 2024 18:32:04 +0200 Subject: [PATCH 08/15] Remove redundant condition argument --- addons/api/fnc_removeAllRacksFromVehicle.sqf | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/addons/api/fnc_removeAllRacksFromVehicle.sqf b/addons/api/fnc_removeAllRacksFromVehicle.sqf index 2edf7cad5..929aab688 100644 --- a/addons/api/fnc_removeAllRacksFromVehicle.sqf +++ b/addons/api/fnc_removeAllRacksFromVehicle.sqf @@ -1,24 +1,22 @@ #include "script_component.hpp" /* * Author: mrschick - * Removes all Racks from a vehicle. Must be executed in the server. + * Removes all Racks from a vehicle. Must be executed on the server. * * Arguments: * 0: Vehicle (default: objNull) - * 1: Condition called with argument "_unit" for rack init. If a longer function is given, it should be precompiled. (default: {}) * * Return Value: * Racks removed successfully * * Example: - * [cursorTarget, {}] call acre_api_fnc_removeAllRacksFromVehicle + * [cursorTarget] call acre_api_fnc_removeAllRacksFromVehicle * * Public: Yes */ params [ - ["_vehicle", objNull, [objNull]], - ["_condition", {}, [{}]] + ["_vehicle", objNull, [objNull]] ]; if (!isServer) exitWith { @@ -35,7 +33,7 @@ private _success = true; if (!([_vehicle] call FUNC(areVehicleRacksInitialized))) then { WARNING_1("Forcing initialisation of vehicle %1 in order to remove all racks",_vehicle); - _success = [_vehicle, _condition] call EFUNC(api,initVehicleRacks); + _success = [_vehicle] call EFUNC(api,initVehicleRacks); }; if (!_success) exitWith { From b4a0591de1f9dca2364b4fe61a2b2914c82e334b Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 29 Jul 2024 19:07:00 +0200 Subject: [PATCH 09/15] Update Documentation --- docs/_includes/custom/functions-list-api.html | 56 +++++++++++++++++++ docs/wiki/frameworks/vehicle-racks.md | 2 + 2 files changed, 58 insertions(+) diff --git a/docs/_includes/custom/functions-list-api.html b/docs/_includes/custom/functions-list-api.html index a40dd617f..fa9ef2fd7 100644 --- a/docs/_includes/custom/functions-list-api.html +++ b/docs/_includes/custom/functions-list-api.html @@ -1663,6 +1663,62 @@ ``` +--- + +### acre_api_fnc_removeAllRacksFromVehicle +__Description__ + +Removes all Racks from a vehicle. Must be executed on the server. + +__Parameters__ + +Index | Description | Datatype(s) | Default Value +--- | --- | --- | --- +0 | Vehicle | OBJECT | objNull + +__Return Value__ + +Description | Datatype(s) +--- | --- +Racks removed successfully | BOOL + +__Example__ + +```sqf +[cursorTarget] call acre_api_fnc_removeAllRacksFromVehicle +``` + + +--- + +### acre_api_fnc_replaceRacksOnVehicle +__Description__ + +Replaces all config-defined Racks on a vehicle with a different class of Rack, while keeping the same name, allowedPositions, etc. +Must be executed on the server. + +__Parameters__ + +Index | Description | Datatype(s) | Default Value +--- | --- | --- | --- +0 | Vehicle | OBJECT | objNull +1 | Rack classname to remove | STRING | "" +2 | Rack classname to add | STRING | "" +3 | Condition called with argument "_unit" for rack init. If a longer function is given, it should be precompiled. | CODE | {} + +__Return Value__ + +Description | Datatype(s) +--- | --- +Racks replaced successfully | BOOL + +__Example__ + +```sqf +[cursorTarget, "ACRE_VRC103", "ACRE_VRC64", {}] call acre_api_fnc_replaceRacksOnVehicle +``` + + --- ### acre_api_fnc_getBaseRadio diff --git a/docs/wiki/frameworks/vehicle-racks.md b/docs/wiki/frameworks/vehicle-racks.md index ab1599516..1da22a726 100644 --- a/docs/wiki/frameworks/vehicle-racks.md +++ b/docs/wiki/frameworks/vehicle-racks.md @@ -227,4 +227,6 @@ Racks can also be dynamically added, removed or initialised using API functions. It is possible through this API function to add and initialise a rack on non-enterable objects like drones or communication tables. - `acre_api_fnc_removeRackFromVehicle` allows removing a rack with a unique ID from a vehicle. +- `acre_api_fnc_removeAllRacksFromVehicle` removes all racks from a vehicle. - `acre_api_fnc_initVehicleRacks` initialises all racks in a vehicle. This API function can be used to initialise racks on non-enterable vehicles. +- `acre_api_fnc_replaceRacksOnVehicle` can be used to replace the config-defined racks of a vehicle with a different rack class. From 64d877c9a8a0da8d6a7f2e8608717833669c2591 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 29 Jul 2024 23:12:44 +0200 Subject: [PATCH 10/15] Remove condition argument on function call --- addons/api/fnc_replaceRacksOnVehicle.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/api/fnc_replaceRacksOnVehicle.sqf b/addons/api/fnc_replaceRacksOnVehicle.sqf index 278c08594..e62ce033a 100644 --- a/addons/api/fnc_replaceRacksOnVehicle.sqf +++ b/addons/api/fnc_replaceRacksOnVehicle.sqf @@ -51,7 +51,7 @@ _vehicle setVariable [QEGVAR(sys_rack,replaceRacks), [_fromRack, _toRack], true] if ([_vehicle] call FUNC(areVehicleRacksInitialized)) then { // If Racks have already been initialized, revert the initialization to run this function again - [_vehicle, _condition] call FUNC(removeAllRacksFromVehicle); + [_vehicle] call FUNC(removeAllRacksFromVehicle); [{ params ["_vehicle"]; From 76c5e72c7420398724693d3975a73bc34d78dc89 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Tue, 30 Jul 2024 00:14:22 +0200 Subject: [PATCH 11/15] Show PRC77 Frequency in VRC64 child actions --- addons/sys_rack/fnc_rackChildrenActions.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/sys_rack/fnc_rackChildrenActions.sqf b/addons/sys_rack/fnc_rackChildrenActions.sqf index 8454a7777..aadf6ac02 100644 --- a/addons/sys_rack/fnc_rackChildrenActions.sqf +++ b/addons/sys_rack/fnc_rackChildrenActions.sqf @@ -41,7 +41,7 @@ if (_mountedRadio == "") then { // Empty } else { private _class = configFile >> "CfgWeapons" >> _mountedRadio; private _currentChannel = [_mountedRadio] call EFUNC(api,getRadioChannel); - private _displayName = format [localize ELSTRING(ace_interact,channelShort), getText (_class >> "displayName"), _currentChannel]; + private _displayName = [_mountedRadio] call EFUNC(sys_core,getDescriptiveName); private _icon = getText (_class >> "picture"); // General radio From 6ee019adde2ec7c4cdcd92ffbd696c9b6e79fc62 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 4 Aug 2024 22:17:33 +0200 Subject: [PATCH 12/15] Refactor fnc_enterVehicle Exit Condition --- addons/sys_rack/fnc_enterVehicle.sqf | 60 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/addons/sys_rack/fnc_enterVehicle.sqf b/addons/sys_rack/fnc_enterVehicle.sqf index 5cf5aead4..a477f9f4f 100644 --- a/addons/sys_rack/fnc_enterVehicle.sqf +++ b/addons/sys_rack/fnc_enterVehicle.sqf @@ -18,31 +18,22 @@ params ["_vehicle", "_unit"]; -if (_unit != _vehicle) then { - private _initialized = _vehicle getVariable [QGVAR(initialized), false]; - - if (!_initialized) then { - // Only initialize if we are first in the crew array - This helps prevent multiple requests if multiple players enter a vehicle around the same time. - private _crew = [_vehicle] call EFUNC(sys_core,getPlayersInVehicle); - private _firstPlayer = objNull; - { - if (!isNull _x) exitWith { - _firstPlayer = _x; - }; - } forEach _crew; - - if (!isNull _firstPlayer) then { - if (_unit == _firstPlayer) then { - [_vehicle] call FUNC(initVehicle); - - // Give some time for the racks to initialise properly - [{ - [_this select 0] call FUNC(configureRackIntercom); - // Update the display - [_this select 0, _this select 1] call EFUNC(sys_intercom,updateVehicleInfoText); - }, [_vehicle, _unit], 0.5] call CBA_fnc_waitAndExecute; - }; - } else { // No other players. +if (_unit == _vehicle) exitWith {}; + +private _initialized = _vehicle getVariable [QGVAR(initialized), false]; + +if (!_initialized) then { + // Only initialize if we are first in the crew array - This helps prevent multiple requests if multiple players enter a vehicle around the same time. + private _crew = [_vehicle] call EFUNC(sys_core,getPlayersInVehicle); + private _firstPlayer = objNull; + { + if (!isNull _x) exitWith { + _firstPlayer = _x; + }; + } forEach _crew; + + if (!isNull _firstPlayer) then { + if (_unit == _firstPlayer) then { [_vehicle] call FUNC(initVehicle); // Give some time for the racks to initialise properly @@ -52,11 +43,20 @@ if (_unit != _vehicle) then { [_this select 0, _this select 1] call EFUNC(sys_intercom,updateVehicleInfoText); }, [_vehicle, _unit], 0.5] call CBA_fnc_waitAndExecute; }; - }; + } else { // No other players. + [_vehicle] call FUNC(initVehicle); - // Enable the PFH if it is not active (can only be active if the unit is using an external radio before entering the vehicle) - if (GVAR(rackPFH) == -1) then { - GVAR(rackPFH) = [DFUNC(rackPFH), 1, [_unit, _vehicle]] call CBA_fnc_addPerFrameHandler; - TRACE_1("rack PFH",GVAR(rackPFH)); + // Give some time for the racks to initialise properly + [{ + [_this select 0] call FUNC(configureRackIntercom); + // Update the display + [_this select 0, _this select 1] call EFUNC(sys_intercom,updateVehicleInfoText); + }, [_vehicle, _unit], 0.5] call CBA_fnc_waitAndExecute; }; }; + +// Enable the PFH if it is not active (can only be active if the unit is using an external radio before entering the vehicle) +if (GVAR(rackPFH) == -1) then { + GVAR(rackPFH) = [DFUNC(rackPFH), 1, [_unit, _vehicle]] call CBA_fnc_addPerFrameHandler; + TRACE_1("rack PFH",GVAR(rackPFH)); +}; From 0a041d4047eb52f72c472f2b9a9d0f99c661e0f5 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 5 Aug 2024 08:24:39 +0200 Subject: [PATCH 13/15] Store Vehicle-specific PTT Assignments --- addons/api/fnc_setMultiPushToTalkAssignment.sqf | 6 ++++++ addons/sys_rack/fnc_enterVehicle.sqf | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/addons/api/fnc_setMultiPushToTalkAssignment.sqf b/addons/api/fnc_setMultiPushToTalkAssignment.sqf index b8648da26..cb10cd232 100644 --- a/addons/api/fnc_setMultiPushToTalkAssignment.sqf +++ b/addons/api/fnc_setMultiPushToTalkAssignment.sqf @@ -35,6 +35,12 @@ private _index = _var findIf { if (_index != -1) exitWith { false }; +// Save Rack PTT Assignments to vehicle +private _vehicle = objectParent acre_player; +if (!isNull _vehicle) then { + _vehicle setVariable [QEGVAR(sys_rack,MPTTAssignment), _var]; +}; + ACRE_ASSIGNED_PTT_RADIOS = _var; true diff --git a/addons/sys_rack/fnc_enterVehicle.sqf b/addons/sys_rack/fnc_enterVehicle.sqf index a477f9f4f..2f5f46ac7 100644 --- a/addons/sys_rack/fnc_enterVehicle.sqf +++ b/addons/sys_rack/fnc_enterVehicle.sqf @@ -60,3 +60,12 @@ if (GVAR(rackPFH) == -1) then { GVAR(rackPFH) = [DFUNC(rackPFH), 1, [_unit, _vehicle]] call CBA_fnc_addPerFrameHandler; TRACE_1("rack PFH",GVAR(rackPFH)); }; + +// Load saved PTT assignments of previously used Racks +private _vehiclePTTs = _vehicle getVariable [QGVAR(MPTTAssignment), []]; +if (_vehiclePTTs isNotEqualTo []) then { + { + [_vehicle, _unit, _x] call FUNC(startUsingMountedRadio); + } forEach _vehiclePTTs; + [_vehiclePTTs] call EFUNC(api,setMultiPushToTalkAssignment); +}; From 0b2875c67d306b206f40dd5f4b811f19de873238 Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Mon, 5 Aug 2024 14:24:52 +0200 Subject: [PATCH 14/15] Re-Use Racks when Re-Entering Vehicle Position --- addons/sys_intercom/fnc_getStationVariableName.sqf | 5 +++-- addons/sys_rack/fnc_enterVehicle.sqf | 12 +++++++++--- addons/sys_rack/fnc_startUsingMountedRadio.sqf | 8 ++++++++ addons/sys_rack/fnc_stopUsingMountedRadio.sqf | 8 ++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/addons/sys_intercom/fnc_getStationVariableName.sqf b/addons/sys_intercom/fnc_getStationVariableName.sqf index 9a25a514e..e95ef9961 100644 --- a/addons/sys_intercom/fnc_getStationVariableName.sqf +++ b/addons/sys_intercom/fnc_getStationVariableName.sqf @@ -6,6 +6,7 @@ * Arguments: * 0: Vehicle with intercom * 1: Unit to be checked + * 2: Component prefix for the variable name (default: "acre_sys_intercom_station_%1") * * Return Value: * Variable name, string of length 0 if not found @@ -16,14 +17,14 @@ * Public: No */ -params ["_vehicle", "_unit"]; +params ["_vehicle", "_unit", ["_prefix", QGVAR(station_%1)]]; private _found = false; private _varName = ""; { if (_unit isEqualTo (_x select 0)) exitWith { private _role = toLower (_x select 1); - _varName = format [QGVAR(station_%1), _role]; + _varName = format [_prefix, _role]; if (_role in ["cargo", "turret"]) then { if (_role isEqualTo "cargo") then { _varName = format ["%1_%2", _varName, _x select 2]; diff --git a/addons/sys_rack/fnc_enterVehicle.sqf b/addons/sys_rack/fnc_enterVehicle.sqf index 2f5f46ac7..0995a0b55 100644 --- a/addons/sys_rack/fnc_enterVehicle.sqf +++ b/addons/sys_rack/fnc_enterVehicle.sqf @@ -61,11 +61,17 @@ if (GVAR(rackPFH) == -1) then { TRACE_1("rack PFH",GVAR(rackPFH)); }; +// Re-Use stored radios for the current position +private _varName = [_vehicle, _unit, QGVAR(usedRacks_%1)] call EFUNC(sys_intercom,getStationVariableName); +if (_varName isNotEqualTo "") then { + private _usedRacks = _vehicle getVariable [_varName, []]; + { + [_vehicle, _unit, _x] call FUNC(startUsingMountedRadio); + } forEach _usedRacks; +}; + // Load saved PTT assignments of previously used Racks private _vehiclePTTs = _vehicle getVariable [QGVAR(MPTTAssignment), []]; if (_vehiclePTTs isNotEqualTo []) then { - { - [_vehicle, _unit, _x] call FUNC(startUsingMountedRadio); - } forEach _vehiclePTTs; [_vehiclePTTs] call EFUNC(api,setMultiPushToTalkAssignment); }; diff --git a/addons/sys_rack/fnc_startUsingMountedRadio.sqf b/addons/sys_rack/fnc_startUsingMountedRadio.sqf index c34b624ff..05e48cc69 100644 --- a/addons/sys_rack/fnc_startUsingMountedRadio.sqf +++ b/addons/sys_rack/fnc_startUsingMountedRadio.sqf @@ -36,5 +36,13 @@ if (GVAR(rackPFH) == -1) then { GVAR(rackPFH) = [DFUNC(rackPFH), 1.1, [_unit, _vehicle]] call CBA_fnc_addPerFrameHandler; }; +// Locally store radio use status for the current position in vehicle +private _varName = [_vehicle, _unit, QGVAR(usedRacks_%1)] call EFUNC(sys_intercom,getStationVariableName); +if (_varName isNotEqualTo "") then { + private _usedRacks = _vehicle getVariable [_varName, []]; + _usedRacks pushBackUnique _radioId; + _vehicle setVariable [_varName, _usedRacks]; +}; + // Update the display [_vehicle, _unit] call EFUNC(sys_intercom,updateVehicleInfoText); diff --git a/addons/sys_rack/fnc_stopUsingMountedRadio.sqf b/addons/sys_rack/fnc_stopUsingMountedRadio.sqf index ff54472ad..8606ba7be 100644 --- a/addons/sys_rack/fnc_stopUsingMountedRadio.sqf +++ b/addons/sys_rack/fnc_stopUsingMountedRadio.sqf @@ -25,5 +25,13 @@ if (_radioId in ACRE_ACCESSIBLE_RACK_RADIOS) then { [_radioId] call EFUNC(sys_radio,stopUsingRadio); +// Remove radio use status for the current position in vehicle +private _varName = [_vehicle, _unit, QGVAR(usedRacks_%1)] call EFUNC(sys_intercom,getStationVariableName); +if (_varName isNotEqualTo "") then { + private _usedRacks = _vehicle getVariable [_varName, []]; + _usedRacks deleteAt (_usedRacks find _radioId); + _vehicle setVariable [_varName, _usedRacks]; +}; + // Update the display [_vehicle, _unit] call EFUNC(sys_intercom,updateVehicleInfoText); From 095bac7366997f773076a9a7643c01e5fbe5f4fa Mon Sep 17 00:00:00 2001 From: mrschick <58027418+mrschick@users.noreply.github.com> Date: Sun, 11 Aug 2024 13:54:26 +0200 Subject: [PATCH 15/15] Fix VehicleInfoText overflowing with long Rack Names --- addons/sys_gui/RscTitles.hpp | 2 +- addons/sys_gui/fnc_updateVehicleInfo.sqf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sys_gui/RscTitles.hpp b/addons/sys_gui/RscTitles.hpp index 2e51e0b5e..65c851dc6 100644 --- a/addons/sys_gui/RscTitles.hpp +++ b/addons/sys_gui/RscTitles.hpp @@ -50,7 +50,7 @@ class RscTitles { }; class VehicleInfoText: RscStructuredText { idc = 2; - w = QUOTE(10 * VEHICLE_INFO_DEFAULT_W); // Must be specifically widened + w = QUOTE(VEHICLE_INFO_DEFAULT_W); }; }; }; diff --git a/addons/sys_gui/fnc_updateVehicleInfo.sqf b/addons/sys_gui/fnc_updateVehicleInfo.sqf index 2af187c7e..f1f9b0035 100644 --- a/addons/sys_gui/fnc_updateVehicleInfo.sqf +++ b/addons/sys_gui/fnc_updateVehicleInfo.sqf @@ -30,7 +30,7 @@ _ctrlText ctrlSetStructuredText parseText _str; // Calculate new height (3 elements per row) private _rows = ceil ((1 max _elements) / 3); -private _newBaseH = (((safezoneW / safezoneH) min 1.2) / 1.2) / 25; +private _newBaseH = (((safezoneW / safezoneH) min 1.2) / 1.2) / 23; private _newH = _newBaseH * _rows; private _newContainerH = (0.8 * _newH) + 0.001; TRACE_4("vehicle info height",_elements,_rows,_newH,_newContainerH);