From 1f603cc814e21672b14714d76b0a75f3a9c7fb34 Mon Sep 17 00:00:00 2001 From: TheMagnetar Date: Mon, 29 Jan 2018 17:50:12 +0100 Subject: [PATCH] Cleanup. Do not access hash contents directly --- addons/bft_device_dk10/data/DK10.rvmat | 2 +- .../functions/fnc_canOpenDevice.sqf | 2 +- .../fnc_centerMapOnPlayerPosition.sqf | 4 ++-- .../bft_devices/functions/fnc_createUavCam.sqf | 4 ++-- .../bft_devices/functions/fnc_getSettings.sqf | 4 ++-- addons/bft_devices/functions/fnc_ifOnLoad.sqf | 5 +++-- addons/bft_devices/functions/fnc_ifUpdate.sqf | 18 +++++++++--------- .../functions/fnc_toggleIconText.sqf | 4 ++-- .../functions/fnc_toggleInterfaceMode.sqf | 2 +- .../functions/fnc_toggleMapMenu.sqf | 4 ++-- .../functions/fnc_toggleMapTools.sqf | 4 ++-- .../functions/fnc_toggleMapType.sqf | 15 +++++---------- .../functions/fnc_toggleNightMode.sqf | 10 +++++++--- 13 files changed, 39 insertions(+), 39 deletions(-) diff --git a/addons/bft_device_dk10/data/DK10.rvmat b/addons/bft_device_dk10/data/DK10.rvmat index c358caf778..7cf18092cb 100644 --- a/addons/bft_device_dk10/data/DK10.rvmat +++ b/addons/bft_device_dk10/data/DK10.rvmat @@ -80,7 +80,7 @@ class Stage6 }; class Stage7 { - texture="a3\data\env_land_co.paa"; + texture="a3\data_f\env_land_co.paa"; uvSource="none"; // uvSource="tex"; // class uvTransform diff --git a/addons/bft_devices/functions/fnc_canOpenDevice.sqf b/addons/bft_devices/functions/fnc_canOpenDevice.sqf index 2af9c19b94..79cbadc4bc 100644 --- a/addons/bft_devices/functions/fnc_canOpenDevice.sqf +++ b/addons/bft_devices/functions/fnc_canOpenDevice.sqf @@ -24,7 +24,7 @@ if (GVAR(ifOpenStart) || {GVAR(uavViewActive)} || {!I_CLOSED}) exitWith {false}; private _ownedDevices = [_target] call EFUNC(bft,getOwnedDevices); -if (count _ownedDevices == 0) exitwith {false}; +if (_ownedDevices isEqualTo []) exitwith {false}; private _return = false; { diff --git a/addons/bft_devices/functions/fnc_centerMapOnPlayerPosition.sqf b/addons/bft_devices/functions/fnc_centerMapOnPlayerPosition.sqf index be63c5f56a..900843a7df 100644 --- a/addons/bft_devices/functions/fnc_centerMapOnPlayerPosition.sqf +++ b/addons/bft_devices/functions/fnc_centerMapOnPlayerPosition.sqf @@ -18,6 +18,6 @@ #include "script_component.hpp" -[_this select 0,[["mapWorldPos",getPosASL vehicle ACE_player]],true,true] call FUNC(setSettings); +[_this select 0, [["mapWorldPos", getPosASL vehicle ACE_player]], true, true] call FUNC(setSettings); -true \ No newline at end of file +true diff --git a/addons/bft_devices/functions/fnc_createUavCam.sqf b/addons/bft_devices/functions/fnc_createUavCam.sqf index 4016631ee8..f6f3c8dbc5 100644 --- a/addons/bft_devices/functions/fnc_createUavCam.sqf +++ b/addons/bft_devices/functions/fnc_createUavCam.sqf @@ -88,9 +88,9 @@ if !(GVAR(UAVcams) isEqualTo []) exitWith { { if !(isNil "_x") then { _uav = _x select 0; - _cam = _x select 2; + private _cam = _x select 2; if (alive _uav) then { - _dir = (_uav selectionPosition (_x select 3)) vectorFromTo (_uav selectionPosition (_x select 4)); + private _dir = (_uav selectionPosition (_x select 3)) vectorFromTo (_uav selectionPosition (_x select 4)); _cam setVectorDirAndUp [_dir,_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]]; } else { [_cam] call FUNC(deleteUAVcam); diff --git a/addons/bft_devices/functions/fnc_getSettings.sqf b/addons/bft_devices/functions/fnc_getSettings.sqf index a7c7e12f4c..319124c5db 100644 --- a/addons/bft_devices/functions/fnc_getSettings.sqf +++ b/addons/bft_devices/functions/fnc_getSettings.sqf @@ -49,7 +49,7 @@ if (_property != "") exitWith { private _combinedProperties = +_commonProperties; systemChat format ["Device app data %1", _deviceAppData]; { - [_combinedProperties, _x, (_deviceAppData select 2) select _forEachIndex] call CBA_fnc_hashSet; -} forEach (_deviceAppData select 1); + [_combinedProperties, _x, [_deviceAppData, _x] call CBA_fnc_hashGet] call CBA_fnc_hashSet; +} forEach ([_deviceAppData] call CBA_fnc_hashKeys); _combinedProperties diff --git a/addons/bft_devices/functions/fnc_ifOnLoad.sqf b/addons/bft_devices/functions/fnc_ifOnLoad.sqf index f1c3bf1cf6..0fd01bb44e 100644 --- a/addons/bft_devices/functions/fnc_ifOnLoad.sqf +++ b/addons/bft_devices/functions/fnc_ifOnLoad.sqf @@ -26,9 +26,10 @@ uiNamespace setVariable [I_GET_NAME, _display]; // setup bft_drawing private _mapTypes = [I_GET_ID,"mapTypes"] call FUNC(getSettings); + { - 0 = [_display displayCtrl _x] call EFUNC(bft_drawing,doBFTDraw); -} count (_mapTypes select 2); + [_display displayCtrl ([_mapTypes, _x] call CBA_fnc_hashGet)] call EFUNC(bft_drawing,doBFTDraw); +} forEach ([_mapTypes] call CBA_fnc_hashKeys); // send "bft_deviceOpened" event ["bft_deviceOpened",[I_GET_DEVICE]] call CBA_fnc_localEvent; diff --git a/addons/bft_devices/functions/fnc_ifUpdate.sqf b/addons/bft_devices/functions/fnc_ifUpdate.sqf index f2b0d6ec98..597fd2cb94 100644 --- a/addons/bft_devices/functions/fnc_ifUpdate.sqf +++ b/addons/bft_devices/functions/fnc_ifUpdate.sqf @@ -1,5 +1,5 @@ /* - * Author: Gundy + * Author: Gundy, TheMagnetar * * Description: * Update current interface (display or dialog) to match current settings. @@ -59,7 +59,7 @@ if (isNil "_mode") then { { call { - private _value = (_settings select 2) select _forEachIndex; + private _value = [_settings, _x] call CBA_fnc_hashGet; if (isNil "_value") exitWith {}; // ------------ DISPLAY POSITION ------------ @@ -96,7 +96,7 @@ if (isNil "_mode") then { [0,0] } else { // reset to defaults - _backgroundPosition = [_displayName] call FUNC(getBackgroundPosition); + private _backgroundPosition = [_displayName] call FUNC(getBackgroundPosition); [(_backgroundPosition select 1 select 0) - (_backgroundPosition select 0 select 0),(_backgroundPosition select 1 select 1) - (_backgroundPosition select 0 select 1)] }; }; @@ -365,7 +365,7 @@ if (isNil "_mode") then { // ------------ MAP TYPE ------------ if (_x == "mapType") exitWith { private _mapTypes = [_interfaceID,"mapTypes"] call FUNC(getSettings); - if ((count (_mapTypes select 1) > 1) && (_mode == "BFT")) then { + if ((count ([_mapTypes] call CBA_fnc_hashKeys) > 1) && (_mode == "BFT")) then { private _targetMapName = _value; private _targetMapIDC = [_mapTypes, _targetMapName] call CBA_fnc_hashGet; _targetMapCtrl = _display displayCtrl _targetMapIDC; @@ -373,11 +373,11 @@ if (isNil "_mode") then { if (!_interfaceInit && _isDialog) then { private _previousMapCtrl = controlNull; { - private _previousMapIDC = (_mapTypes select 2) select _forEachIndex; + private _previousMapIDC = ([_mapTypes, _x] call CBA_fnc_hashGet); _previousMapCtrl = _display displayCtrl _previousMapIDC; if (ctrlShown _previousMapCtrl) exitWith {}; _previousMapCtrl = controlNull; - } forEach (_mapTypes select 1); + } forEach ([_mapTypes] call CBA_fnc_hashKeys); // See if _targetMapCtrl is already being shown if ((!ctrlShown _targetMapCtrl) && (_targetMapCtrl != _previousMapCtrl)) then { // Update _targetMapCtrl to scale and position of _previousMapCtrl @@ -389,9 +389,9 @@ if (isNil "_mode") then { // Hide all unwanted map types { if (_x != _targetMapName) then { - (_display displayCtrl ((_mapTypes select 2) select _forEachIndex)) ctrlShow false; + (_display displayCtrl ([_mapTypes, _x] call CBA_fnc_hashGet)) ctrlShow false; }; - } forEach (_mapTypes select 1); + } forEach ([_mapTypes] call CBA_fnc_hashKeys); // Update OSD element if it exists private _osdCtrl = _display displayCtrl IDC_OSD_MAP_TGGL; @@ -550,7 +550,7 @@ if (isNil "_mode") then { }; // ---------------------------------- }; -} forEach (_settings select 1); +} forEach ([_settings] call CBA_fnc_hashKeys); // update scale and world position if we have to. If so, fill in the blanks and make the changes if ((!isNil "_targetMapScale") || (!isNil "_targetMapWorldPos")) then { diff --git a/addons/bft_devices/functions/fnc_toggleIconText.sqf b/addons/bft_devices/functions/fnc_toggleIconText.sqf index f1180dbc32..4599b717b0 100644 --- a/addons/bft_devices/functions/fnc_toggleIconText.sqf +++ b/addons/bft_devices/functions/fnc_toggleIconText.sqf @@ -20,7 +20,7 @@ params ["_interfaceID"]; -private _showIconText = !([_interfaceID,"showIconText"] call FUNC(getSettings)); -[_interfaceID,[["showIconText",_showIconText]]] call FUNC(setSettings); +private _showIconText = !([_interfaceID, "showIconText"] call FUNC(getSettings)); +[_interfaceID, [["showIconText", _showIconText]]] call FUNC(setSettings); _showIconText diff --git a/addons/bft_devices/functions/fnc_toggleInterfaceMode.sqf b/addons/bft_devices/functions/fnc_toggleInterfaceMode.sqf index 9fb0833c4e..bcc5815f3c 100644 --- a/addons/bft_devices/functions/fnc_toggleInterfaceMode.sqf +++ b/addons/bft_devices/functions/fnc_toggleInterfaceMode.sqf @@ -32,6 +32,6 @@ call { }; }; }; -[_interfaceID,[["mode",_mode]]] call FUNC(setSettings); +[_interfaceID, [["mode",_mode]]] call FUNC(setSettings); true diff --git a/addons/bft_devices/functions/fnc_toggleMapMenu.sqf b/addons/bft_devices/functions/fnc_toggleMapMenu.sqf index 814b73e47c..1cd0f65e3b 100644 --- a/addons/bft_devices/functions/fnc_toggleMapMenu.sqf +++ b/addons/bft_devices/functions/fnc_toggleMapMenu.sqf @@ -20,7 +20,7 @@ params ["_interfaceID"]; -private _showMenu = [_interfaceID,"showMenu"] call FUNC(getSettings); -[_interfaceID,[["showMenu",!_showMenu]]] call FUNC(setSettings); +private _showMenu = [_interfaceID, "showMenu"] call FUNC(getSettings); +[_interfaceID, [["showMenu", !_showMenu]]] call FUNC(setSettings); true diff --git a/addons/bft_devices/functions/fnc_toggleMapTools.sqf b/addons/bft_devices/functions/fnc_toggleMapTools.sqf index 1ddd420024..c2f076caf3 100644 --- a/addons/bft_devices/functions/fnc_toggleMapTools.sqf +++ b/addons/bft_devices/functions/fnc_toggleMapTools.sqf @@ -20,7 +20,7 @@ params ["_interfaceID"]; -private _newMapTools = !([_interfaceID,"mapTools"] call FUNC(getSettings)); -[_interfaceID,[["mapTools",_newMapTools]]] call FUNC(setSettings); +private _newMapTools = !([_interfaceID, "mapTools"] call FUNC(getSettings)); +[_interfaceID, [["mapTools", _newMapTools]]] call FUNC(setSettings); _newMapTools diff --git a/addons/bft_devices/functions/fnc_toggleMapType.sqf b/addons/bft_devices/functions/fnc_toggleMapType.sqf index b5d0b4b7c4..61ecd5be8c 100644 --- a/addons/bft_devices/functions/fnc_toggleMapType.sqf +++ b/addons/bft_devices/functions/fnc_toggleMapType.sqf @@ -1,5 +1,5 @@ /* - * Author: Gundy + * Author: Gundy, TheMagnetar * * Description: * Toggle mapType to the next one in the list of available map types @@ -20,20 +20,15 @@ params ["_interfaceID"]; +// List of available map types private _mapTypesHash = [_interfaceID, "mapTypes"] call FUNC(getSettings); +private _mapTypes = [_mapTypesHash] call CBA_fnc_hashKeys; -private _mapTypes = _mapTypesHash select 1; -private _mapTypesIndexes = _mapTypesHash select 2; -systemChat format ["mapTypes %1", _mapTypes]; -systemChat format ["mapTypesIndexes %1", _mapTypesIndexes]; - +// Current map type private _currentMapType = [_interfaceID, "mapType"] call FUNC(getSettings); private _currentMapTypeIndex = _mapTypes find _currentMapType; -systemChat format ["currentMapType %1", _currentMapType]; -systemChat format ["currentMapIndex %1", _currentMapTypeIndex]; - -if (_currentMapTypeIndex == (count _mapTypesIndexes) - 1) then { +if (_currentMapTypeIndex == (count _mapTypes) - 1) then { [_interfaceID, [["mapType", _mapTypes select 0]]] call FUNC(setSettings); } else { [_interfaceID, [["mapType", _mapTypes select (_currentMapTypeIndex + 1)]]] call FUNC(setSettings); diff --git a/addons/bft_devices/functions/fnc_toggleNightMode.sqf b/addons/bft_devices/functions/fnc_toggleNightMode.sqf index 40f7ee5220..0705f829ef 100644 --- a/addons/bft_devices/functions/fnc_toggleNightMode.sqf +++ b/addons/bft_devices/functions/fnc_toggleNightMode.sqf @@ -20,11 +20,15 @@ params ["_interfaceID"]; -private _nightMode = [_interfaceID,"nightMode"] call FUNC(getSettings); +private _nightMode = [_interfaceID, "nightMode"] call FUNC(getSettings); if (_nightMode != 2) then { - if (_nightMode == 0) then {_nightMode = 1} else {_nightMode = 0}; - [_interfaceID,[["nightMode",_nightMode]]] call FUNC(setSettings); + if (_nightMode == 0) then { + _nightMode = 1; + } else { + _nightMode = 0; + }; + [_interfaceID, [["nightMode", _nightMode]]] call FUNC(setSettings); }; true