-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vehicle GPS support #31
base: master
Are you sure you want to change the base?
Conversation
0.0109 ms _x = "UavTerminal_F"; ["UavTerminal", _x] call BIS_fnc_inString 0.0017 ms _x = "UavTerminal_F"; "uavterminal" in toLower _x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job.
|
||
if (!GVAR(GPSVehicle)) exitWith {false}; | ||
|
||
getNumber (configOf _vehicle >> "enableGPS") == 1 // return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to limit this only to configured vehicles? No support for custom variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't there a support to explicitly add certain object into tracker? It will have different color if I recall tho. 🤔 And also it would be shown when empty, not sure if it's necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I wonder if adding caching here would improve performance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching would be nice indeed.
Yep, there is support for adding tracker to objects but it's a bit different behaviour. But I guess we can leave it for now and maybe add this later if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've implemented caching and added ability to override config with afft_friendly_tracker_enabledGps
variable on vehicle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@3Mydlo3
Caching does not give any performance advantage in such simple config lookup, always benchmark never assume.
Also, CBA hashmaps should not be used anymore unless you need objects as keys. I do not understand why you've used them as they're the slowest implementation that you could use.
Benchmark:
Test code: player call fnc_getSide
Implementations:
No caching
fnc_getSide = {
private _side = _this getVariable ["side", ""];
if (_side isEqualType 0) exitWith {_side};
getNumber (configOf _this >> "side")
};
Execution Time: 0.0020 ms | Cycles: 10000/10000 | Total Time: 20 ms
Native HashMap
hash = createHashMap;
fnc_getSide = {
private _side = _this getVariable ["side", ""];
if (_side isEqualType 0) exitWith {_side};
private _config = configOf _this;
private _side = hash getOrDefault [_config, ""];
if (_side isEqualTo "") then {
_side = getNumber (_config >> "side");
hash set [_config, _side];
};
_side
};
Execution Time: 0.0026 ms | Cycles: 10000/10000 | Total Time: 26 ms
Object/Location namespace
hash = call CBA_fnc_createNamespace;
fnc_getSide = {
private _side = _this getVariable ["side", ""];
if (_side isEqualType 0) exitWith {_side};
private _config = configOf _this;
private _configName = configName _config;
private _side = hash getVariable [_configName, ""];
if (_side isEqualTo "") then {
_side = getNumber (_config >> "side");
hash setVariable [_configName, _side];
};
_side
};
Execution Time: 0.0029 ms | Cycles: 10000/10000 | Total Time: 29 ms
CBA Hash
(your implementation is even slower as you're using configName
but you can use configs as keys)
hash = call CBA_fnc_hashCreate;
fnc_getSide = {
private _side = _this getVariable ["side", ""];
if (_side isEqualType 0) exitWith {_side};
private _config = configOf _this;
private _side = [hash, _config, ""] call CBA_fnc_hashGet;
if (_side isEqualTo "") then {
_side = getNumber (_config >> "side");
[hash, _config, _side] call CBA_fnc_hashSet;
};
_side
};
Execution Time: 0.0046 ms | Cycles: 10000/10000 | Total Time: 46 ms
GVAR(vehicleGpsCache) = call CBA_fnc_hashCreate; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GVAR(vehicleGpsCache) = call CBA_fnc_hashCreate; |
private _enabledGps = _vehicle getVariable [QGVAR(enabledGps), ""]; | ||
|
||
if (_enabledGps isEqualType true) exitWith {_enabledGps}; | ||
|
||
private _vehicleConfig = configOf _vehicle; | ||
private _vehicleConfigName = configName _vehicleConfig; | ||
|
||
_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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Execution Time: 0.0021 ms | Cycles: 10000/10000 | Total Time: 21 ms
fnc_test1 = {
private _enabledGps = _this getVariable "test";
if (!isNil "_enabledGps") exitWith {
_enabledGps // return
};
getNumber (configOf _this >> "side") == 1 // return
};
// Execution Time: 0.0022 ms | Cycles: 10000/10000 | Total Time: 22 ms
fnc_test2 = {
private _enabledGps = _this getVariable ["test", ""];
if (_enabledGps isEqualType true) exitWith {
_enabledGps // return
};
getNumber (configOf _this >> "side") == 1 // return
};
// Execution Time: 0.0017 ms | Cycles: 10000/10000 | Total Time: 17 ms
fnc_test3 = {
_this getVariable ["test", getNumber (configOf _this >> "side") == 1] // return
};
private _enabledGps = _vehicle getVariable [QGVAR(enabledGps), ""]; | |
if (_enabledGps isEqualType true) exitWith {_enabledGps}; | |
private _vehicleConfig = configOf _vehicle; | |
private _vehicleConfigName = configName _vehicleConfig; | |
_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 | |
_vehicle getVariable [ | |
QGVAR(enabledGps), | |
getNumber (configOf _vehicle >> "enableGPS") == 1 | |
] // return |
I'll just stick to mission making. |
When merged this pull request will:
Closes #28