Cleanup and fixes

This commit is contained in:
TheMagnetar 2018-02-01 00:08:07 +01:00
parent 1f603cc814
commit 6cc05038ff
57 changed files with 194 additions and 274 deletions

View File

@ -14,12 +14,10 @@
params ["_side", "_key"]; 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 { if !(_key in _keys) then {
_keys pushback _key; _keys pushback _key;
missionNamespace setvariable [_variableName, _keys]; missionNamespace setvariable [_variableName, _keys, true];
publicVariable "_variableName";
}; };

View File

@ -17,12 +17,12 @@
#include "script_component.hpp" #include "script_component.hpp"
params ["_fromId", "_toId", "_message"]; params ["_deviceId", "_otherDeviceId", "_message"];
private _messagesListKey = [_deviceId, _otherDeviceId] call FUNC(chatMessage_getId); private _messagesListKey = [_deviceId, _otherDeviceId] call FUNC(chatMessage_getId);
private _timeStamp = format["00:00"]; private _timeStamp = format["00:00"];
private _messageId = [] call FUNC(generateEncryptionKey); // some random key TODO improve or implement some unique Id generator 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); [_messagesListKey, _constructedMessage] call FUNC(syncedArrayPushback);

View File

@ -19,4 +19,4 @@ if !(local _unit) exitwith {};
{ {
[_unit, _x] call FUNC(checkItem); [_unit, _x] call FUNC(checkItem);
}foreach items _unit; } foreach items _unit;

View File

