From 6cc05038ff040c89ae5c46a29bebd494bd83bb0c Mon Sep 17 00:00:00 2001 From: TheMagnetar Date: Thu, 1 Feb 2018 00:08:07 +0100 Subject: [PATCH] Cleanup and fixes --- .../fnc_addDefaultSideEncryptionKey.sqf | 8 ++- .../bft/functions/fnc_chatMessages_send.sqf | 4 +- addons/bft/functions/fnc_checkInventory.sqf | 2 +- addons/bft/functions/fnc_checkItem.sqf | 12 ++--- addons/bft/functions/fnc_createGroup.sqf | 3 +- .../bft/functions/fnc_deviceDataToMapData.sqf | 29 ++++++----- .../bft/functions/fnc_encryptionKeyMatch.sqf | 11 +--- .../functions/fnc_generateEncryptionKey.sqf | 3 +- .../functions/fnc_getAllReportingModes.sqf | 20 +++----- addons/bft/functions/fnc_getDeviceData.sqf | 3 +- addons/bft/functions/fnc_getEncryptionKey.sqf | 2 +- addons/bft/functions/fnc_getGroupColor.sqf | 7 ++- addons/bft/functions/fnc_getGroupData.sqf | 3 +- addons/bft/functions/fnc_getInterfaces.sqf | 50 +++++++++---------- addons/bft/functions/fnc_getMagazineID.sqf | 7 ++- addons/bft/functions/fnc_getOwnedDevices.sqf | 3 +- .../bft/functions/fnc_handleAddDeviceData.sqf | 3 +- .../fnc_handleColorFilteringChanged.sqf | 7 ++- .../functions/fnc_handleDeviceDataChanged.sqf | 14 +++--- .../bft/functions/fnc_handleDeviceOpened.sqf | 8 ++- addons/bft/functions/fnc_handleEngine.sqf | 21 +++----- .../bft/functions/fnc_handleItemCreated.sqf | 30 ++++++----- ..._handleRegisteredEncryptionKeysChanged.sqf | 16 ++---- .../fnc_handleRegisteredModeChanged.sqf | 12 ++--- .../functions/fnc_handleRequestAllData.sqf | 5 +- .../functions/fnc_handleSyncedArrayDelete.sqf | 6 +-- .../fnc_handleSyncedArrayPushback.sqf | 10 ++-- .../functions/fnc_handleSyncedArrayUpdate.sqf | 8 ++- .../fnc_handleUpdateDeviceAppData.sqf | 3 +- .../fnc_handleUpdateDeviceCallsign.sqf | 5 +- .../fnc_handleUpdateDeviceElementType.sqf | 5 +- .../functions/fnc_handleUpdateDeviceGroup.sqf | 5 +- .../functions/fnc_handleUpdateDeviceKeys.sqf | 5 +- .../functions/fnc_handleUpdateDeviceOwner.sqf | 12 ++--- .../fnc_handleVehicleDeviceKilled.sqf | 3 +- addons/bft/functions/fnc_isDeviceOwned.sqf | 3 +- .../bft/functions/fnc_removeDeviceByOwner.sqf | 8 +-- addons/bft/functions/fnc_setDeviceAppData.sqf | 3 +- .../bft/functions/fnc_setDeviceCallsign.sqf | 3 +- .../functions/fnc_setDeviceElementType.sqf | 3 +- addons/bft/functions/fnc_setDeviceGroup.sqf | 3 +- addons/bft/functions/fnc_setDeviceKeys.sqf | 3 +- addons/bft/functions/fnc_setDeviceOwner.sqf | 3 +- .../functions/fnc_syncedArrayGetNextID.sqf | 5 +- .../fnc_updateRegisteredEncryptionKeys.sqf | 3 +- .../functions/fnc_updateRegisteredModes.sqf | 4 +- .../bft/functions/fnc_validateInventory.sqf | 14 +++--- addons/bft/functions/fnc_vehicleInit.sqf | 3 +- .../functions/fnc_createUavCam.sqf | 2 +- .../functions/fnc_decBrightness.sqf | 4 +- .../functions/fnc_getBackgroundPosition.sqf | 16 +++--- addons/bft_devices/functions/fnc_ifOpen.sqf | 2 +- .../functions/fnc_onIfToggleKey.sqf | 4 +- .../bft_devices/functions/fnc_openDevice.sqf | 2 +- .../functions/fnc_setInterfacePosition.sqf | 25 ++++------ .../functions/fnc_updateHCamList.sqf | 8 +-- .../functions/fnc_updateUAVList.sqf | 2 +- 57 files changed, 194 insertions(+), 274 deletions(-) diff --git a/addons/bft/functions/fnc_addDefaultSideEncryptionKey.sqf b/addons/bft/functions/fnc_addDefaultSideEncryptionKey.sqf index df14789f6e..c1f26c08ba 100644 --- a/addons/bft/functions/fnc_addDefaultSideEncryptionKey.sqf +++ b/addons/bft/functions/fnc_addDefaultSideEncryptionKey.sqf @@ -14,12 +14,10 @@ params ["_side", "_key"]; -private ["_variableName", "_keys"]; +private _variableName = format[QGVAR(%1_encryptionKey), _side]; +private _keys = missionNamespace getvariable [_variableName, []]; -_variableName = format[QGVAR(%1_encryptionKey), _side]; -_keys = missionNamespace getvariable [_variableName, []]; if !(_key in _keys) then { _keys pushback _key; - missionNamespace setvariable [_variableName, _keys]; - publicVariable "_variableName"; + missionNamespace setvariable [_variableName, _keys, true]; }; diff --git a/addons/bft/functions/fnc_chatMessages_send.sqf b/addons/bft/functions/fnc_chatMessages_send.sqf index 4159e90a28..a53440af4c 100644 --- a/addons/bft/functions/fnc_chatMessages_send.sqf +++ b/addons/bft/functions/fnc_chatMessages_send.sqf @@ -17,12 +17,12 @@ #include "script_component.hpp" -params ["_fromId", "_toId", "_message"]; +params ["_deviceId", "_otherDeviceId", "_message"]; private _messagesListKey = [_deviceId, _otherDeviceId] call FUNC(chatMessage_getId); private _timeStamp = format["00:00"]; private _messageId = [] call FUNC(generateEncryptionKey); // some random key TODO improve or implement some unique Id generator -private _constructedMessage = [_messageId, _timestamp, _message, _fromId]; +private _constructedMessage = [_messageId, _timestamp, _message, _deviceId]; [_messagesListKey, _constructedMessage] call FUNC(syncedArrayPushback); diff --git a/addons/bft/functions/fnc_checkInventory.sqf b/addons/bft/functions/fnc_checkInventory.sqf index 2ff3dc49f4..770a9eaf70 100644 --- a/addons/bft/functions/fnc_checkInventory.sqf +++ b/addons/bft/functions/fnc_checkInventory.sqf @@ -19,4 +19,4 @@ if !(local _unit) exitwith {}; { [_unit, _x] call FUNC(checkItem); -}foreach items _unit; +} foreach items _unit; diff --git a/addons/bft/functions/fnc_checkItem.sqf b/addons/bft/functions/fnc_checkItem.sqf index d6d57476d3..2dcf52cdca 100644 --- a/addons/bft/functions/fnc_checkItem.sqf +++ b/addons/bft/functions/fnc_checkItem.sqf @@ -16,8 +16,6 @@ params ["_unit", "_item"]; -private ["_magazine", "_previousMags", "_newMagName", "_newMags", "_magID"]; - if !(local _unit) exitwith {}; if (isText (configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) && {getText(configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) != ""}) then { @@ -27,19 +25,19 @@ if (isText (configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) && {getTex systemChat format["%1 BFT enabled item %2", _unit, _item]; diag_log format["%1 BFT enabled item %2", _unit, _item]; - _magazine = getText (configFile >> "CfgWeapons" >> _item >> QGVAR(magazineItem)); + private _magazine = getText (configFile >> "CfgWeapons" >> _item >> QGVAR(magazineItem)); if (_magazine != "") then { systemChat format["%1 replacing by %2", _item, _magazine]; diag_log format["%1 replacing by %2", _item, _magazine]; _unit removeItem _item; - _previousMags = magazinesDetail _unit; + private _previousMags = magazinesDetail _unit; _unit addMagazine _magazine; - _newMags = (magazinesDetail _unit) - _previousMags; + private _newMags = (magazinesDetail _unit) - _previousMags; if ((count _newMags) == 0) exitWith {ERROR("failed to add magazine (inventory full?)");}; - _newMagName = _newMags select 0; + private _newMagName = _newMags select 0; - _magID = [_newMagName] call FUNC(getMagazineID); + private _magID = [_newMagName] call FUNC(getMagazineID); systemChat format["%1 id %2", _item, _magID]; diag_log format["%1 id %2", _item, _magID]; diff --git a/addons/bft/functions/fnc_createGroup.sqf b/addons/bft/functions/fnc_createGroup.sqf index a1b96c6621..3eeb3442c6 100644 --- a/addons/bft/functions/fnc_createGroup.sqf +++ b/addons/bft/functions/fnc_createGroup.sqf @@ -19,8 +19,7 @@ params ["_groupID"]; if (count _this < 3) exitwith {}; // What is the 3rd parameter? -private ["_found"]; -_found = false; +private _found = false; { if (_x select 0 == _groupID) exitwith {_found = true;}; } forEach GVAR(orbatElements); diff --git a/addons/bft/functions/fnc_deviceDataToMapData.sqf b/addons/bft/functions/fnc_deviceDataToMapData.sqf index 50f1a050c3..6e9576e152 100644 --- a/addons/bft/functions/fnc_deviceDataToMapData.sqf +++ b/addons/bft/functions/fnc_deviceDataToMapData.sqf @@ -13,15 +13,14 @@ #include "script_component.hpp" -private [ "_deviceID", "_owner","_deviceClass", "_encryptionKeys", "_access", "_typeIconPath", "_sizeIconPath", "_callsign","_groupID", "_position", "_direction", "_refreshRate", "_viewModes", "_color", "_state"]; -_deviceID = D_GET_ID(_this); -_owner = D_GET_OWNER(_this); -_deviceClass = D_GET_CLASSNAME(_this); -_refreshRate = D_GET_REFRESH_RATE_TX(_this); -_viewModes = D_GET_DEVICEMODES(_this); +private _deviceID = D_GET_ID(_this); +private _owner = D_GET_OWNER(_this); +private _deviceClass = D_GET_CLASSNAME(_this); +private _refreshRate = D_GET_REFRESH_RATE_TX(_this); +private _viewModes = D_GET_DEVICEMODES(_this); -_encryptionKeys = D_GET_ENCRYPTION(_this); -_state = D_GET_DEVICE_STATE(_this); +private _encryptionKeys = D_GET_ENCRYPTION(_this); +private _state = D_GET_DEVICE_STATE(_this); /*_access = true; { if (_x in _encryptionKeys) exitwith {_access = true; }; @@ -29,14 +28,14 @@ _state = D_GET_DEVICE_STATE(_this); if !(_access) exitwith {[]};*/ -_typeIconPath = [D_GET_SIDE(_this), D_GET_TYPE(_this)] call FUNC(getTypeIcon); -_sizeIconPath = [D_GET_SIDE(_this), D_GET_SIZE(_this)] call FUNC(getSizeIcon); -_callsign = D_GET_CALLSIGN(_this); -_groupID = D_GET_GROUP_ID(_this); +private _typeIconPath = [D_GET_SIDE(_this), D_GET_TYPE(_this)] call FUNC(getTypeIcon); +private _sizeIconPath = [D_GET_SIDE(_this), D_GET_SIZE(_this)] call FUNC(getSizeIcon); +private _callsign = D_GET_CALLSIGN(_this); +private _groupID = D_GET_GROUP_ID(_this); -_position = getPosASL vehicle _owner; -_direction = direction vehicle _owner; -_color = [_groupID] call FUNC(getGroupColor); +private _position = getPosASL vehicle _owner; +private _direction = direction vehicle _owner; +private _color = [_groupID] call FUNC(getGroupColor); if (_callsign == "" && {_owner isKindOf "CAManBase"}) then { _callsign = groupId group _owner; diff --git a/addons/bft/functions/fnc_encryptionKeyMatch.sqf b/addons/bft/functions/fnc_encryptionKeyMatch.sqf index 434e74cbec..d5b63574d2 100644 --- a/addons/bft/functions/fnc_encryptionKeyMatch.sqf +++ b/addons/bft/functions/fnc_encryptionKeyMatch.sqf @@ -16,13 +16,4 @@ params ["_keySetOne", "_keySetTwo"]; -private ["_return"]; -// ToDo: replace with arrayIntersect when available -// count (_keySetOne arrayIntersect _keySetTwo) > 0 - -_return = false; -{ - if (_x in _keySetTwo) exitWith { _return = true; }; -} forEach _keySetOne; - -_return +count (_keySetOne arrayIntersect _keySetTwo) > 0 diff --git a/addons/bft/functions/fnc_generateEncryptionKey.sqf b/addons/bft/functions/fnc_generateEncryptionKey.sqf index d078950953..6fcb05a6d5 100644 --- a/addons/bft/functions/fnc_generateEncryptionKey.sqf +++ b/addons/bft/functions/fnc_generateEncryptionKey.sqf @@ -12,8 +12,7 @@ #include "script_component.hpp" -private ["_newKeyArray"]; -_newKeyArray = []; +private _newKeyArray = []; for "_i" from 1 to 15 /* step +1 */ do { _newKeyArray pushback (48 + floor(random(74))); diff --git a/addons/bft/functions/fnc_getAllReportingModes.sqf b/addons/bft/functions/fnc_getAllReportingModes.sqf index ac987683e3..7fea71c543 100644 --- a/addons/bft/functions/fnc_getAllReportingModes.sqf +++ b/addons/bft/functions/fnc_getAllReportingModes.sqf @@ -15,19 +15,15 @@ #include "script_component.hpp" -private ["_deviceConfigs","_allReportingModes","_deviceReportingModes"]; +private _deviceConfigs = "true" configClasses (configFile >> "ACE_BFT" >> "Devices"); -_deviceConfigs = "true" configClasses (configFile >> "ACE_BFT" >> "Devices"); - -_allReportingModes = []; +private _allReportingModes = []; { - if (isClass _x) then { - if (isArray (_x >> "reportingModes")) then { - _deviceReportingModes = getArray (_x >> "reportingModes"); - // only append what isn't there already - _allReportingModes append (_deviceReportingModes - _allReportingModes); - }; - } + if (isClass _x && {isArray (_x >> "reportingModes")}) then { + private _deviceReportingModes = getArray (_x >> "reportingModes"); + // only append what isn't there already + _allReportingModes append (_deviceReportingModes - _allReportingModes); + }; } forEach _deviceConfigs; -_allReportingModes \ No newline at end of file +_allReportingModes diff --git a/addons/bft/functions/fnc_getDeviceData.sqf b/addons/bft/functions/fnc_getDeviceData.sqf index dc29d9bc88..3078d2edff 100644 --- a/addons/bft/functions/fnc_getDeviceData.sqf +++ b/addons/bft/functions/fnc_getDeviceData.sqf @@ -15,8 +15,7 @@ params ["_deviceID"]; -private ["_data"]; -_data = []; +private _data = []; { if (_x select 0 == _deviceID) exitWith { _data = _x; // GVAR(deviceData) select _foreachIndex; diff --git a/addons/bft/functions/fnc_getEncryptionKey.sqf b/addons/bft/functions/fnc_getEncryptionKey.sqf index f04cbd1b0f..6380c8f786 100644 --- a/addons/bft/functions/fnc_getEncryptionKey.sqf +++ b/addons/bft/functions/fnc_getEncryptionKey.sqf @@ -20,4 +20,4 @@ if (typeName _side == "OBJECT") then { _side = str side _side; }; -(missionNamespace getvariable [format[QGVAR(%1_encryptionKey), _side], [""]]) \ No newline at end of file +(missionNamespace getvariable [format[QGVAR(%1_encryptionKey), _side], [""]]) diff --git a/addons/bft/functions/fnc_getGroupColor.sqf b/addons/bft/functions/fnc_getGroupColor.sqf index 9600894304..74b657e309 100644 --- a/addons/bft/functions/fnc_getGroupColor.sqf +++ b/addons/bft/functions/fnc_getGroupColor.sqf @@ -15,10 +15,9 @@ params ["_groupID"]; -private ["_data", "_found", "_color"]; -_data = [_groupID] call FUNC(getGroupData); -_found = false; -_color = GVAR(colorWest); +private _data = [_groupID] call FUNC(getGroupData); +private _found = false; +private _color = GVAR(colorWest); while {!_found} do { if (_groupID < 0) exitWith {}; diff --git a/addons/bft/functions/fnc_getGroupData.sqf b/addons/bft/functions/fnc_getGroupData.sqf index 33b8605a48..e315a02a78 100644 --- a/addons/bft/functions/fnc_getGroupData.sqf +++ b/addons/bft/functions/fnc_getGroupData.sqf @@ -15,8 +15,7 @@ params ["_groupID"]; -private ["_data"]; -_data = [_groupID, "", -1/*parent group ID*/]; +private _data = [_groupID, "", -1/*parent group ID*/]; { if (_x select 0 == _groupID) exitWith { _data = _x; diff --git a/addons/bft/functions/fnc_getInterfaces.sqf b/addons/bft/functions/fnc_getInterfaces.sqf index 967e1b8313..4dbf0bc7e4 100644 --- a/addons/bft/functions/fnc_getInterfaces.sqf +++ b/addons/bft/functions/fnc_getInterfaces.sqf @@ -19,61 +19,61 @@ #include "script_component.hpp" -private ["_deviceData","_deviceOwner","_interfaces","_interface","_deviceType","_vehicleInterfaces","_assignedVehicleRole","_roleIndex","_roleName","_whereAvailable","_found"]; params ["_deviceID", "_unit"]; -_deviceData = [_deviceID] call EFUNC(bft,getDeviceData); -_deviceOwner = D_GET_OWNER(_deviceData); +private _deviceData = [_deviceID] call EFUNC(bft,getDeviceData); +private _deviceOwner = D_GET_OWNER(_deviceData); -_interfaces = []; +private _interfaces = []; -if (_deviceOwner isKindOf "ParachuteBase" || _deviceOwner isKindOf "CAManBase") then { +if (_deviceOwner isKindOf "ParachuteBase" || {_deviceOwner isKindOf "CAManBase"}) then { // personal device - _deviceType = D_GET_DEVICETYPE(_deviceData); + private _deviceType = D_GET_DEVICETYPE(_deviceData); if (isText (configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "interface")) then { - _interface = getText (configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "interface"); + private _interface = getText (configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "interface"); if (_interface != "") then { _interfaces pushBack _interface; }; }; } else { // vehicle device - _vehicleInterfaces = _deviceOwner getvariable [QGVAR(vehicleInterfaces), getArray (configFile >> "CfgVehicles" >> typeOf _deviceOwner >> QGVAR(vehicleInterfaces))]; - + private _vehicleInterfaces = _deviceOwner getvariable [QGVAR(vehicleInterfaces), getArray (configFile >> "CfgVehicles" >> typeOf _deviceOwner >> QGVAR(vehicleInterfaces))]; + // bail if there are no interfaces defined if (isNil "_vehicleInterfaces" || {_vehicleInterfaces isEqualTo []}) exitWith {}; - - _assignedVehicleRole = assignedVehicleRole _unit; - + + private _assignedVehicleRole = assignedVehicleRole _unit; + // bail if unit is not in a vehicle if (_assignedVehicleRole isEqualTo []) exitWith {}; - - _roleName = _assignedVehicleRole select 0; - _roleIndex = call { + + private _roleName = _assignedVehicleRole select 0; + private _roleIndex = call { if (_roleName == "Cargo") exitWith {_deviceOwner getCargoIndex _unit}; if (_roleName == "Turret") exitWith {_assignedVehicleRole select 1 select 0}; 0 }; - + { switch (typeName _x) do { case "STRING": {_interfaces pushBack _x}; - + case "ARRAY": { // whereAvailable test - _interface = _x select 0; - _whereAvailable = _x select 1; + private _interface = _x select 0; + private _whereAvailable = _x select 1; { - _found = switch (typeName _x) do { + private _found = false; + + switch (typeName _x) do { case "STRING": { - if (_x == _roleName) then {true}; + if (_x == _roleName) then {_found = true}; }; case "ARRAY": { - if ((_x select 0) == _roleName && _roleIndex in (_x select 1)) then {true}; + if ((_x select 0) == _roleName && _roleIndex in (_x select 1)) then {_found = true}; }; - default {false}; }; - + if (_found) exitWith {_interfaces pushBack _interface}; } forEach _whereAvailable; }; @@ -81,4 +81,4 @@ if (_deviceOwner isKindOf "ParachuteBase" || _deviceOwner isKindOf "CAManBase") } forEach _vehicleInterfaces; }; -_interfaces \ No newline at end of file +_interfaces diff --git a/addons/bft/functions/fnc_getMagazineID.sqf b/addons/bft/functions/fnc_getMagazineID.sqf index c2367f9001..bb1de526f8 100644 --- a/addons/bft/functions/fnc_getMagazineID.sqf +++ b/addons/bft/functions/fnc_getMagazineID.sqf @@ -15,12 +15,11 @@ params ["_detailsEntry"]; -private ["_index", "_value", "_id"]; -_index = _detailsEntry find "["; -_id = ""; +private _index = _detailsEntry find "["; +private _id = ""; if (_index > 0) then { - _value = toArray _detailsEntry; + private _value = toArray _detailsEntry; _value deleteRange [0, _index]; _id = toString _value; }; diff --git a/addons/bft/functions/fnc_getOwnedDevices.sqf b/addons/bft/functions/fnc_getOwnedDevices.sqf index ba443e4494..afe4bdcb86 100644 --- a/addons/bft/functions/fnc_getOwnedDevices.sqf +++ b/addons/bft/functions/fnc_getOwnedDevices.sqf @@ -16,8 +16,7 @@ params ["_owner"]; // Or use OBJECT getvariable [QGVAR(ownedDevices), []]; ? -private ["_ids"]; -_ids = []; +private _ids = []; { if ((_x select 5) == _owner) then { diff --git a/addons/bft/functions/fnc_handleAddDeviceData.sqf b/addons/bft/functions/fnc_handleAddDeviceData.sqf index 8a93fc95aa..12b722479a 100644 --- a/addons/bft/functions/fnc_handleAddDeviceData.sqf +++ b/addons/bft/functions/fnc_handleAddDeviceData.sqf @@ -18,7 +18,6 @@ #include "script_component.hpp" -private ["_currentDevices"]; // [_magID, [_deviceSide, _deviceEncryptionKeys], _assignableInformation, _app, -1, _owner] diag_log format["added to deviceData: %1", _this]; GVAR(deviceData) pushback _this; @@ -27,7 +26,7 @@ systemChat format["handleAddDeviceData: %1", _this]; diag_log format["handleAddDeviceData: %1", _this]; if (local (_this select 5)) then { - _currentDevices = (_this select 5) getvariable [QGVAR(ownedDevices), []]; + private _currentDevices = (_this select 5) getvariable [QGVAR(ownedDevices), []]; if !((_this select 0) in _currentDevices) then { _currentDevices pushback (_this select 0); (_this select 5) setvariable [QGVAR(ownedDevices), _currentDevices, true]; diff --git a/addons/bft/functions/fnc_handleColorFilteringChanged.sqf b/addons/bft/functions/fnc_handleColorFilteringChanged.sqf index cc25a15d9c..d4ff13850a 100644 --- a/addons/bft/functions/fnc_handleColorFilteringChanged.sqf +++ b/addons/bft/functions/fnc_handleColorFilteringChanged.sqf @@ -13,10 +13,9 @@ #include "script_component.hpp" { - private ["_groupID","_color"]; - _groupID = (_x select 6) select 0; + private _groupID = (_x select 6) select 0; if (_groupID >= 0) then { - _color = [_groupID] call FUNC(getGroupColor); + private _color = [_groupID] call FUNC(getGroupColor); (_x select 6) set [1, _color]; }; -} foreach GVAR(availableDevices); \ No newline at end of file +} foreach GVAR(availableDevices); diff --git a/addons/bft/functions/fnc_handleDeviceDataChanged.sqf b/addons/bft/functions/fnc_handleDeviceDataChanged.sqf index ab5844491b..5fd94f8d6d 100644 --- a/addons/bft/functions/fnc_handleDeviceDataChanged.sqf +++ b/addons/bft/functions/fnc_handleDeviceDataChanged.sqf @@ -12,9 +12,9 @@ #include "script_component.hpp" -private ["_data", "_deviceID", "_displayData", "_encryptionKeys", "_deviceModes"]; -_data = _this select 0; -_deviceID = D_GET_ID(_data); +params ["_data"]; + +private _deviceID = D_GET_ID(_data); diag_log format["hanldeDeviceDataChanged for: %1", _deviceID]; if (isNull D_GET_OWNER(_data)) exitwith { // doesn't have an owner anymore, remove. @@ -28,8 +28,8 @@ if (isNull D_GET_OWNER(_data)) exitwith { // doesn't have an owner anymore, remo } foreach GVAR(availableDevices); }; }; -_encryptionKeys = D_GET_ENCRYPTION(_data); -_deviceModes = D_GET_DEVICEMODES(_data); +private _encryptionKeys = D_GET_ENCRYPTION(_data); +private _deviceModes = D_GET_DEVICEMODES(_data); if (_this select 1) then { // add new if !([_encryptionKeys, GVAR(registeredEncyptionKeys)] call FUNC(encryptionKeyMatch)) exitwith { @@ -40,7 +40,7 @@ if (_this select 1) then { // add new }; // if the encryption key is not know, the device is not available if (!(D_GET_OWNER(_data) isKindOf "CAManBAse") && {D_GET_DEVICE_STATE_VALUE(_data) isEqualTo STATE_NORMAL} && {!(isEngineOn D_GET_OWNER(_data)) && alive D_GET_OWNER(_data)}) exitwith {}; if (D_GET_DEVICE_STATE_VALUE(_data) in [STATE_OFFLINE, STATE_DESTROYED]) exitwith {}; - _displayData = _data call FUNC(deviceDataToMapData); + private _displayData = _data call FUNC(deviceDataToMapData); if (count _displayData > 0) then { GVAR(availableDevices) pushback _displayData; }; @@ -59,7 +59,7 @@ if (_this select 1) then { // add new // GVAR(availableDevices) deleteAt _forEachIndex; // no longer a match, so we remove it from available devices //}; // we don't know what info has changed, so we just replace it completely. - _displayData = _data call FUNC(deviceDataToMapData); + private _displayData = _data call FUNC(deviceDataToMapData); GVAR(availableDevices) set [_forEachIndex, _displayData]; }; } foreach GVAR(availableDevices); diff --git a/addons/bft/functions/fnc_handleDeviceOpened.sqf b/addons/bft/functions/fnc_handleDeviceOpened.sqf index a9188f1588..fa32196e97 100644 --- a/addons/bft/functions/fnc_handleDeviceOpened.sqf +++ b/addons/bft/functions/fnc_handleDeviceOpened.sqf @@ -12,12 +12,10 @@ #include "script_component.hpp" -private ["_deviceID","_refreshRateRX","_deviceData"]; - // by default, consider the device not having a receiver -_refreshRateRX = -1; -_deviceID = _this select 0; -_deviceData = [_deviceID] call FUNC(getDeviceData); +private _refreshRateRX = -1; +private _deviceID = _this select 0; +private _deviceData = [_deviceID] call FUNC(getDeviceData); GVAR(currentOpenedDevice) = _deviceData; if !(_deviceData isEqualTo []) then { _refreshRateRX = D_GET_REFRESH_RATE_RX(_deviceData); diff --git a/addons/bft/functions/fnc_handleEngine.sqf b/addons/bft/functions/fnc_handleEngine.sqf index 77c140a0d0..880e48835d 100644 --- a/addons/bft/functions/fnc_handleEngine.sqf +++ b/addons/bft/functions/fnc_handleEngine.sqf @@ -16,11 +16,8 @@ params ["_object", "_turnedOn"]; // clear out any device in available devices that is owned by the object. // We do this for both engine on and engine off to avoid any duplicates -private ["_device","_i"]; - - for "_i" from (count GVAR(availableDevices) - 1) to 0 step -1 do { - _device = GVAR(availableDevices) select _i; + private _device = GVAR(availableDevices) select _i; if (AD_GET_DEVICE_STATE_VALUE(_device) isEqualTo STATE_NORMAL) then { if (AD_GET_OWNER(_device) == _object) then { GVAR(availableDevices) deleteAt _i; @@ -30,9 +27,8 @@ for "_i" from (count GVAR(availableDevices) - 1) to 0 step -1 do { }; if (_turnedOn) then { - private ["_deviceData", "_encryptionKeys", "_deviceModes", "_displayData"]; { - _deviceData = [_x] call FUNC(getDeviceData); + private _deviceData = [_x] call FUNC(getDeviceData); if (!(_deviceData isEqualTo [])) then { if !(isNull D_GET_OWNER(_deviceData)) then { if (D_GET_DEVICE_STATE_VALUE(_deviceData) isEqualTo STATE_OFFLINE) then { @@ -41,25 +37,24 @@ if (_turnedOn) then { }; if !(D_GET_DEVICE_STATE_VALUE(_deviceData) isEqualTo STATE_NORMAL) exitwith {}; // means we didn't remove it - _encryptionKeys = D_GET_ENCRYPTION(_deviceData); + private _encryptionKeys = D_GET_ENCRYPTION(_deviceData); if !([_encryptionKeys, GVAR(registeredEncyptionKeys)] call FUNC(encryptionKeyMatch)) exitWith {}; - _deviceModes = D_GET_DEVICEMODES(_deviceData); + private _deviceModes = D_GET_DEVICEMODES(_deviceData); if !([_deviceModes, GVAR(registeredViewModes)] call FUNC(encryptionKeyMatch)) exitWith {}; - _displayData = _deviceData call FUNC(deviceDataToMapData); + private _displayData = _deviceData call FUNC(deviceDataToMapData); if (count _displayData > 0) then { GVAR(availableDevices) pushback _displayData; }; }; }; - }foreach (_object getvariable [QGVAR(ownedDevices), []]); + } foreach (_object getvariable [QGVAR(ownedDevices), []]); } else { if (!alive _object) exitwith {}; - - private ["_deviceData", "_encryptionKeys", "_deviceModes", "_displayData"]; + { - _deviceData = [_x] call FUNC(getDeviceData); + private _deviceData = [_x] call FUNC(getDeviceData); if (!(_deviceData isEqualTo [])) then { if !(isNull D_GET_OWNER(_deviceData)) then { if (D_GET_DEVICE_STATE_VALUE(_deviceData) isEqualTo STATE_NORMAL) then { diff --git a/addons/bft/functions/fnc_handleItemCreated.sqf b/addons/bft/functions/fnc_handleItemCreated.sqf index ca3df223dd..eafc27debc 100644 --- a/addons/bft/functions/fnc_handleItemCreated.sqf +++ b/addons/bft/functions/fnc_handleItemCreated.sqf @@ -18,8 +18,6 @@ params ["_owner", "_item", "_magazine", "_magID", ["_initialState", STATE_NORMAL]]; -private ["_deviceType", "_deviceSide", "_refreshRate", "_deviceEncryptionKeys", "_assignableInformation", "_app", "_deviceInformation", "_exists", "_deviceModes", "_defaultValues", "_elementCallsign", "_elementSize", "_elementType", "_groupID"]; - /* Device ID Side ID/encyrption ID @@ -35,7 +33,7 @@ private ["_deviceType", "_deviceSide", "_refreshRate", "_deviceEncryptionKeys", systemChat format["handleItemCreated: %1", _this]; diag_log format["handleItemCreated: entry args: %1", _this]; -_exists = false; +private _exists = false; { if (_magID == (_x select 0)) exitwith {_exists = true}; } forEach GVAR(deviceData); @@ -43,11 +41,11 @@ if (_exists) exitwith { diag_log format["handleItemCreated: Already exists: %1", _magID]; }; -_deviceType = if (_magazine != "") then { getText(configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) } else { _item }; -_deviceSide = getText(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "deviceSide"); -_deviceModes = getArray(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "reportingModes"); +private _deviceType = if (_magazine != "") then { getText(configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) } else { _item }; +private _deviceSide = getText(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "deviceSide"); +private _deviceModes = getArray(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "reportingModes"); -_defaultValues = []; +private _defaultValues = []; // if this is a vehicle device, see if the default information is present on the vehicle if !(isNull _owner || {_owner isKindOf "ParachuteBase" || _owner isKindOf "CAManBase"}) then { if (isArray (configFile >> "CfgVehicles" >> typeOf _owner >> QGVAR(defaultInformation))) then { @@ -59,18 +57,18 @@ if (_defaultValues isEqualTo []) then { _defaultValues = getArray (configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "defaultInformation"); }; -_refreshRate = getArray(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "refreshRate"); +private _refreshRate = getArray(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "refreshRate"); -_deviceEncryptionKeys = [_deviceSide] call FUNC(getEncryptionKey); // getting the default encryption keys for this side +private _deviceEncryptionKeys = [_deviceSide] call FUNC(getEncryptionKey); // getting the default encryption keys for this side -_elementType = _owner getvariable format[QGVAR(elementType_%1),_item]; -_elementSize = _owner getvariable format[QGVAR(elementSize_%1),_item]; -_elementCallsign = _owner getvariable format[QGVAR(elementCallsign_%1),_item]; -_groupID = _owner getvariable format[QGVAR(groupID_%1),_item]; +private _elementType = _owner getvariable format[QGVAR(elementType_%1),_item]; +private _elementSize = _owner getvariable format[QGVAR(elementSize_%1),_item]; +private _elementCallsign = _owner getvariable format[QGVAR(elementCallsign_%1),_item]; +private _groupID = _owner getvariable format[QGVAR(groupID_%1),_item]; // format: [elementType, elementSize, elementCallsign, orbatElementID] -_assignableInformation = _owner getvariable [format[QGVAR(assignableInformation_%1),_item], _defaultValues]; +private _assignableInformation = _owner getvariable [format[QGVAR(assignableInformation_%1),_item], _defaultValues]; if (!isnil "_elementType") then { _assignableInformation set [0, _elementType]; @@ -87,10 +85,10 @@ if (!isnil "_groupID") then { }; // format: app ID, app data -_app = [-1, []]; +private _app = [-1, []]; // format: device ID, deviceSide [side, encryptionKeys], deviceInformation [elementType, elementSize, callsign, orbatID], appInformation [appID, appData], timeLoggedIn, owner, item, deviceType, _refreshRate [TX, RX], _deviceModes, deviceState] -_deviceInformation = [_magID, [_deviceSide, _deviceEncryptionKeys], _assignableInformation, _app, -1, _owner, _item, _deviceType, _refreshRate, _deviceModes, [_initialState]]; +private _deviceInformation = [_magID, [_deviceSide, _deviceEncryptionKeys], _assignableInformation, _app, -1, _owner, _item, _deviceType, _refreshRate, _deviceModes, [_initialState]]; diag_log format["Prep raising bft_addDeviceData _deviceInformation with: %1", _deviceInformation]; [{ diff --git a/addons/bft/functions/fnc_handleRegisteredEncryptionKeysChanged.sqf b/addons/bft/functions/fnc_handleRegisteredEncryptionKeysChanged.sqf index dd51c7a20d..fbfd5f107f 100644 --- a/addons/bft/functions/fnc_handleRegisteredEncryptionKeysChanged.sqf +++ b/addons/bft/functions/fnc_handleRegisteredEncryptionKeysChanged.sqf @@ -12,9 +12,7 @@ #include "script_component.hpp" -private ["_add","_newEncryptionKeys"]; -_newEncryptionKeys = _this select 0; -_add = _this select 1; +params ["_newEncryptionKeys", "_add"]; // if _add is nil, rebuild list from scratch if (isNil "_add") then { @@ -27,30 +25,26 @@ if (isNil "_add") then { if (count _newEncryptionKeys == 0) exitWith {}; if (_add) then { - private ["_deviceModes","_encryptionKeys","_displayData"]; - // Adding a new key isn't nice. Now we got to add new shit and loop through the massive data collection. yay? { if !(isNull D_GET_OWNER(_x)) then { if (!(D_GET_OWNER(_x) isKindOf "CAManBAse") && {D_GET_DEVICE_STATE_VALUE(_x) isEqualTo STATE_NORMAL} && {!(isEngineOn D_GET_OWNER(_x)) && alive D_GET_OWNER(_data)}) exitwith {}; if (D_GET_DEVICE_STATE_VALUE(_x) in [STATE_OFFLINE, STATE_DESTROYED]) exitwith {}; - _encryptionKeys = D_GET_ENCRYPTION(_x); + private _encryptionKeys = D_GET_ENCRYPTION(_x); if !([_encryptionKeys, _newEncryptionKeys] call FUNC(encryptionKeyMatch)) exitWith {}; - _deviceModes = D_GET_DEVICEMODES(_x); + private _deviceModes = D_GET_DEVICEMODES(_x); if !([_deviceModes, GVAR(registeredViewModes)] call FUNC(encryptionKeyMatch)) exitWith {}; - _displayData = _x call FUNC(deviceDataToMapData); + private _displayData = _x call FUNC(deviceDataToMapData); if (count _displayData > 0) then { GVAR(availableDevices) pushback _displayData; }; }; } foreach GVAR(deviceData); } else { // if we remove one, we only have to check the already available devices - private ["_device","_i"]; - for "_i" from (count GVAR(availableDevices) - 1) to 0 step -1 do { - _device = GVAR(availableDevices) select _i; + private _device = GVAR(availableDevices) select _i; if !([AD_GET_ENCRYPTION(_device), GVAR(registeredEncyptionKeys)] call FUNC(encryptionKeyMatch)) then { GVAR(availableDevices) deleteAt _i; _i = _i - 1; diff --git a/addons/bft/functions/fnc_handleRegisteredModeChanged.sqf b/addons/bft/functions/fnc_handleRegisteredModeChanged.sqf index 6f198d44f3..ca0c505f01 100644 --- a/addons/bft/functions/fnc_handleRegisteredModeChanged.sqf +++ b/addons/bft/functions/fnc_handleRegisteredModeChanged.sqf @@ -12,9 +12,7 @@ #include "script_component.hpp" -private ["_add","_viewModes"]; -_viewModes = _this select 0; -_add = _this select 1; +params ["_viewModes", "_add"]; // if _add is nil, rebuild list from scratch if (isNil "_add") then { @@ -27,19 +25,17 @@ if (isNil "_add") then { if (count _viewModes == 0) exitWith {}; if (_add) then { - private ["_deviceModes","_encryptionKeys","_displayData"]; - { if !(isNull D_GET_OWNER(_x)) then { if (!(D_GET_OWNER(_x) isKindOf "CAManBAse") && {D_GET_DEVICE_STATE_VALUE(_x) isEqualTo STATE_NORMAL} && {!(isEngineOn D_GET_OWNER(_x)) && alive D_GET_OWNER(_data)}) exitwith {}; if (D_GET_DEVICE_STATE_VALUE(_x) in [STATE_OFFLINE, STATE_DESTROYED]) exitwith {}; - _deviceModes = D_GET_DEVICEMODES(_x); + private _deviceModes = D_GET_DEVICEMODES(_x); if !([_deviceModes, _viewModes] call FUNC(encryptionKeyMatch)) exitWith {}; - _encryptionKeys = D_GET_ENCRYPTION(_x); + private _encryptionKeys = D_GET_ENCRYPTION(_x); if !([_encryptionKeys, GVAR(registeredEncyptionKeys)] call FUNC(encryptionKeyMatch)) exitWith {}; - _displayData = _x call FUNC(deviceDataToMapData); + private _displayData = _x call FUNC(deviceDataToMapData); if (count _displayData > 0) then { GVAR(availableDevices) pushback _displayData; }; diff --git a/addons/bft/functions/fnc_handleRequestAllData.sqf b/addons/bft/functions/fnc_handleRequestAllData.sqf index aebcb026d5..30a0f37a75 100644 --- a/addons/bft/functions/fnc_handleRequestAllData.sqf +++ b/addons/bft/functions/fnc_handleRequestAllData.sqf @@ -29,9 +29,8 @@ diag_log format["handleRequestAllData: Request from Origin: %1", _origin]; { diag_log format["handleRequestAllData: Add synced array variable: %1", _x]; - private ["_varName", "_variable"]; - _varName = _x; - _variable = missionNamespace getvariable [_varName, []]; + private _varName = _x; + private _variable = missionNamespace getvariable [_varName, []]; { diag_log format["handleRequestAllData: Add synced array variable (%1) value: %2", _varName, _x]; diff --git a/addons/bft/functions/fnc_handleSyncedArrayDelete.sqf b/addons/bft/functions/fnc_handleSyncedArrayDelete.sqf index 24d11a38a8..1519d86494 100644 --- a/addons/bft/functions/fnc_handleSyncedArrayDelete.sqf +++ b/addons/bft/functions/fnc_handleSyncedArrayDelete.sqf @@ -17,15 +17,13 @@ params ["_varName", "_elementID"]; -private ["_variable"]; -_variable = missionNamespace getvariable [_varName, []]; +private _variable = missionNamespace getvariable [_varName, []]; { if ((_x select 0) isEqualTo _elementID) exitwith { systemChat format["handleSyncedArrayDelete deleting- %1", _x]; diag_log format["handleSyncedArrayDelete deleting- %1", _x]; - private ["_removedElement"]; - _removedElement = _variable deleteAt _foreachIndex; + private _removedElement = _variable deleteAt _foreachIndex; ["bft_syncedArrayChanged", [2, _removedElement]] call CBA_fnc_localEvent; }; diff --git a/addons/bft/functions/fnc_handleSyncedArrayPushback.sqf b/addons/bft/functions/fnc_handleSyncedArrayPushback.sqf index e1ba306826..cb9ac1f5f0 100644 --- a/addons/bft/functions/fnc_handleSyncedArrayPushback.sqf +++ b/addons/bft/functions/fnc_handleSyncedArrayPushback.sqf @@ -16,12 +16,10 @@ params ["_varName", "_data"]; -private ["_variable"]; - systemChat format["handleSyncedArrayPushback: %1", _this]; diag_log format["handleSyncedArrayPushback: %1", _this]; -_variable = missionNamespace getvariable [_varName, []]; +private _variable = missionNamespace getvariable [_varName, []]; _variable pushback _data; missionNamespace setvariable [_varName, _variable]; @@ -30,8 +28,6 @@ missionNamespace setvariable [_varName, _variable]; systemChat format["handleSyncedArrayPushback %1 - %2", _varName, _variable]; diag_log format["handleSyncedArrayPushback %1 - %2", _varName, _variable]; -if (isServer) then { - if !(_varName in GVAR(syncedArrayVariables)) then { - GVAR(syncedArrayVariables) pushback _varName; - }; +if (isServer && {!(_varName in GVAR(syncedArrayVariables))}) then { + GVAR(syncedArrayVariables) pushback _varName; }; diff --git a/addons/bft/functions/fnc_handleSyncedArrayUpdate.sqf b/addons/bft/functions/fnc_handleSyncedArrayUpdate.sqf index 38649c108c..de6e27bb77 100644 --- a/addons/bft/functions/fnc_handleSyncedArrayUpdate.sqf +++ b/addons/bft/functions/fnc_handleSyncedArrayUpdate.sqf @@ -18,15 +18,13 @@ params ["_varName", "_data"]; -private ["_elementID", "_variable", "_compareID"]; - systemChat format["handleSyncedArrayUpdate - %1", _this]; diag_log format["handleSyncedArrayUpdate - %1", _this]; -_elementID = if (typeName _data == "ARRAY") then {_data select 0} else {_data}; -_variable = missionNamespace getvariable [_varName, []]; +private _elementID = if (typeName _data == "ARRAY") then {_data select 0} else {_data}; +private _variable = missionNamespace getvariable [_varName, []]; { - _compareID = if (typeName _x == "ARRAY") then {_x select 0} else {_x}; + private _compareID = if (typeName _x == "ARRAY") then {_x select 0} else {_x}; if (_compareID isEqualTo _elementID) exitwith { _variable set[_forEachIndex, _data]; ["bft_syncedArrayChanged", [1, _data, _x]] call CBA_fnc_localEvent; diff --git a/addons/bft/functions/fnc_handleUpdateDeviceAppData.sqf b/addons/bft/functions/fnc_handleUpdateDeviceAppData.sqf index 322283bad6..82b92fe65e 100644 --- a/addons/bft/functions/fnc_handleUpdateDeviceAppData.sqf +++ b/addons/bft/functions/fnc_handleUpdateDeviceAppData.sqf @@ -16,8 +16,7 @@ params ["_deviceID", "_newData"]; -private ["_data"]; -_data = [_deviceID] call FUNC(getDeviceData); +private _data = [_deviceID] call FUNC(getDeviceData); _data set [3, _newData]; // ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; diff --git a/addons/bft/functions/fnc_handleUpdateDeviceCallsign.sqf b/addons/bft/functions/fnc_handleUpdateDeviceCallsign.sqf index 965c3af479..e041a15947 100644 --- a/addons/bft/functions/fnc_handleUpdateDeviceCallsign.sqf +++ b/addons/bft/functions/fnc_handleUpdateDeviceCallsign.sqf @@ -16,9 +16,8 @@ params ["_deviceID", "_callsign"]; -private ["_data", "_deviceAssignableInfo"]; -_data = [_deviceID] call FUNC(getDeviceData); -_deviceAssignableInfo = _data select 2; +private _data = [_deviceID] call FUNC(getDeviceData); +private _deviceAssignableInfo = _data select 2; _deviceAssignableInfo set [2, _callsign]; ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; diff --git a/addons/bft/functions/fnc_handleUpdateDeviceElementType.sqf b/addons/bft/functions/fnc_handleUpdateDeviceElementType.sqf index bf187d90d5..df806fcb7e 100644 --- a/addons/bft/functions/fnc_handleUpdateDeviceElementType.sqf +++ b/addons/bft/functions/fnc_handleUpdateDeviceElementType.sqf @@ -16,9 +16,8 @@ params ["_deviceID", "_elementType"]; -private ["_data", "_assignableInformation"]; -_data = [_deviceID] call FUNC(getDeviceData); -_assignableInformation = _data select 2; +private _data = [_deviceID] call FUNC(getDeviceData); +private _assignableInformation = _data select 2; _assignableInformation set [0, _elementType select 0]; _assignableInformation set [1, _elementType select 1]; diff --git a/addons/bft/functions/fnc_handleUpdateDeviceGroup.sqf b/addons/bft/functions/fnc_handleUpdateDeviceGroup.sqf index 878b1f98a1..dbc66ff62c 100644 --- a/addons/bft/functions/fnc_handleUpdateDeviceGroup.sqf +++ b/addons/bft/functions/fnc_handleUpdateDeviceGroup.sqf @@ -16,9 +16,8 @@ params ["_deviceID", "_groupID"]; -private ["_data", "_previousGroup"]; -_data = [_deviceID] call FUNC(getDeviceData); -_previousGroup = _data select 2; +private _data = [_deviceID] call FUNC(getDeviceData); +private _previousGroup = _data select 2; _previousGroup set [3, _groupID]; ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; diff --git a/addons/bft/functions/fnc_handleUpdateDeviceKeys.sqf b/addons/bft/functions/fnc_handleUpdateDeviceKeys.sqf index 8068190948..c947c88e13 100644 --- a/addons/bft/functions/fnc_handleUpdateDeviceKeys.sqf +++ b/addons/bft/functions/fnc_handleUpdateDeviceKeys.sqf @@ -16,9 +16,8 @@ params ["_deviceID", "_keys"]; -private ["_data", "_encryption"]; -_data = [_deviceID] call FUNC(getDeviceData); -_encryption = _data select 1; +private _data = [_deviceID] call FUNC(getDeviceData); +private _encryption = _data select 1; _encryption set [1, _keys]; ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; diff --git a/addons/bft/functions/fnc_handleUpdateDeviceOwner.sqf b/addons/bft/functions/fnc_handleUpdateDeviceOwner.sqf index 3ef71170bb..a701471181 100644 --- a/addons/bft/functions/fnc_handleUpdateDeviceOwner.sqf +++ b/addons/bft/functions/fnc_handleUpdateDeviceOwner.sqf @@ -16,13 +16,11 @@ params ["_deviceID", "_newOwner"]; -private ["_data", "_newData", "_previousOwner", "_currentDevices"]; - systemChat format["handleUpdateDeviceOwner: %1", _this]; diag_log format["handleUpdateDeviceOwner: %1", _this]; -_data = [_deviceID] call FUNC(getDeviceData); -_previousOwner = _data select 5; +private _data = [_deviceID] call FUNC(getDeviceData); +private _previousOwner = _data select 5; _data set [5, _newOwner]; ["bft_deviceDataChanged", [_data, isNull _previousOwner]] call CBA_fnc_localEvent; @@ -30,12 +28,12 @@ _data set [5, _newOwner]; systemChat format["handleUpdateDeviceOwner - setting new owner from %1 to %2", _previousOwner, _newOwner]; diag_log format["handleUpdateDeviceOwner - setting new owner from %1 to %2", _previousOwner, _newOwner]; -_newData = [_deviceID] call FUNC(getDeviceData); +private _newData = [_deviceID] call FUNC(getDeviceData); systemChat format["handleUpdateDeviceOwner - validate new owner - %1", (_newData select 5) == _newOwner]; diag_log format["handleUpdateDeviceOwner - validate new owner - %1", (_newData select 5) == _newOwner]; if (!isNull _newOwner && {local _newOwner}) then { - _currentDevices = _newOwner getvariable [QGVAR(ownedDevices), []]; + private _currentDevices = _newOwner getvariable [QGVAR(ownedDevices), []]; if !(_deviceID in _currentDevices) then { _currentDevices pushback _deviceID; _newOwner setvariable [QGVAR(ownedDevices), _currentDevices, true]; @@ -47,7 +45,7 @@ if (!isNull _newOwner && {local _newOwner}) then { }; if (!isNull _previousOwner && {local _previousOwner}) then { diag_log format["handleUpdateDeviceOwner - removing device (%1) from owner %2 ", _deviceId, _previousOwner]; - _currentDevices = _previousOwner getvariable [QGVAR(ownedDevices), []]; + private _currentDevices = _previousOwner getvariable [QGVAR(ownedDevices), []]; if (_deviceID in _currentDevices) then { _currentDevices = _currentDevices - [_deviceID]; _previousOwner setvariable [QGVAR(ownedDevices), _currentDevices, true]; diff --git a/addons/bft/functions/fnc_handleVehicleDeviceKilled.sqf b/addons/bft/functions/fnc_handleVehicleDeviceKilled.sqf index 0cde976023..4786f4efb6 100644 --- a/addons/bft/functions/fnc_handleVehicleDeviceKilled.sqf +++ b/addons/bft/functions/fnc_handleVehicleDeviceKilled.sqf @@ -12,10 +12,9 @@ #include "script_component.hpp" -private ["_data"]; params ["_deviceId"]; -_data = [_deviceId] call FUNC(getDeviceData); +private _data = [_deviceId] call FUNC(getDeviceData); systemChat format["handleVehicleDeviceKilled: %1 ", _deviceId]; diag_log format["handleVehicleDeviceKilled: %1 DATA: %2", _deviceId, _data]; diff --git a/addons/bft/functions/fnc_isDeviceOwned.sqf b/addons/bft/functions/fnc_isDeviceOwned.sqf index ef032aafa8..37ddadf90e 100644 --- a/addons/bft/functions/fnc_isDeviceOwned.sqf +++ b/addons/bft/functions/fnc_isDeviceOwned.sqf @@ -16,7 +16,6 @@ params ["_unit", "_deviceID"]; -private ["_ownedIDs"]; -_ownedIDs = _unit getvariable [QGVAR(ownedDevices), []]; +private _ownedIDs = _unit getvariable [QGVAR(ownedDevices), []]; (_deviceID in _ownedIDs) diff --git a/addons/bft/functions/fnc_removeDeviceByOwner.sqf b/addons/bft/functions/fnc_removeDeviceByOwner.sqf index ae5fa72a3b..f29faf87af 100644 --- a/addons/bft/functions/fnc_removeDeviceByOwner.sqf +++ b/addons/bft/functions/fnc_removeDeviceByOwner.sqf @@ -13,13 +13,13 @@ #include "script_component.hpp" -private ["_owner", "_deviceOwner", "_device"]; params ["_deviceData"]; -_owner = D_GET_OWNER(_deviceData); + +private _owner = D_GET_OWNER(_deviceData); for "_i" from (count GVAR(availableDevices) - 1) to 0 step -1 do { - _device = GVAR(availableDevices) select _i; - _deviceOwner = AD_GET_OWNER(_device); + private _device = GVAR(availableDevices) select _i; + private _deviceOwner = AD_GET_OWNER(_device); if (_owner == _deviceOwner) then { GVAR(availableDevices) deleteAt _i; _i = _i - 1; diff --git a/addons/bft/functions/fnc_setDeviceAppData.sqf b/addons/bft/functions/fnc_setDeviceAppData.sqf index d6a49c45c5..d295e50ef1 100644 --- a/addons/bft/functions/fnc_setDeviceAppData.sqf +++ b/addons/bft/functions/fnc_setDeviceAppData.sqf @@ -16,8 +16,7 @@ params ["_deviceID", "_deviceData"]; -private ["_data"]; -_data = [_deviceID] call FUNC(getDeviceData); +private _data = [_deviceID] call FUNC(getDeviceData); if (count _data == 0) exitwith {}; if (_deviceData isEqualTo (_data select 3)) exitwith {}; diff --git a/addons/bft/functions/fnc_setDeviceCallsign.sqf b/addons/bft/functions/fnc_setDeviceCallsign.sqf index 4310a70d5e..bca9829453 100644 --- a/addons/bft/functions/fnc_setDeviceCallsign.sqf +++ b/addons/bft/functions/fnc_setDeviceCallsign.sqf @@ -16,8 +16,7 @@ params ["_deviceID", "_callsign"]; -private ["_data"]; -_data = [_deviceID] call FUNC(getDeviceData); +private _data = [_deviceID] call FUNC(getDeviceData); if (count _data < 3) exitwith {}; if (count (_data select 2) < 3) exitwith {}; diff --git a/addons/bft/functions/fnc_setDeviceElementType.sqf b/addons/bft/functions/fnc_setDeviceElementType.sqf index e64b0ad36a..56a3030a64 100644 --- a/addons/bft/functions/fnc_setDeviceElementType.sqf +++ b/addons/bft/functions/fnc_setDeviceElementType.sqf @@ -16,8 +16,7 @@ params ["_deviceID", "_elementType"]; -private ["_data"]; -_data = [_deviceID] call FUNC(getDeviceData); +private _data = [_deviceID] call FUNC(getDeviceData); if (count _data < 3) exitwith {}; if (count (_data select 2) < 2) exitwith {}; diff --git a/addons/bft/functions/fnc_setDeviceGroup.sqf b/addons/bft/functions/fnc_setDeviceGroup.sqf index 8a91e9c7fc..4c100e6fe0 100644 --- a/addons/bft/functions/fnc_setDeviceGroup.sqf +++ b/addons/bft/functions/fnc_setDeviceGroup.sqf @@ -16,8 +16,7 @@ params ["_deviceID", "_groupID"]; -private ["_data"]; -_data = [_deviceID] call FUNC(getDeviceData); +private _data = [_deviceID] call FUNC(getDeviceData); if (count _data < 3) exitwith {}; if (count (_data select 2) < 4) exitwith {}; diff --git a/addons/bft/functions/fnc_setDeviceKeys.sqf b/addons/bft/functions/fnc_setDeviceKeys.sqf index 8cc17a74f8..558dc84330 100644 --- a/addons/bft/functions/fnc_setDeviceKeys.sqf +++ b/addons/bft/functions/fnc_setDeviceKeys.sqf @@ -16,8 +16,7 @@ params ["_deviceID", "_keys"]; -private ["_data"]; -_data = [_deviceID] call FUNC(getDeviceData); +private _data = [_deviceID] call FUNC(getDeviceData); if (count _data < 2) exitwith {}; if (count (_data select 1) < 2) exitwith {}; diff --git a/addons/bft/functions/fnc_setDeviceOwner.sqf b/addons/bft/functions/fnc_setDeviceOwner.sqf index aad596ec50..6f85bb6380 100644 --- a/addons/bft/functions/fnc_setDeviceOwner.sqf +++ b/addons/bft/functions/fnc_setDeviceOwner.sqf @@ -16,8 +16,7 @@ params ["_deviceID", "_newOwner"]; -private ["_data"]; -_data = [_deviceID] call FUNC(getDeviceData); +private _data = [_deviceID] call FUNC(getDeviceData); if (count _data < 6) exitwith {}; if (_newOwner isEqualTo (_data select 5)) exitwith {}; diff --git a/addons/bft/functions/fnc_syncedArrayGetNextID.sqf b/addons/bft/functions/fnc_syncedArrayGetNextID.sqf index b780f4d172..4d7c572378 100644 --- a/addons/bft/functions/fnc_syncedArrayGetNextID.sqf +++ b/addons/bft/functions/fnc_syncedArrayGetNextID.sqf @@ -15,9 +15,8 @@ params ["_varName"]; -private ["_variable", "_nextID"]; -_variable = missionNamespace getvariable [_varName, []]; -_nextID = 0; +private _variable = missionNamespace getvariable [_varName, []]; +private _nextID = 0; if (count _variable > 0) then { _nextID = ((_variable select (count _variable - 1)) select 0) + 1; diff --git a/addons/bft/functions/fnc_updateRegisteredEncryptionKeys.sqf b/addons/bft/functions/fnc_updateRegisteredEncryptionKeys.sqf index 2eedaffe9f..9f46684120 100644 --- a/addons/bft/functions/fnc_updateRegisteredEncryptionKeys.sqf +++ b/addons/bft/functions/fnc_updateRegisteredEncryptionKeys.sqf @@ -25,8 +25,7 @@ if (isNil "_add") then { ["bft_registeredEncryptionKeysChanged", [_keys,nil]] call CBA_fnc_localEvent; }; } else { - private ["_changed"]; - _changed = false; + private _changed = false; if (_add) then { // figure out the real difference diff --git a/addons/bft/functions/fnc_updateRegisteredModes.sqf b/addons/bft/functions/fnc_updateRegisteredModes.sqf index a930d6778a..a110efb288 100644 --- a/addons/bft/functions/fnc_updateRegisteredModes.sqf +++ b/addons/bft/functions/fnc_updateRegisteredModes.sqf @@ -25,8 +25,7 @@ if (isNil "_add") then { ["bft_registeredModeChanged", [_modes,nil]] call CBA_fnc_localEvent; }; } else { - private ["_changed"]; - _changed = false; + private _changed = false; if (_add) then { // figure out the real difference @@ -43,6 +42,7 @@ if (isNil "_add") then { _changed = true; }; }; + if (_changed) then { ["bft_registeredModeChanged", [_modes,_add]] call CBA_fnc_localEvent; }; diff --git a/addons/bft/functions/fnc_validateInventory.sqf b/addons/bft/functions/fnc_validateInventory.sqf index 47fcc84e7e..87f4653fa1 100644 --- a/addons/bft/functions/fnc_validateInventory.sqf +++ b/addons/bft/functions/fnc_validateInventory.sqf @@ -15,19 +15,17 @@ params ["_unit"]; -private ["_magazine", "_data", "_magID", "_unMatchedDevices", "_ownedDevices", "_matchedIDs"]; - if !(local _unit) exitwith {}; { [_unit, _x] call FUNC(checkItem); } forEach items _unit; -_ownedDevices = _unit getvariable [QGVAR(ownedDevices), []]; -_matchedIDs = []; +private _ownedDevices = _unit getvariable [QGVAR(ownedDevices), []]; +private _matchedIDs = []; { - _magID = [_x] call FUNC(getMagazineID); - _data = [_magID] call FUNC(getDeviceData); + private _magID = [_x] call FUNC(getMagazineID); + private _data = [_magID] call FUNC(getDeviceData); if (count _data > 0) then { if !(_magID in _ownedDevices) then { systemChat format["validate - new picked up ID: %1 %2", _unit, _magID]; @@ -37,7 +35,7 @@ _matchedIDs = []; _matchedIDs pushback _magID; } else { if (!(_magId in GVAR(pendingIdAssignmentList))) then { - _magazine = (magazines _unit) select _forEachIndex; + private _magazine = (magazines _unit) select _forEachIndex; if (getText (configFile >> "CfgMagazines" >> _magazine >> QGVAR(type)) != "") then { ["bft_itemCreated", [_unit, getText (configFile >> "CfgMagazines" >> _magazine >> QGVAR(type)), _magazine, _magID]] call CBA_fnc_serverEvent; }; @@ -45,7 +43,7 @@ _matchedIDs = []; }; }foreach (magazinesDetail _unit); -_unMatchedDevices = _ownedDevices - _matchedIDs; +private _unMatchedDevices = _ownedDevices - _matchedIDs; { systemChat format["validate - no longer has ID: %1 %2", _unit, _x]; diag_log format["validate - no longer has ID: %1 %2", _unit, _x]; diff --git a/addons/bft/functions/fnc_vehicleInit.sqf b/addons/bft/functions/fnc_vehicleInit.sqf index cd8b5a4d83..2261e0602e 100644 --- a/addons/bft/functions/fnc_vehicleInit.sqf +++ b/addons/bft/functions/fnc_vehicleInit.sqf @@ -20,8 +20,7 @@ diag_log format["VehicleInit: %1",_this]; if !(isServer) exitwith {}; -private ["_device"]; -_device = _vehicle getvariable [QGVAR(vehicleDevice), getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(vehicleDevice))]; +private _device = _vehicle getvariable [QGVAR(vehicleDevice), getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(vehicleDevice))]; systemChat format["VehicleInit devices: %1",_device]; diag_log format["VehicleInit devices: %1",_device]; diff --git a/addons/bft_devices/functions/fnc_createUavCam.sqf b/addons/bft_devices/functions/fnc_createUavCam.sqf index f6f3c8dbc5..fe1acbf27c 100644 --- a/addons/bft_devices/functions/fnc_createUavCam.sqf +++ b/addons/bft_devices/functions/fnc_createUavCam.sqf @@ -77,7 +77,7 @@ if (!alive _uav) exitWith {false}; }; _cam camSetFov 0.5; // set default zoom }; - 0 = GVAR(UAVcams) pushBack [_uav,_renderTarget,_cam,_camPosMemPt,_camDirMemPt]; + GVAR(UAVcams) pushBack [_uav,_renderTarget,_cam,_camPosMemPt,_camDirMemPt]; }; } count _uavCams; diff --git a/addons/bft_devices/functions/fnc_decBrightness.sqf b/addons/bft_devices/functions/fnc_decBrightness.sqf index 7d2847f0f3..78ed79cb13 100644 --- a/addons/bft_devices/functions/fnc_decBrightness.sqf +++ b/addons/bft_devices/functions/fnc_decBrightness.sqf @@ -20,10 +20,10 @@ params ["_interfaceID"]; -private _brightness = [_interfaceID,"brightness"] call FUNC(getSettings); +private _brightness = [_interfaceID, "brightness"] call FUNC(getSettings); _brightness = _brightness - 0.1; // make sure brightness is not larger than 0.5 if (_brightness < 0.5) then {_brightness = 0.5}; -[_interfaceID,[["brightness",_brightness]]] call FUNC(setSettings); +[_interfaceID, [["brightness",_brightness]]] call FUNC(setSettings); true diff --git a/addons/bft_devices/functions/fnc_getBackgroundPosition.sqf b/addons/bft_devices/functions/fnc_getBackgroundPosition.sqf index 423da230bd..e2df957a0f 100644 --- a/addons/bft_devices/functions/fnc_getBackgroundPosition.sqf +++ b/addons/bft_devices/functions/fnc_getBackgroundPosition.sqf @@ -39,15 +39,13 @@ private _backgroundPosition = ctrlPosition _backgroundCtrl; // get the original position of the background control private _backgroundConfigPosition = []; { - if (isClass _x) then { - if (isClass (_x >> _backgroundClassName)) exitWith { - _backgroundConfigPosition = [ - getNumber (_x >> _backgroundClassName >> "x"), - getNumber (_x >> _backgroundClassName >> "y"), - getNumber (_x >> _backgroundClassName >> "w"), - getNumber (_x >> _backgroundClassName >> "h") - ]; - }; + if (isClass _x && {isClass (_x >> _backgroundClassName)}) exitWith { + _backgroundConfigPosition = [ + getNumber (_x >> _backgroundClassName >> "x"), + getNumber (_x >> _backgroundClassName >> "y"), + getNumber (_x >> _backgroundClassName >> "w"), + getNumber (_x >> _backgroundClassName >> "h") + ]; }; } forEach _displayConfigContainers; diff --git a/addons/bft_devices/functions/fnc_ifOpen.sqf b/addons/bft_devices/functions/fnc_ifOpen.sqf index e6b8cf0bb8..97bf8153e5 100644 --- a/addons/bft_devices/functions/fnc_ifOpen.sqf +++ b/addons/bft_devices/functions/fnc_ifOpen.sqf @@ -74,7 +74,7 @@ GVAR(ifOpen) = [ ]; // Only register the GetOut event handler for vehicle displays -if (_inVehicle && (_isDialog || _displayName in [QGVAR(TAD_dsp)])) then { +if (_inVehicle && {_isDialog || _displayName in [QGVAR(TAD_dsp)]}) then { GVAR(ifOpen) set [9, _vehicle addEventHandler ["GetOut",{if (_this select 2 == ACE_player) then {[] call FUNC(ifClose)}}] ]; diff --git a/addons/bft_devices/functions/fnc_onIfToggleKey.sqf b/addons/bft_devices/functions/fnc_onIfToggleKey.sqf index d95abf0f69..e8cd3f825f 100644 --- a/addons/bft_devices/functions/fnc_onIfToggleKey.sqf +++ b/addons/bft_devices/functions/fnc_onIfToggleKey.sqf @@ -70,12 +70,12 @@ if (_playerDeviceData isEqualTo [] && _vehicleDeviceData isEqualTo []) exitWith // get interface for device private _playerDeviceInterface = if !(_playerDeviceData isEqualTo []) then { - _interfaces = [_playerDeviceId,ACE_player] call EFUNC(bft,getInterfaces); + private _interfaces = [_playerDeviceId,ACE_player] call EFUNC(bft,getInterfaces); // select the first device -- for now if (count _interfaces > 0) then {_interfaces select 0} else {""}; } else {""}; private _vehicleDeviceInterface = if !(_vehicleDeviceData isEqualTo []) then { - _interfaces = [_vehicleDeviceId,ACE_player] call EFUNC(bft,getInterfaces); + private _interfaces = [_vehicleDeviceId,ACE_player] call EFUNC(bft,getInterfaces); // select the first device -- for now if (count _interfaces > 0) then {_interfaces select 0} else {""}; } else {""}; diff --git a/addons/bft_devices/functions/fnc_openDevice.sqf b/addons/bft_devices/functions/fnc_openDevice.sqf index 93f045bb3d..a1e1c6a70b 100644 --- a/addons/bft_devices/functions/fnc_openDevice.sqf +++ b/addons/bft_devices/functions/fnc_openDevice.sqf @@ -43,6 +43,6 @@ if (_return) then { if (_interfaces isEqualTo []) exitwith {}; _interfaces params [ ["_interface", nil] ]; - _interfaceDisplayName = getText (configFile >> "ACE_BFT" >> "Interfaces" >> _interface >> "dialogName"); + private _interfaceDisplayName = getText (configFile >> "ACE_BFT" >> "Interfaces" >> _interface >> "dialogName"); [_deviceID, _interface, 0 /* main interface type */,_interfaceDisplayName, true /*Is Dialog*/, _player, _target] call FUNC(ifOpen); }; diff --git a/addons/bft_devices/functions/fnc_setInterfacePosition.sqf b/addons/bft_devices/functions/fnc_setInterfacePosition.sqf index 968bdb55f8..67da5e5ad0 100644 --- a/addons/bft_devices/functions/fnc_setInterfacePosition.sqf +++ b/addons/bft_devices/functions/fnc_setInterfacePosition.sqf @@ -36,20 +36,17 @@ _displayConfigContainers = "true" configClasses _displayConfigContainers; if (isClass _x) then { private _displayConfigClasses = "true" configClasses _x; { - if (isClass _x) then { - // only move controls that have an IDC - if (isNumber (_x >> "idc")) then { - // only move controls that have a positive IDC - private _idc = getNumber (_x >> "idc"); - if (_idc > 0) then { - private _ctrl = _display displayCtrl _idc; - private _ctrlPosition = ctrlPosition _ctrl; - _ctrlPosition set [0, (_ctrlPosition select 0) + _xOffset]; - _ctrlPosition set [1, (_ctrlPosition select 1) + _yOffset]; - _ctrl ctrlSetPosition _ctrlPosition; - _ctrl ctrlCommit 0; - } else {diag_log str ["invalid IDC",_x]}; - } else {diag_log str ["missing IDC",_x]}; + if (isClass _x && {isNumber (_x >> "idc")}) then { + // only move controls that have a positive IDC + private _idc = getNumber (_x >> "idc"); + if (_idc > 0) then { + private _ctrl = _display displayCtrl _idc; + private _ctrlPosition = ctrlPosition _ctrl; + _ctrlPosition set [0, (_ctrlPosition select 0) + _xOffset]; + _ctrlPosition set [1, (_ctrlPosition select 1) + _yOffset]; + _ctrl ctrlSetPosition _ctrlPosition; + _ctrl ctrlCommit 0; + } else {diag_log str ["invalid IDC",_x]}; }; } forEach _displayConfigClasses; }; diff --git a/addons/bft_devices/functions/fnc_updateHCamList.sqf b/addons/bft_devices/functions/fnc_updateHCamList.sqf index ead948a4d0..4ff30ae5e3 100644 --- a/addons/bft_devices/functions/fnc_updateHCamList.sqf +++ b/addons/bft_devices/functions/fnc_updateHCamList.sqf @@ -28,8 +28,8 @@ private _deviceEncryptionKey = D_GET_ENCRYPTION(_deviceData); // compile a list of valid sides private _validSides = []; { - if ([_deviceEncryptionKey,[_x] call EFUNC(bft,getEncryptionKey)] call EFUNC(bft,encryptionKeyMatch)) then { - 0 = _validSides pushBack _x; + if ([_deviceEncryptionKey, [_x] call EFUNC(bft,getEncryptionKey)] call EFUNC(bft,encryptionKeyMatch)) then { + _validSides pushBack _x; }; } count ["WEST","EAST","GUER","CIV"]; @@ -37,8 +37,8 @@ private _validSides = []; private _hcamList = []; { if (str side _x in _validSides) then { - if ("ACE_HelmetCam" in items _x) then { - 0 = _hcamList pushBack _x; + if ("ACE_HelmetCam" in (items _x)) then { + _hcamList pushBack _x; }; }; } count allUnits; diff --git a/addons/bft_devices/functions/fnc_updateUAVList.sqf b/addons/bft_devices/functions/fnc_updateUAVList.sqf index 57ce5a9078..566ef249c9 100644 --- a/addons/bft_devices/functions/fnc_updateUAVList.sqf +++ b/addons/bft_devices/functions/fnc_updateUAVList.sqf @@ -37,7 +37,7 @@ GVAR(UAVlist) = []; // check if UAV has matching encryption key private _uavEncryption = D_GET_ENCRYPTION(_uavDeviceData); if ([_deviceEncryption,_uavEncryption] call EFUNC(BFT,encryptionKeyMatch)) then { - 0 = GVAR(UAVlist) pushBack [_uavDevice,_uavDeviceData]; + GVAR(UAVlist) pushBack [_uavDevice,_uavDeviceData]; }; }; } count allUnitsUAV;