From 5a075855fc7d24c86aea5c8f1a39221c0d54faba Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 02:09:28 +0100 Subject: [PATCH 01/10] Optimize fnc_hasTracker 0.0109 ms _x = "UavTerminal_F"; ["UavTerminal", _x] call BIS_fnc_inString 0.0017 ms _x = "UavTerminal_F"; "uavterminal" in toLower _x --- addons/friendly_tracker/functions/fnc_hasTracker.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/friendly_tracker/functions/fnc_hasTracker.sqf b/addons/friendly_tracker/functions/fnc_hasTracker.sqf index c14d4d6..457d020 100644 --- a/addons/friendly_tracker/functions/fnc_hasTracker.sqf +++ b/addons/friendly_tracker/functions/fnc_hasTracker.sqf @@ -17,4 +17,4 @@ params ["_unit"]; -((assignedItems _unit findIf {_x isEqualTo "ItemGPS" || {["UavTerminal", _x] call BIS_fnc_inString}}) != -1) +((assignedItems _unit findIf {_x isEqualTo "ItemGPS" || {"uavterminal" in toLower _x}}) != -1) From 9941f6599bd57412ae294ec1ee1278a2d626b1e5 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 02:24:04 +0100 Subject: [PATCH 02/10] Fix fnc_isTrackable always using more expensive check --- addons/friendly_tracker/functions/fnc_isTrackable.sqf | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/friendly_tracker/functions/fnc_isTrackable.sqf b/addons/friendly_tracker/functions/fnc_isTrackable.sqf index e54cfd3..ce2372f 100644 --- a/addons/friendly_tracker/functions/fnc_isTrackable.sqf +++ b/addons/friendly_tracker/functions/fnc_isTrackable.sqf @@ -29,9 +29,10 @@ if (!GVAR(showInvisible) && {isObjectHidden _object}) exitWith {false}; // If GPS mode is disabled all object are trackable. if (!GVAR(GPS)) exitWith {true}; -// If object is vehicle check if anyone inside has tracker -if (_object isKindOf "AllVehicles") exitWith { - (crew _object) findIf {[_x] call FUNC(hasTracker)} != -1 +// If object is Human check if has tracker +if (_object isKindOf "CAManBase") exitWith { + [_object] call FUNC(hasTracker) // return }; -[_object] call FUNC(hasTracker); +// If object is vehicle check if crew has tracker +(crew _object) findIf {[_x] call FUNC(hasTracker)} != -1 // return From 290e1cd658aeb40a0484e42268a80554b5bdf2d6 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 02:53:57 +0100 Subject: [PATCH 03/10] Add fnc_hasTrackerVehicle --- .../functions/fnc_hasTrackerVehicle.sqf | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf diff --git a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf new file mode 100644 index 0000000..42ea8f1 --- /dev/null +++ b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf @@ -0,0 +1,20 @@ +#include "script_component.hpp" +/* + * Author: 3Mydlo3 + * Function checks if vehicle has tracking capabilities + * + * Arguments: + * 0: The vehicle that will be checked if it has a tracking capabilities + * + * Return Value: + * 0: Has tracker + * + * Example: + * [bob] call afft_friendly_tracker_fnc_hasTrackerVehicle + * + * Public: No + */ + +params ["_vehicle"]; + +getNumber (configOf _vehicle >> "enableGPS") == 1 // return From d46ed27fadcf8517c4ad82a300e91b25651bcdb4 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 02:54:16 +0100 Subject: [PATCH 04/10] Allow tracking when in vehicle with tracker --- addons/friendly_tracker/functions/fnc_canTrack.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/friendly_tracker/functions/fnc_canTrack.sqf b/addons/friendly_tracker/functions/fnc_canTrack.sqf index 4639e00..5277fc5 100644 --- a/addons/friendly_tracker/functions/fnc_canTrack.sqf +++ b/addons/friendly_tracker/functions/fnc_canTrack.sqf @@ -20,4 +20,4 @@ params ["_object"]; // If GPS mode is disabled all units can track. if (!GVAR(GPS)) exitWith {true}; -[_object] call FUNC(hasTracker) +_object call FUNC(hasTracker) || {vehicle _object call FUNC(hasTrackerVehicle)} From 6c0adf3eccfa0d4efe847a8c23e9b87eccaa4751 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 02:54:49 +0100 Subject: [PATCH 05/10] Allow being tracked when in vehicle with tracker --- addons/friendly_tracker/functions/fnc_isTrackable.sqf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/addons/friendly_tracker/functions/fnc_isTrackable.sqf b/addons/friendly_tracker/functions/fnc_isTrackable.sqf index ce2372f..8264125 100644 --- a/addons/friendly_tracker/functions/fnc_isTrackable.sqf +++ b/addons/friendly_tracker/functions/fnc_isTrackable.sqf @@ -29,10 +29,10 @@ if (!GVAR(showInvisible) && {isObjectHidden _object}) exitWith {false}; // If GPS mode is disabled all object are trackable. if (!GVAR(GPS)) exitWith {true}; -// If object is Human check if has tracker +// If object is Human check if has tracker or is in vehicle with tracker if (_object isKindOf "CAManBase") exitWith { - [_object] call FUNC(hasTracker) // return + _object call FUNC(hasTracker) || {vehicle _object call FUNC(hasTrackerVehicle)} // return }; -// If object is vehicle check if crew has tracker -(crew _object) findIf {[_x] call FUNC(hasTracker)} != -1 // return +// If object is vehicle check if it has tracker or its crew has tracker +_object call FUNC(hasTrackerVehicle) || (crew _object) findIf {_x call FUNC(hasTracker)} != -1 // return From 550f2414b2d051b2475bad923ea0f13dd94a4815 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 02:55:10 +0100 Subject: [PATCH 06/10] Add missing prep --- addons/friendly_tracker/XEH_PREP.hpp | 1 + addons/friendly_tracker/functions/fnc_hasTracker.sqf | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/friendly_tracker/XEH_PREP.hpp b/addons/friendly_tracker/XEH_PREP.hpp index e02ca0b..3ac5e88 100644 --- a/addons/friendly_tracker/XEH_PREP.hpp +++ b/addons/friendly_tracker/XEH_PREP.hpp @@ -12,4 +12,5 @@ PREP(getVehicleMarkerType); PREP(canTrack); PREP(getTrackedSides); PREP(hasTracker); +PREP(hasTrackerVehicle); PREP(isTrackable); diff --git a/addons/friendly_tracker/functions/fnc_hasTracker.sqf b/addons/friendly_tracker/functions/fnc_hasTracker.sqf index 457d020..15b62fa 100644 --- a/addons/friendly_tracker/functions/fnc_hasTracker.sqf +++ b/addons/friendly_tracker/functions/fnc_hasTracker.sqf @@ -17,4 +17,4 @@ params ["_unit"]; -((assignedItems _unit findIf {_x isEqualTo "ItemGPS" || {"uavterminal" in toLower _x}}) != -1) +((assignedItems _unit findIf {_x isEqualTo "ItemGPS" || {"uavterminal" in toLower _x}}) != -1) // return From 220a4eadbeb7e4ff397bae6cc91fcfe4ebd12b54 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 02:59:08 +0100 Subject: [PATCH 07/10] Add vehicle tracker capabilities setting --- .../friendly_tracker/functions/fnc_hasTrackerVehicle.sqf | 2 ++ addons/friendly_tracker/initSettings.sqf | 9 +++++++++ addons/friendly_tracker/stringtable.xml | 8 ++++++++ 3 files changed, 19 insertions(+) diff --git a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf index 42ea8f1..30239c0 100644 --- a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf +++ b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf @@ -17,4 +17,6 @@ params ["_vehicle"]; +if (!GVAR(GPSVehicle)) exitWith {false}; + getNumber (configOf _vehicle >> "enableGPS") == 1 // return diff --git a/addons/friendly_tracker/initSettings.sqf b/addons/friendly_tracker/initSettings.sqf index fbc3d4a..7a5bcb8 100644 --- a/addons/friendly_tracker/initSettings.sqf +++ b/addons/friendly_tracker/initSettings.sqf @@ -92,3 +92,12 @@ false, true ] call CBA_fnc_addSetting; + +[ + QGVAR(GPSVehicle), + "CHECKBOX", + [LSTRING(GPSVehicle), LSTRING(GPSVehicle_Description)], + LSTRING(DisplayName), + true, + true +] call CBA_fnc_addSetting; diff --git a/addons/friendly_tracker/stringtable.xml b/addons/friendly_tracker/stringtable.xml index 4fe7680..3234680 100644 --- a/addons/friendly_tracker/stringtable.xml +++ b/addons/friendly_tracker/stringtable.xml @@ -109,5 +109,13 @@ When enabled only units with tracker in equipment will be visible on the map. To see other players you also need a tracker. Wymagaj trackera by pokazać jednostkę na mapie. By widzieć markery innych graczy również musisz mieć tracker. + + Use vehicle GPS as tracker + Używaj GPS pojazdu jako tracker + + + When enabled vehicles with GPS will provide tracking capabilities to its crew. + Gdy włączone pojazdy z GPS będą dostarczać funkcjonalność trackera swojej załodze. + From 72fabee645870d6e824d8f9df188e92c9e6601d8 Mon Sep 17 00:00:00 2001 From: Filip Maciejewski Date: Fri, 30 Oct 2020 03:06:49 +0100 Subject: [PATCH 08/10] Edit author --- addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf index 30239c0..8d00397 100644 --- a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf +++ b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf @@ -1,6 +1,6 @@ #include "script_component.hpp" /* - * Author: 3Mydlo3 + * Author: veteran29 * Function checks if vehicle has tracking capabilities * * Arguments: From 1180a0824773fa7c305b7f166696a6c5f0ea61d1 Mon Sep 17 00:00:00 2001 From: 3Mydlo3 Date: Sun, 5 Dec 2021 20:30:06 +0100 Subject: [PATCH 09/10] Add vehicle GPS config caching --- addons/friendly_tracker/XEH_preInit.sqf | 2 ++ .../functions/fnc_hasTrackerVehicle.sqf | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/addons/friendly_tracker/XEH_preInit.sqf b/addons/friendly_tracker/XEH_preInit.sqf index a9d2a2b..a7b4632 100644 --- a/addons/friendly_tracker/XEH_preInit.sqf +++ b/addons/friendly_tracker/XEH_preInit.sqf @@ -11,4 +11,6 @@ GVAR(running) = false; GVAR(markers) = []; GVAR(trackedVehicles) = []; +GVAR(vehicleGpsCache) = call CBA_fnc_hashCreate; + ADDON = true; diff --git a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf index 8d00397..c5be2f5 100644 --- a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf +++ b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf @@ -19,4 +19,15 @@ params ["_vehicle"]; if (!GVAR(GPSVehicle)) exitWith {false}; -getNumber (configOf _vehicle >> "enableGPS") == 1 // return +private _vehicleConfig = configOf _vehicle; +private _vehicleConfigName = configName _vehicleConfig; + +private _enabledGps = [GVAR(vehicleGpsCache), _vehicleConfigName, ""] call CBA_fnc_hashGet; + +if (_enabledGps isEqualTo "") then { + _enabledGps = getNumber (_vehicleConfig >> "enableGPS") == 1; + [GVAR(vehicleGpsCache), _vehicleConfigName, _enabledGps] call CBA_fnc_hashSet; +}; + +// Return +_enabledGps From 5b4bb9740fd445f9df3bdfcb73aa62e5379d115b Mon Sep 17 00:00:00 2001 From: 3Mydlo3 Date: Sun, 5 Dec 2021 20:44:57 +0100 Subject: [PATCH 10/10] Support QGVAR(enabledGps) tracker override on vehicle --- addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf index c5be2f5..d4a3a16 100644 --- a/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf +++ b/addons/friendly_tracker/functions/fnc_hasTrackerVehicle.sqf @@ -19,10 +19,14 @@ params ["_vehicle"]; if (!GVAR(GPSVehicle)) exitWith {false}; +private _enabledGps = _vehicle getVariable [QGVAR(enabledGps), ""]; + +if (_enabledGps isEqualType true) exitWith {_enabledGps}; + private _vehicleConfig = configOf _vehicle; private _vehicleConfigName = configName _vehicleConfig; -private _enabledGps = [GVAR(vehicleGpsCache), _vehicleConfigName, ""] call CBA_fnc_hashGet; +_enabledGps = [GVAR(vehicleGpsCache), _vehicleConfigName, ""] call CBA_fnc_hashGet; if (_enabledGps isEqualTo "") then { _enabledGps = getNumber (_vehicleConfig >> "enableGPS") == 1;