@ -16,8 +16,6 @@
params ["_unit", "_item"]; params ["_unit", "_item"];
private ["_magazine", "_previousMags", "_newMagName", "_newMags", "_magID"];
if !(local _unit) exitwith {}; if !(local _unit) exitwith {};
if (isText (configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) && {getText(configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) != ""}) then { 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]; systemChat format["%1 BFT enabled item %2", _unit, _item];
diag_log 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 { if (_magazine != "") then {
systemChat format["%1 replacing by %2", _item, _magazine]; systemChat format["%1 replacing by %2", _item, _magazine];
diag_log format["%1 replacing by %2", _item, _magazine]; diag_log format["%1 replacing by %2", _item, _magazine];
_unit removeItem _item; _unit removeItem _item;
_previousMags = magazinesDetail _unit; private _previousMags = magazinesDetail _unit;
_unit addMagazine _magazine; _unit addMagazine _magazine;
_newMags = (magazinesDetail _unit) - _previousMags; private _newMags = (magazinesDetail _unit) - _previousMags;
if ((count _newMags) == 0) exitWith {ERROR("failed to add magazine (inventory full?)");}; 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]; systemChat format["%1 id %2", _item, _magID];
diag_log format["%1 id %2", _item, _magID]; diag_log format["%1 id %2", _item, _magID];

View File

@ -19,8 +19,7 @@ params ["_groupID"];
if (count _this < 3) exitwith {}; // What is the 3rd parameter? if (count _this < 3) exitwith {}; // What is the 3rd parameter?
private ["_found"]; private _found = false;
_found = false;
{ {
if (_x select 0 == _groupID) exitwith {_found = true;}; if (_x select 0 == _groupID) exitwith {_found = true;};
} forEach GVAR(orbatElements); } forEach GVAR(orbatElements);

View File

@ -13,15 +13,14 @@
#include "script_component.hpp" #include "script_component.hpp"
private [ "_deviceID", "_owner","_deviceClass", "_encryptionKeys", "_access", "_typeIconPath", "_sizeIconPath", "_callsign","_groupID", "_position", "_direction", "_refreshRate", "_viewModes", "_color", "_state"]; private _deviceID = D_GET_ID(_this);
_deviceID = D_GET_ID(_this); private _owner = D_GET_OWNER(_this);
_owner = D_GET_OWNER(_this); private _deviceClass = D_GET_CLASSNAME(_this);
_deviceClass = D_GET_CLASSNAME(_this); private _refreshRate = D_GET_REFRESH_RATE_TX(_this);
_refreshRate = D_GET_REFRESH_RATE_TX(_this); private _viewModes = D_GET_DEVICEMODES(_this);
_viewModes = D_GET_DEVICEMODES(_this);
_encryptionKeys = D_GET_ENCRYPTION(_this); private _encryptionKeys = D_GET_ENCRYPTION(_this);
_state = D_GET_DEVICE_STATE(_this); private _state = D_GET_DEVICE_STATE(_this);
/*_access = true; /*_access = true;
{ {
if (_x in _encryptionKeys) exitwith {_access = true; }; if (_x in _encryptionKeys) exitwith {_access = true; };
@ -29,14 +28,14 @@ _state = D_GET_DEVICE_STATE(_this);
if !(_access) exitwith {[]};*/ if !(_access) exitwith {[]};*/
_typeIconPath = [D_GET_SIDE(_this), D_GET_TYPE(_this)] call FUNC(getTypeIcon); private _typeIconPath = [D_GET_SIDE(_this), D_GET_TYPE(_this)] call FUNC(getTypeIcon);
_sizeIconPath = [D_GET_SIDE(_this), D_GET_SIZE(_this)] call FUNC(getSizeIcon); private _sizeIconPath = [D_GET_SIDE(_this), D_GET_SIZE(_this)] call FUNC(getSizeIcon);
_callsign = D_GET_CALLSIGN(_this); private _callsign = D_GET_CALLSIGN(_this);
_groupID = D_GET_GROUP_ID(_this); private _groupID = D_GET_GROUP_ID(_this);
_position = getPosASL vehicle _owner; private _position = getPosASL vehicle _owner;
_direction = direction vehicle _owner; private _direction = direction vehicle _owner;
_color = [_groupID] call FUNC(getGroupColor); private _color = [_groupID] call FUNC(getGroupColor);
if (_callsign == "" && {_owner isKindOf "CAManBase"}) then { if (_callsign == "" && {_owner isKindOf "CAManBase"}) then {
_callsign = groupId group _owner; _callsign = groupId group _owner;

View File

@ -16,13 +16,4 @@
params ["_keySetOne", "_keySetTwo"]; params ["_keySetOne", "_keySetTwo"];
private ["_return"]; count (_keySetOne arrayIntersect _keySetTwo) > 0
// ToDo: replace with arrayIntersect when available
// count (_keySetOne arrayIntersect _keySetTwo) > 0
_return = false;
{
if (_x in _keySetTwo) exitWith { _return = true; };
} forEach _keySetOne;
_return

View File

@ -12,8 +12,7 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_newKeyArray"]; private _newKeyArray = [];
_newKeyArray = [];
for "_i" from 1 to 15 /* step +1 */ do { for "_i" from 1 to 15 /* step +1 */ do {
_newKeyArray pushback (48 + floor(random(74))); _newKeyArray pushback (48 + floor(random(74)));

View File

@ -15,19 +15,15 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_deviceConfigs","_allReportingModes","_deviceReportingModes"]; private _deviceConfigs = "true" configClasses (configFile >> "ACE_BFT" >> "Devices");
_deviceConfigs = "true" configClasses (configFile >> "ACE_BFT" >> "Devices"); private _allReportingModes = [];
_allReportingModes = [];
{ {
if (isClass _x) then { if (isClass _x && {isArray (_x >> "reportingModes")}) then {
if (isArray (_x >> "reportingModes")) then { private _deviceReportingModes = getArray (_x >> "reportingModes");
_deviceReportingModes = getArray (_x >> "reportingModes");
// only append what isn't there already // only append what isn't there already
_allReportingModes append (_deviceReportingModes - _allReportingModes); _allReportingModes append (_deviceReportingModes - _allReportingModes);
}; };
}
} forEach _deviceConfigs; } forEach _deviceConfigs;
_allReportingModes _allReportingModes

View File

@ -15,8 +15,7 @@
params ["_deviceID"]; params ["_deviceID"];
private ["_data"]; private _data = [];
_data = [];
{ {
if (_x select 0 == _deviceID) exitWith { if (_x select 0 == _deviceID) exitWith {
_data = _x; // GVAR(deviceData) select _foreachIndex; _data = _x; // GVAR(deviceData) select _foreachIndex;

View File

@ -15,10 +15,9 @@
params ["_groupID"]; params ["_groupID"];
private ["_data", "_found", "_color"]; private _data = [_groupID] call FUNC(getGroupData);
_data = [_groupID] call FUNC(getGroupData); private _found = false;
_found = false; private _color = GVAR(colorWest);
_color = GVAR(colorWest);
while {!_found} do { while {!_found} do {
if (_groupID < 0) exitWith {}; if (_groupID < 0) exitWith {};

View File

@ -15,8 +15,7 @@
params ["_groupID"]; params ["_groupID"];
private ["_data"]; private _data = [_groupID, "", -1/*parent group ID*/];
_data = [_groupID, "", -1/*parent group ID*/];
{ {
if (_x select 0 == _groupID) exitWith { if (_x select 0 == _groupID) exitWith {
_data = _x; _data = _x;

View File

@ -19,37 +19,36 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_deviceData","_deviceOwner","_interfaces","_interface","_deviceType","_vehicleInterfaces","_assignedVehicleRole","_roleIndex","_roleName","_whereAvailable","_found"];
params ["_deviceID", "_unit"]; params ["_deviceID", "_unit"];
_deviceData = [_deviceID] call EFUNC(bft,getDeviceData); private _deviceData = [_deviceID] call EFUNC(bft,getDeviceData);
_deviceOwner = D_GET_OWNER(_deviceData); 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 // personal device
_deviceType = D_GET_DEVICETYPE(_deviceData); private _deviceType = D_GET_DEVICETYPE(_deviceData);
if (isText (configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "interface")) then { 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 { if (_interface != "") then {
_interfaces pushBack _interface; _interfaces pushBack _interface;
}; };
}; };
} else { } else {
// vehicle device // 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 // bail if there are no interfaces defined
if (isNil "_vehicleInterfaces" || {_vehicleInterfaces isEqualTo []}) exitWith {}; if (isNil "_vehicleInterfaces" || {_vehicleInterfaces isEqualTo []}) exitWith {};
_assignedVehicleRole = assignedVehicleRole _unit; private _assignedVehicleRole = assignedVehicleRole _unit;
// bail if unit is not in a vehicle // bail if unit is not in a vehicle
if (_assignedVehicleRole isEqualTo []) exitWith {}; if (_assignedVehicleRole isEqualTo []) exitWith {};
_roleName = _assignedVehicleRole select 0; private _roleName = _assignedVehicleRole select 0;
_roleIndex = call { private _roleIndex = call {
if (_roleName == "Cargo") exitWith {_deviceOwner getCargoIndex _unit}; if (_roleName == "Cargo") exitWith {_deviceOwner getCargoIndex _unit};
if (_roleName == "Turret") exitWith {_assignedVehicleRole select 1 select 0}; if (_roleName == "Turret") exitWith {_assignedVehicleRole select 1 select 0};
0 0
@ -61,17 +60,18 @@ if (_deviceOwner isKindOf "ParachuteBase" || _deviceOwner isKindOf "CAManBase")
case "ARRAY": { case "ARRAY": {
// whereAvailable test // whereAvailable test
_interface = _x select 0; private _interface = _x select 0;
_whereAvailable = _x select 1; private _whereAvailable = _x select 1;
{ {
_found = switch (typeName _x) do { private _found = false;
switch (typeName _x) do {
case "STRING": { case "STRING": {
if (_x == _roleName) then {true}; if (_x == _roleName) then {_found = true};
}; };
case "ARRAY": { 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}; if (_found) exitWith {_interfaces pushBack _interface};

View File

@ -15,12 +15,11 @@
params ["_detailsEntry"]; params ["_detailsEntry"];
private ["_index", "_value", "_id"]; private _index = _detailsEntry find "[";
_index = _detailsEntry find "["; private _id = "";
_id = "";
if (_index > 0) then { if (_index > 0) then {
_value = toArray _detailsEntry; private _value = toArray _detailsEntry;
_value deleteRange [0, _index]; _value deleteRange [0, _index];
_id = toString _value; _id = toString _value;
}; };

View File

@ -16,8 +16,7 @@
params ["_owner"]; params ["_owner"];
// Or use OBJECT getvariable [QGVAR(ownedDevices), []]; ? // Or use OBJECT getvariable [QGVAR(ownedDevices), []]; ?
private ["_ids"]; private _ids = [];
_ids = [];
{ {
if ((_x select 5) == _owner) then { if ((_x select 5) == _owner) then {

View File

@ -18,7 +18,6 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_currentDevices"];
// [_magID, [_deviceSide, _deviceEncryptionKeys], _assignableInformation, _app, -1, _owner] // [_magID, [_deviceSide, _deviceEncryptionKeys], _assignableInformation, _app, -1, _owner]
diag_log format["added to deviceData: %1", _this]; diag_log format["added to deviceData: %1", _this];
GVAR(deviceData) pushback _this; GVAR(deviceData) pushback _this;
@ -27,7 +26,7 @@ systemChat format["handleAddDeviceData: %1", _this];
diag_log format["handleAddDeviceData: %1", _this]; diag_log format["handleAddDeviceData: %1", _this];
if (local (_this select 5)) then { 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 { if !((_this select 0) in _currentDevices) then {
_currentDevices pushback (_this select 0); _currentDevices pushback (_this select 0);
(_this select 5) setvariable [QGVAR(ownedDevices), _currentDevices, true]; (_this select 5) setvariable [QGVAR(ownedDevices), _currentDevices, true];

View File

@ -13,10 +13,9 @@
#include "script_component.hpp" #include "script_component.hpp"
{ {
private ["_groupID","_color"]; private _groupID = (_x select 6) select 0;
_groupID = (_x select 6) select 0;
if (_groupID >= 0) then { if (_groupID >= 0) then {
_color = [_groupID] call FUNC(getGroupColor); private _color = [_groupID] call FUNC(getGroupColor);
(_x select 6) set [1, _color]; (_x select 6) set [1, _color];
}; };
} foreach GVAR(availableDevices); } foreach GVAR(availableDevices);

View File

@ -12,9 +12,9 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_data", "_deviceID", "_displayData", "_encryptionKeys", "_deviceModes"]; params ["_data"];
_data = _this select 0;
_deviceID = D_GET_ID(_data); private _deviceID = D_GET_ID(_data);
diag_log format["hanldeDeviceDataChanged for: %1", _deviceID]; diag_log format["hanldeDeviceDataChanged for: %1", _deviceID];
if (isNull D_GET_OWNER(_data)) exitwith { // doesn't have an owner anymore, remove. 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); } foreach GVAR(availableDevices);
}; };
}; };
_encryptionKeys = D_GET_ENCRYPTION(_data); private _encryptionKeys = D_GET_ENCRYPTION(_data);
_deviceModes = D_GET_DEVICEMODES(_data); private _deviceModes = D_GET_DEVICEMODES(_data);
if (_this select 1) then { // add new if (_this select 1) then { // add new
if !([_encryptionKeys, GVAR(registeredEncyptionKeys)] call FUNC(encryptionKeyMatch)) exitwith { 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 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_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 {}; 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 { if (count _displayData > 0) then {
GVAR(availableDevices) pushback _displayData; 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 // 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. // 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]; GVAR(availableDevices) set [_forEachIndex, _displayData];
}; };
} foreach GVAR(availableDevices); } foreach GVAR(availableDevices);

View File

@ -12,12 +12,10 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_deviceID","_refreshRateRX","_deviceData"];
// by default, consider the device not having a receiver // by default, consider the device not having a receiver
_refreshRateRX = -1; private _refreshRateRX = -1;
_deviceID = _this select 0; private _deviceID = _this select 0;
_deviceData = [_deviceID] call FUNC(getDeviceData); private _deviceData = [_deviceID] call FUNC(getDeviceData);
GVAR(currentOpenedDevice) = _deviceData; GVAR(currentOpenedDevice) = _deviceData;
if !(_deviceData isEqualTo []) then { if !(_deviceData isEqualTo []) then {
_refreshRateRX = D_GET_REFRESH_RATE_RX(_deviceData); _refreshRateRX = D_GET_REFRESH_RATE_RX(_deviceData);

View File

@ -16,11 +16,8 @@ params ["_object", "_turnedOn"];
// clear out any device in available devices that is owned by the object. // 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 // 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 { 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_DEVICE_STATE_VALUE(_device) isEqualTo STATE_NORMAL) then {
if (AD_GET_OWNER(_device) == _object) then { if (AD_GET_OWNER(_device) == _object) then {
GVAR(availableDevices) deleteAt _i; GVAR(availableDevices) deleteAt _i;
@ -30,9 +27,8 @@ for "_i" from (count GVAR(availableDevices) - 1) to 0 step -1 do {
}; };
if (_turnedOn) then { if (_turnedOn) then {
private ["_deviceData", "_encryptionKeys", "_deviceModes", "_displayData"];
{ {
_deviceData = [_x] call FUNC(getDeviceData); private _deviceData = [_x] call FUNC(getDeviceData);
if (!(_deviceData isEqualTo [])) then { if (!(_deviceData isEqualTo [])) then {
if !(isNull D_GET_OWNER(_deviceData)) then { if !(isNull D_GET_OWNER(_deviceData)) then {
if (D_GET_DEVICE_STATE_VALUE(_deviceData) isEqualTo STATE_OFFLINE) 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 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 {}; 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 {}; if !([_deviceModes, GVAR(registeredViewModes)] call FUNC(encryptionKeyMatch)) exitWith {};
_displayData = _deviceData call FUNC(deviceDataToMapData); private _displayData = _deviceData call FUNC(deviceDataToMapData);
if (count _displayData > 0) then { if (count _displayData > 0) then {
GVAR(availableDevices) pushback _displayData; GVAR(availableDevices) pushback _displayData;
}; };
}; };
}; };
}foreach (_object getvariable [QGVAR(ownedDevices), []]); } foreach (_object getvariable [QGVAR(ownedDevices), []]);
} else { } else {
if (!alive _object) exitwith {}; 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 (!(_deviceData isEqualTo [])) then {
if !(isNull D_GET_OWNER(_deviceData)) then { if !(isNull D_GET_OWNER(_deviceData)) then {
if (D_GET_DEVICE_STATE_VALUE(_deviceData) isEqualTo STATE_NORMAL) then { if (D_GET_DEVICE_STATE_VALUE(_deviceData) isEqualTo STATE_NORMAL) then {

View File

@ -18,8 +18,6 @@
params ["_owner", "_item", "_magazine", "_magID", ["_initialState", STATE_NORMAL]]; 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 Device ID
Side ID/encyrption ID Side ID/encyrption ID
@ -35,7 +33,7 @@ private ["_deviceType", "_deviceSide", "_refreshRate", "_deviceEncryptionKeys",
systemChat format["handleItemCreated: %1", _this]; systemChat format["handleItemCreated: %1", _this];
diag_log format["handleItemCreated: entry args: %1", _this]; diag_log format["handleItemCreated: entry args: %1", _this];
_exists = false; private _exists = false;
{ {
if (_magID == (_x select 0)) exitwith {_exists = true}; if (_magID == (_x select 0)) exitwith {_exists = true};
} forEach GVAR(deviceData); } forEach GVAR(deviceData);
@ -43,11 +41,11 @@ if (_exists) exitwith {
diag_log format["handleItemCreated: Already exists: %1", _magID]; diag_log format["handleItemCreated: Already exists: %1", _magID];
}; };
_deviceType = if (_magazine != "") then { getText(configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) } else { _item }; private _deviceType = if (_magazine != "") then { getText(configFile >> "CfgWeapons" >> _item >> QGVAR(deviceType)) } else { _item };
_deviceSide = getText(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "deviceSide"); private _deviceSide = getText(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "deviceSide");
_deviceModes = getArray(configFile >> "ACE_BFT" >> "Devices" >> _deviceType >> "reportingModes"); 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 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 !(isNull _owner || {_owner isKindOf "ParachuteBase" || _owner isKindOf "CAManBase"}) then {
if (isArray (configFile >> "CfgVehicles" >> typeOf _owner >> QGVAR(defaultInformation))) 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"); _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]; private _elementType = _owner getvariable format[QGVAR(elementType_%1),_item];
_elementSize = _owner getvariable format[QGVAR(elementSize_%1),_item]; private _elementSize = _owner getvariable format[QGVAR(elementSize_%1),_item];
_elementCallsign = _owner getvariable format[QGVAR(elementCallsign_%1),_item]; private _elementCallsign = _owner getvariable format[QGVAR(elementCallsign_%1),_item];
_groupID = _owner getvariable format[QGVAR(groupID_%1),_item]; private _groupID = _owner getvariable format[QGVAR(groupID_%1),_item];
// format: [elementType, elementSize, elementCallsign, orbatElementID] // 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 { if (!isnil "_elementType") then {
_assignableInformation set [0, _elementType]; _assignableInformation set [0, _elementType];
@ -87,10 +85,10 @@ if (!isnil "_groupID") then {
}; };
// format: app ID, app data // 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] // 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]; diag_log format["Prep raising bft_addDeviceData _deviceInformation with: %1", _deviceInformation];
[{ [{

View File

@ -12,9 +12,7 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_add","_newEncryptionKeys"]; params ["_newEncryptionKeys", "_add"];
_newEncryptionKeys = _this select 0;
_add = _this select 1;
// if _add is nil, rebuild list from scratch // if _add is nil, rebuild list from scratch
if (isNil "_add") then { if (isNil "_add") then {
@ -27,30 +25,26 @@ if (isNil "_add") then {
if (count _newEncryptionKeys == 0) exitWith {}; if (count _newEncryptionKeys == 0) exitWith {};
if (_add) then { 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? // 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 !(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_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 {}; 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 {}; 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 {}; if !([_deviceModes, GVAR(registeredViewModes)] call FUNC(encryptionKeyMatch)) exitWith {};
_displayData = _x call FUNC(deviceDataToMapData); private _displayData = _x call FUNC(deviceDataToMapData);
if (count _displayData > 0) then { if (count _displayData > 0) then {
GVAR(availableDevices) pushback _displayData; GVAR(availableDevices) pushback _displayData;
}; };
}; };
} foreach GVAR(deviceData); } foreach GVAR(deviceData);
} else { // if we remove one, we only have to check the already available devices } 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 { 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 { if !([AD_GET_ENCRYPTION(_device), GVAR(registeredEncyptionKeys)] call FUNC(encryptionKeyMatch)) then {
GVAR(availableDevices) deleteAt _i; GVAR(availableDevices) deleteAt _i;
_i = _i - 1; _i = _i - 1;

View File

@ -12,9 +12,7 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_add","_viewModes"]; params ["_viewModes", "_add"];
_viewModes = _this select 0;
_add = _this select 1;
// if _add is nil, rebuild list from scratch // if _add is nil, rebuild list from scratch
if (isNil "_add") then { if (isNil "_add") then {
@ -27,19 +25,17 @@ if (isNil "_add") then {
if (count _viewModes == 0) exitWith {}; if (count _viewModes == 0) exitWith {};
if (_add) then { if (_add) then {
private ["_deviceModes","_encryptionKeys","_displayData"];
{ {
if !(isNull D_GET_OWNER(_x)) then { 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_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 {}; 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 {}; 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 {}; if !([_encryptionKeys, GVAR(registeredEncyptionKeys)] call FUNC(encryptionKeyMatch)) exitWith {};
_displayData = _x call FUNC(deviceDataToMapData); private _displayData = _x call FUNC(deviceDataToMapData);
if (count _displayData > 0) then { if (count _displayData > 0) then {
GVAR(availableDevices) pushback _displayData; GVAR(availableDevices) pushback _displayData;
}; };

View File

@ -29,9 +29,8 @@ diag_log format["handleRequestAllData: Request from Origin: %1", _origin];
{ {
diag_log format["handleRequestAllData: Add synced array variable: %1", _x]; diag_log format["handleRequestAllData: Add synced array variable: %1", _x];
private ["_varName", "_variable"]; private _varName = _x;
_varName = _x; private _variable = missionNamespace getvariable [_varName, []];
_variable = missionNamespace getvariable [_varName, []];
{ {
diag_log format["handleRequestAllData: Add synced array variable (%1) value: %2", _varName, _x]; diag_log format["handleRequestAllData: Add synced array variable (%1) value: %2", _varName, _x];

View File

@ -17,15 +17,13 @@
params ["_varName", "_elementID"]; params ["_varName", "_elementID"];
private ["_variable"]; private _variable = missionNamespace getvariable [_varName, []];
_variable = missionNamespace getvariable [_varName, []];
{ {
if ((_x select 0) isEqualTo _elementID) exitwith { if ((_x select 0) isEqualTo _elementID) exitwith {
systemChat format["handleSyncedArrayDelete deleting- %1", _x]; systemChat format["handleSyncedArrayDelete deleting- %1", _x];
diag_log format["handleSyncedArrayDelete deleting- %1", _x]; diag_log format["handleSyncedArrayDelete deleting- %1", _x];
private ["_removedElement"]; private _removedElement = _variable deleteAt _foreachIndex;
_removedElement = _variable deleteAt _foreachIndex;
["bft_syncedArrayChanged", [2, _removedElement]] call CBA_fnc_localEvent; ["bft_syncedArrayChanged", [2, _removedElement]] call CBA_fnc_localEvent;
}; };

View File

@ -16,12 +16,10 @@
params ["_varName", "_data"]; params ["_varName", "_data"];
private ["_variable"];
systemChat format["handleSyncedArrayPushback: %1", _this]; systemChat format["handleSyncedArrayPushback: %1", _this];
diag_log format["handleSyncedArrayPushback: %1", _this]; diag_log format["handleSyncedArrayPushback: %1", _this];
_variable = missionNamespace getvariable [_varName, []]; private _variable = missionNamespace getvariable [_varName, []];
_variable pushback _data; _variable pushback _data;
missionNamespace setvariable [_varName, _variable]; missionNamespace setvariable [_varName, _variable];
@ -30,8 +28,6 @@ missionNamespace setvariable [_varName, _variable];
systemChat format["handleSyncedArrayPushback %1 - %2", _varName, _variable]; systemChat format["handleSyncedArrayPushback %1 - %2", _varName, _variable];
diag_log format["handleSyncedArrayPushback %1 - %2", _varName, _variable]; diag_log format["handleSyncedArrayPushback %1 - %2", _varName, _variable];
if (isServer) then { if (isServer && {!(_varName in GVAR(syncedArrayVariables))}) then {
if !(_varName in GVAR(syncedArrayVariables)) then {
GVAR(syncedArrayVariables) pushback _varName; GVAR(syncedArrayVariables) pushback _varName;
};
}; };

View File

@ -18,15 +18,13 @@
params ["_varName", "_data"]; params ["_varName", "_data"];
private ["_elementID", "_variable", "_compareID"];
systemChat format["handleSyncedArrayUpdate - %1", _this]; systemChat format["handleSyncedArrayUpdate - %1", _this];
diag_log format["handleSyncedArrayUpdate - %1", _this]; diag_log format["handleSyncedArrayUpdate - %1", _this];
_elementID = if (typeName _data == "ARRAY") then {_data select 0} else {_data}; private _elementID = if (typeName _data == "ARRAY") then {_data select 0} else {_data};
_variable = missionNamespace getvariable [_varName, []]; 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 { if (_compareID isEqualTo _elementID) exitwith {
_variable set[_forEachIndex, _data]; _variable set[_forEachIndex, _data];
["bft_syncedArrayChanged", [1, _data, _x]] call CBA_fnc_localEvent; ["bft_syncedArrayChanged", [1, _data, _x]] call CBA_fnc_localEvent;

View File

@ -16,8 +16,7 @@
params ["_deviceID", "_newData"]; params ["_deviceID", "_newData"];
private ["_data"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData);
_data set [3, _newData]; _data set [3, _newData];
// ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; // ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent;

View File

@ -16,9 +16,8 @@
params ["_deviceID", "_callsign"]; params ["_deviceID", "_callsign"];
private ["_data", "_deviceAssignableInfo"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData); private _deviceAssignableInfo = _data select 2;
_deviceAssignableInfo = _data select 2;
_deviceAssignableInfo set [2, _callsign]; _deviceAssignableInfo set [2, _callsign];
["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent;

View File

@ -16,9 +16,8 @@
params ["_deviceID", "_elementType"]; params ["_deviceID", "_elementType"];
private ["_data", "_assignableInformation"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData); private _assignableInformation = _data select 2;
_assignableInformation = _data select 2;
_assignableInformation set [0, _elementType select 0]; _assignableInformation set [0, _elementType select 0];
_assignableInformation set [1, _elementType select 1]; _assignableInformation set [1, _elementType select 1];

View File

@ -16,9 +16,8 @@
params ["_deviceID", "_groupID"]; params ["_deviceID", "_groupID"];
private ["_data", "_previousGroup"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData); private _previousGroup = _data select 2;
_previousGroup = _data select 2;
_previousGroup set [3, _groupID]; _previousGroup set [3, _groupID];
["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent;

View File

@ -16,9 +16,8 @@
params ["_deviceID", "_keys"]; params ["_deviceID", "_keys"];
private ["_data", "_encryption"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData); private _encryption = _data select 1;
_encryption = _data select 1;
_encryption set [1, _keys]; _encryption set [1, _keys];
["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent; ["bft_deviceDataChanged", [_data, false]] call CBA_fnc_localEvent;

View File

@ -16,13 +16,11 @@
params ["_deviceID", "_newOwner"]; params ["_deviceID", "_newOwner"];
private ["_data", "_newData", "_previousOwner", "_currentDevices"];
systemChat format["handleUpdateDeviceOwner: %1", _this]; systemChat format["handleUpdateDeviceOwner: %1", _this];
diag_log format["handleUpdateDeviceOwner: %1", _this]; diag_log format["handleUpdateDeviceOwner: %1", _this];
_data = [_deviceID] call FUNC(getDeviceData); private _data = [_deviceID] call FUNC(getDeviceData);
_previousOwner = _data select 5; private _previousOwner = _data select 5;
_data set [5, _newOwner]; _data set [5, _newOwner];
["bft_deviceDataChanged", [_data, isNull _previousOwner]] call CBA_fnc_localEvent; ["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]; 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]; 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]; systemChat format["handleUpdateDeviceOwner - validate new owner - %1", (_newData select 5) == _newOwner];
diag_log 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 { if (!isNull _newOwner && {local _newOwner}) then {
_currentDevices = _newOwner getvariable [QGVAR(ownedDevices), []]; private _currentDevices = _newOwner getvariable [QGVAR(ownedDevices), []];
if !(_deviceID in _currentDevices) then { if !(_deviceID in _currentDevices) then {
_currentDevices pushback _deviceID; _currentDevices pushback _deviceID;
_newOwner setvariable [QGVAR(ownedDevices), _currentDevices, true]; _newOwner setvariable [QGVAR(ownedDevices), _currentDevices, true];
@ -47,7 +45,7 @@ if (!isNull _newOwner && {local _newOwner}) then {
}; };
if (!isNull _previousOwner && {local _previousOwner}) then { if (!isNull _previousOwner && {local _previousOwner}) then {
diag_log format["handleUpdateDeviceOwner - removing device (%1) from owner %2 ", _deviceId, _previousOwner]; 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 { if (_deviceID in _currentDevices) then {
_currentDevices = _currentDevices - [_deviceID]; _currentDevices = _currentDevices - [_deviceID];
_previousOwner setvariable [QGVAR(ownedDevices), _currentDevices, true]; _previousOwner setvariable [QGVAR(ownedDevices), _currentDevices, true];

View File

@ -12,10 +12,9 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_data"];
params ["_deviceId"]; params ["_deviceId"];
_data = [_deviceId] call FUNC(getDeviceData); private _data = [_deviceId] call FUNC(getDeviceData);
systemChat format["handleVehicleDeviceKilled: %1 ", _deviceId]; systemChat format["handleVehicleDeviceKilled: %1 ", _deviceId];
diag_log format["handleVehicleDeviceKilled: %1 DATA: %2", _deviceId, _data]; diag_log format["handleVehicleDeviceKilled: %1 DATA: %2", _deviceId, _data];

View File

@ -16,7 +16,6 @@
params ["_unit", "_deviceID"]; params ["_unit", "_deviceID"];
private ["_ownedIDs"]; private _ownedIDs = _unit getvariable [QGVAR(ownedDevices), []];
_ownedIDs = _unit getvariable [QGVAR(ownedDevices), []];
(_deviceID in _ownedIDs) (_deviceID in _ownedIDs)

View File

@ -13,13 +13,13 @@
#include "script_component.hpp" #include "script_component.hpp"
private ["_owner", "_deviceOwner", "_device"];
params ["_deviceData"]; 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 { for "_i" from (count GVAR(availableDevices) - 1) to 0 step -1 do {
_device = GVAR(availableDevices) select _i; private _device = GVAR(availableDevices) select _i;
_deviceOwner = AD_GET_OWNER(_device); private _deviceOwner = AD_GET_OWNER(_device);
if (_owner == _deviceOwner) then { if (_owner == _deviceOwner) then {
GVAR(availableDevices) deleteAt _i; GVAR(availableDevices) deleteAt _i;
_i = _i - 1; _i = _i - 1;

View File

@ -16,8 +16,7 @@
params ["_deviceID", "_deviceData"]; params ["_deviceID", "_deviceData"];
private ["_data"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData);
if (count _data == 0) exitwith {}; if (count _data == 0) exitwith {};
if (_deviceData isEqualTo (_data select 3)) exitwith {}; if (_deviceData isEqualTo (_data select 3)) exitwith {};

View File

@ -16,8 +16,7 @@
params ["_deviceID", "_callsign"]; params ["_deviceID", "_callsign"];
private ["_data"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData);
if (count _data < 3) exitwith {}; if (count _data < 3) exitwith {};
if (count (_data select 2) < 3) exitwith {}; if (count (_data select 2) < 3) exitwith {};

View File

@ -16,8 +16,7 @@
params ["_deviceID", "_elementType"]; params ["_deviceID", "_elementType"];
private ["_data"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData);
if (count _data < 3) exitwith {}; if (count _data < 3) exitwith {};
if (count (_data select 2) < 2) exitwith {}; if (count (_data select 2) < 2) exitwith {};

View File

@ -16,8 +16,7 @@
params ["_deviceID", "_groupID"]; params ["_deviceID", "_groupID"];
private ["_data"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData);
if (count _data < 3) exitwith {}; if (count _data < 3) exitwith {};
if (count (_data select 2) < 4) exitwith {}; if (count (_data select 2) < 4) exitwith {};

View File

@ -16,8 +16,7 @@
params ["_deviceID", "_keys"]; params ["_deviceID", "_keys"];
private ["_data"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData);
if (count _data < 2) exitwith {}; if (count _data < 2) exitwith {};
if (count (_data select 1) < 2) exitwith {}; if (count (_data select 1) < 2) exitwith {};

View File

@ -16,8 +16,7 @@
params ["_deviceID", "_newOwner"]; params ["_deviceID", "_newOwner"];
private ["_data"]; private _data = [_deviceID] call FUNC(getDeviceData);
_data = [_deviceID] call FUNC(getDeviceData);
if (count _data < 6) exitwith {}; if (count _data < 6) exitwith {};
if (_newOwner isEqualTo (_data select 5)) exitwith {}; if (_newOwner isEqualTo (_data select 5)) exitwith {};

View File

@ -15,9 +15,8 @@
params ["_varName"]; params ["_varName"];
private ["_variable", "_nextID"]; private _variable = missionNamespace getvariable [_varName, []];
_variable = missionNamespace getvariable [_varName, []]; private _nextID = 0;
_nextID = 0;
if (count _variable > 0) then { if (count _variable > 0) then {
_nextID = ((_variable select (count _variable - 1)) select 0) + 1; _nextID = ((_variable select (count _variable - 1)) select 0) + 1;

View File

@ -25,8 +25,7 @@ if (isNil "_add") then {
["bft_registeredEncryptionKeysChanged", [_keys,nil]] call CBA_fnc_localEvent; ["bft_registeredEncryptionKeysChanged", [_keys,nil]] call CBA_fnc_localEvent;
}; };
} else { } else {
private ["_changed"]; private _changed = false;
_changed = false;
if (_add) then { if (_add) then {
// figure out the real difference // figure out the real difference

View File

@ -25,8 +25,7 @@ if (isNil "_add") then {
["bft_registeredModeChanged", [_modes,nil]] call CBA_fnc_localEvent; ["bft_registeredModeChanged", [_modes,nil]] call CBA_fnc_localEvent;
}; };
} else { } else {
private ["_changed"]; private _changed = false;
_changed = false;
if (_add) then { if (_add) then {
// figure out the real difference // figure out the real difference
@ -43,6 +42,7 @@ if (isNil "_add") then {
_changed = true; _changed = true;
}; };
}; };
if (_changed) then { if (_changed) then {
["bft_registeredModeChanged", [_modes,_add]] call CBA_fnc_localEvent; ["bft_registeredModeChanged", [_modes,_add]] call CBA_fnc_localEvent;
}; };

View File

@ -15,19 +15,17 @@
params ["_unit"]; params ["_unit"];
private ["_magazine", "_data", "_magID", "_unMatchedDevices", "_ownedDevices", "_matchedIDs"];
if !(local _unit) exitwith {}; if !(local _unit) exitwith {};
{ {
[_unit, _x] call FUNC(checkItem); [_unit, _x] call FUNC(checkItem);
} forEach items _unit; } forEach items _unit;
_ownedDevices = _unit getvariable [QGVAR(ownedDevices), []]; private _ownedDevices = _unit getvariable [QGVAR(ownedDevices), []];
_matchedIDs = []; private _matchedIDs = [];
{ {
_magID = [_x] call FUNC(getMagazineID); private _magID = [_x] call FUNC(getMagazineID);
_data = [_magID] call FUNC(getDeviceData); private _data = [_magID] call FUNC(getDeviceData);
if (count _data > 0) then { if (count _data > 0) then {
if !(_magID in _ownedDevices) then { if !(_magID in _ownedDevices) then {
systemChat format["validate - new picked up ID: %1 %2", _unit, _magID]; systemChat format["validate - new picked up ID: %1 %2", _unit, _magID];
@ -37,7 +35,7 @@ _matchedIDs = [];
_matchedIDs pushback _magID; _matchedIDs pushback _magID;
} else { } else {
if (!(_magId in GVAR(pendingIdAssignmentList))) then { 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 { if (getText (configFile >> "CfgMagazines" >> _magazine >> QGVAR(type)) != "") then {
["bft_itemCreated", [_unit, getText (configFile >> "CfgMagazines" >> _magazine >> QGVAR(type)), _magazine, _magID]] call CBA_fnc_serverEvent; ["bft_itemCreated", [_unit, getText (configFile >> "CfgMagazines" >> _magazine >> QGVAR(type)), _magazine, _magID]] call CBA_fnc_serverEvent;
}; };
@ -45,7 +43,7 @@ _matchedIDs = [];
}; };
}foreach (magazinesDetail _unit); }foreach (magazinesDetail _unit);
_unMatchedDevices = _ownedDevices - _matchedIDs; private _unMatchedDevices = _ownedDevices - _matchedIDs;
{ {
systemChat format["validate - no longer has ID: %1 %2", _unit, _x]; systemChat format["validate - no longer has ID: %1 %2", _unit, _x];
diag_log format["validate - no longer has ID: %1 %2", _unit, _x]; diag_log format["validate - no longer has ID: %1 %2", _unit, _x];

View File

@ -20,8 +20,7 @@ diag_log format["VehicleInit: %1",_this];
if !(isServer) exitwith {}; if !(isServer) exitwith {};
private ["_device"]; private _device = _vehicle getvariable [QGVAR(vehicleDevice), getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(vehicleDevice))];
_device = _vehicle getvariable [QGVAR(vehicleDevice), getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> QGVAR(vehicleDevice))];
systemChat format["VehicleInit devices: %1",_device]; systemChat format["VehicleInit devices: %1",_device];
diag_log format["VehicleInit devices: %1",_device]; diag_log format["VehicleInit devices: %1",_device];

View File

@ -77,7 +77,7 @@ if (!alive _uav) exitWith {false};
}; };
_cam camSetFov 0.5; // set default zoom _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; } count _uavCams;

View File

@ -20,10 +20,10 @@
params ["_interfaceID"]; params ["_interfaceID"];
private _brightness = [_interfaceID,"brightness"] call FUNC(getSettings); private _brightness = [_interfaceID, "brightness"] call FUNC(getSettings);
_brightness = _brightness - 0.1; _brightness = _brightness - 0.1;
// make sure brightness is not larger than 0.5 // make sure brightness is not larger than 0.5
if (_brightness < 0.5) then {_brightness = 0.5}; if (_brightness < 0.5) then {_brightness = 0.5};
[_interfaceID,[["brightness",_brightness]]] call FUNC(setSettings); [_interfaceID, [["brightness",_brightness]]] call FUNC(setSettings);
true true

View File

@ -39,8 +39,7 @@ private _backgroundPosition = ctrlPosition _backgroundCtrl;
// get the original position of the background control // get the original position of the background control
private _backgroundConfigPosition = []; private _backgroundConfigPosition = [];
{ {
if (isClass _x) then { if (isClass _x && {isClass (_x >> _backgroundClassName)}) exitWith {
if (isClass (_x >> _backgroundClassName)) exitWith {
_backgroundConfigPosition = [ _backgroundConfigPosition = [
getNumber (_x >> _backgroundClassName >> "x"), getNumber (_x >> _backgroundClassName >> "x"),
getNumber (_x >> _backgroundClassName >> "y"), getNumber (_x >> _backgroundClassName >> "y"),
@ -48,7 +47,6 @@ private _backgroundConfigPosition = [];
getNumber (_x >> _backgroundClassName >> "h") getNumber (_x >> _backgroundClassName >> "h")
]; ];
}; };
};
} forEach _displayConfigContainers; } forEach _displayConfigContainers;
[_backgroundPosition,_backgroundConfigPosition] [_backgroundPosition,_backgroundConfigPosition]

View File

@ -74,7 +74,7 @@ GVAR(ifOpen) = [
]; ];
// Only register the GetOut event handler for vehicle displays // 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, GVAR(ifOpen) set [9,
_vehicle addEventHandler ["GetOut",{if (_this select 2 == ACE_player) then {[] call FUNC(ifClose)}}] _vehicle addEventHandler ["GetOut",{if (_this select 2 == ACE_player) then {[] call FUNC(ifClose)}}]
]; ];

View File

@ -70,12 +70,12 @@ if (_playerDeviceData isEqualTo [] && _vehicleDeviceData isEqualTo []) exitWith
// get interface for device // get interface for device
private _playerDeviceInterface = if !(_playerDeviceData isEqualTo []) then { 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 // select the first device -- for now
if (count _interfaces > 0) then {_interfaces select 0} else {""}; if (count _interfaces > 0) then {_interfaces select 0} else {""};
} else {""}; } else {""};
private _vehicleDeviceInterface = if !(_vehicleDeviceData isEqualTo []) then { 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 // select the first device -- for now
if (count _interfaces > 0) then {_interfaces select 0} else {""}; if (count _interfaces > 0) then {_interfaces select 0} else {""};
} else {""}; } else {""};

View File

@ -43,6 +43,6 @@ if (_return) then {
if (_interfaces isEqualTo []) exitwith {}; if (_interfaces isEqualTo []) exitwith {};
_interfaces params [ ["_interface", nil] ]; _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); [_deviceID, _interface, 0 /* main interface type */,_interfaceDisplayName, true /*Is Dialog*/, _player, _target] call FUNC(ifOpen);
}; };

View File

@ -36,9 +36,7 @@ _displayConfigContainers = "true" configClasses _displayConfigContainers;
if (isClass _x) then { if (isClass _x) then {
private _displayConfigClasses = "true" configClasses _x; private _displayConfigClasses = "true" configClasses _x;
{ {
if (isClass _x) then { if (isClass _x && {isNumber (_x >> "idc")}) then {
// only move controls that have an IDC
if (isNumber (_x >> "idc")) then {
// only move controls that have a positive IDC // only move controls that have a positive IDC
private _idc = getNumber (_x >> "idc"); private _idc = getNumber (_x >> "idc");
if (_idc > 0) then { if (_idc > 0) then {
@ -49,7 +47,6 @@ _displayConfigContainers = "true" configClasses _displayConfigContainers;
_ctrl ctrlSetPosition _ctrlPosition; _ctrl ctrlSetPosition _ctrlPosition;
_ctrl ctrlCommit 0; _ctrl ctrlCommit 0;
} else {diag_log str ["invalid IDC",_x]}; } else {diag_log str ["invalid IDC",_x]};
} else {diag_log str ["missing IDC",_x]};
}; };
} forEach _displayConfigClasses; } forEach _displayConfigClasses;
}; };

View File

@ -28,8 +28,8 @@ private _deviceEncryptionKey = D_GET_ENCRYPTION(_deviceData);
// compile a list of valid sides // compile a list of valid sides
private _validSides = []; private _validSides = [];
{ {
if ([_deviceEncryptionKey,[_x] call EFUNC(bft,getEncryptionKey)] call EFUNC(bft,encryptionKeyMatch)) then { if ([_deviceEncryptionKey, [_x] call EFUNC(bft,getEncryptionKey)] call EFUNC(bft,encryptionKeyMatch)) then {
0 = _validSides pushBack _x; _validSides pushBack _x;
}; };
} count ["WEST","EAST","GUER","CIV"]; } count ["WEST","EAST","GUER","CIV"];
@ -37,8 +37,8 @@ private _validSides = [];
private _hcamList = []; private _hcamList = [];
{ {
if (str side _x in _validSides) then { if (str side _x in _validSides) then {
if ("ACE_HelmetCam" in items _x) then { if ("ACE_HelmetCam" in (items _x)) then {
0 = _hcamList pushBack _x; _hcamList pushBack _x;
}; };
}; };
} count allUnits; } count allUnits;

View File

@ -37,7 +37,7 @@ GVAR(UAVlist) = [];
// check if UAV has matching encryption key // check if UAV has matching encryption key
private _uavEncryption = D_GET_ENCRYPTION(_uavDeviceData); private _uavEncryption = D_GET_ENCRYPTION(_uavDeviceData);
if ([_deviceEncryption,_uavEncryption] call EFUNC(BFT,encryptionKeyMatch)) then { if ([_deviceEncryption,_uavEncryption] call EFUNC(BFT,encryptionKeyMatch)) then {
0 = GVAR(UAVlist) pushBack [_uavDevice,_uavDeviceData]; GVAR(UAVlist) pushBack [_uavDevice,_uavDeviceData];
}; };
}; };
} count allUnitsUAV; } count allUnitsUAV;