diff --git a/addons/accessory/fnc_switchAttachment.sqf b/addons/accessory/fnc_switchAttachment.sqf index 45f87bb80..c494ec71f 100644 --- a/addons/accessory/fnc_switchAttachment.sqf +++ b/addons/accessory/fnc_switchAttachment.sqf @@ -24,11 +24,11 @@ Author: params ["_itemType", "_switchTo"]; -private ["_currWeaponType", "_currItem", "_switchItem"]; +private ["_currItem", "_switchItem"]; private _unit = call CBA_fnc_currentUnit; private _cw = currentWeapon _unit; -_currWeaponType = call { +private _currWeaponType = call { if (_cw == "") exitWith {_currItem = ""; -1}; if (_cw == primaryWeapon _unit) exitWith {_currItem = (primaryWeaponItems _unit) select _itemType; 0}; if (_cw == handgunWeapon _unit) exitWith {_currItem = (handgunItems _unit) select _itemType; 1}; diff --git a/addons/ai/fnc_addWaypoint.sqf b/addons/ai/fnc_addWaypoint.sqf index 165edbd92..96467a0e9 100644 --- a/addons/ai/fnc_addWaypoint.sqf +++ b/addons/ai/fnc_addWaypoint.sqf @@ -48,8 +48,7 @@ params [ _group = _group call CBA_fnc_getGroup; _position = _position call CBA_fnc_getPos; -private ["_waypoint"]; -_waypoint = _group addWaypoint [_position, _radius]; +private _waypoint = _group addWaypoint [_position, _radius]; _waypoint setWaypointType _type; _waypoint setWaypointBehaviour _behaviour; diff --git a/addons/arrays/fnc_getArrayDiff.sqf b/addons/arrays/fnc_getArrayDiff.sqf index b9f50a3e4..7ab18bebf 100644 --- a/addons/arrays/fnc_getArrayDiff.sqf +++ b/addons/arrays/fnc_getArrayDiff.sqf @@ -26,24 +26,22 @@ Author: params ["_arrayA", "_arrayB"]; -private ["_elmsA", "_elmsB", "_return", "_item", "_idx", "_cA", "_cB", "_case", "_cT"]; - // Simplify the arrays to save on processing power -_elmsA = _arrayA call CBA_fnc_getArrayElements; -_elmsB = _arrayB call CBA_fnc_getArrayElements; -_return = [[], []]; +private _elmsA = _arrayA call CBA_fnc_getArrayElements; +private _elmsB = _arrayB call CBA_fnc_getArrayElements; +private _return = [[], []]; for "_i" from 1 to (count _elmsA) step 2 do { // Pick the first item - _item = _elmsA select 0; - _idx = _elmsB find _item; // O(n^2), TODO: Find a way to differentiate counts - _cA = _elmsA select 1; + private _item = _elmsA select 0; + private _idx = _elmsB find _item; // O(n^2), TODO: Find a way to differentiate counts + private _cA = _elmsA select 1; if (_idx > -1) then { // Differential code - _cB = _elmsB select (_idx + 1); + private _cB = _elmsB select (_idx + 1); - _case = -1; - _cT = _cA - _cB; + private _case = -1; + private _cT = _cA - _cB; if (_cT < 0) then { _case = 1; //Missing from B _cT = abs _cT; @@ -73,8 +71,8 @@ for "_i" from 1 to (count _elmsA) step 2 do { }; // Now add all those missing from A for "_i" from 0 to (count _elmsB - 1) step 2 do { - _item = _elmsB select _i; - _cB = _elmsB select (_i + 1); + private _item = _elmsB select _i; + private _cB = _elmsB select (_i + 1); for "_j" from 0 to (_cB - 1) do { (_return select 1) pushBack _item; // Fills array }; diff --git a/addons/arrays/fnc_getArrayElements.sqf b/addons/arrays/fnc_getArrayElements.sqf index 8fc8ecb44..eb520bc57 100644 --- a/addons/arrays/fnc_getArrayElements.sqf +++ b/addons/arrays/fnc_getArrayElements.sqf @@ -20,16 +20,14 @@ Author: ---------------------------------------------------------------------------- */ -private ["_array", "_return", "_countA", "_var", "_countB"]; - -_array =+ _this; -_return = []; -_countA = count _array; +private _array = +_this; +private _return = []; +private _countA = count _array; while {_countA > 0} do { - _var = _array select 0; + private _var = _array select 0; _array = _array - [_var]; - _countB = count _array; + private _countB = count _array; _return = _return + [_var, _countA - _countB]; _countA = _countB; }; diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 87ec98a2a..ac24d3ce8 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -22,16 +22,16 @@ LOG(MSG_INIT); // Upgrade check - Registry for removed addons, warn the user if found // TODO: Evaluate registry of 'current addons' and verifying that against available CfgPatches TRACE_1("Upgrade Check",nil); -#define CFG configFile >> "CfgSettings" >> "CBA" >> "registry" -private ["_entry"]; -for "_i" from 0 to ((count (CFG)) - 1) do { - _entry = (CFG) select _i; - if (isClass(_entry) && {isArray(_entry >> "removed")}) then { +private _config = configFile >> "CfgSettings" >> "CBA" >> "registry"; + +for "_i" from 0 to (count _config - 1) do { + private _entry = _config select _i; + if (isClass _entry && {isArray (_entry >> "removed")}) then { { - if (isClass(configFile >> "CfgPatches" >> _x)) then { - format["WARNING: Found addon that should be removed: %1; Please remove and restart game", _x] call FUNC(log); + if (isClass (configFile >> "CfgPatches" >> _x)) then { + format ["WARNING: Found addon that should be removed: %1; Please remove and restart game", _x] call FUNC(log); }; - } forEach (getArray(_entry >> "removed")); + } forEach getArray (_entry >> "removed"); }; }; diff --git a/addons/common/fnc_createMarker.sqf b/addons/common/fnc_createMarker.sqf index e8e62f577..fd3e624b6 100644 --- a/addons/common/fnc_createMarker.sqf +++ b/addons/common/fnc_createMarker.sqf @@ -40,14 +40,13 @@ Author: #include "script_component.hpp" SCRIPT(createMarker); -private ["_m", "_br", "_ty", "_co", "_tx", "_persist", "_global"]; - -_br = ["BRUSH:", "brush:", "", _this] call CBA_fnc_getArg; -_ty = ["TYPE:", "type:", "", _this] call CBA_fnc_getArg; -_co = ["COLOR:", "color:", "", _this] call CBA_fnc_getArg; -_tx = ["TEXT:", "text:", "", _this] call CBA_fnc_getArg; -_persist = "PERSIST" in _this; -_global = "GLOBAL" in _this || _persist; +private _m = ""; +private _br = ["BRUSH:", "brush:", "", _this] call CBA_fnc_getArg; +private _ty = ["TYPE:", "type:", "", _this] call CBA_fnc_getArg; +private _co = ["COLOR:", "color:", "", _this] call CBA_fnc_getArg; +private _tx = ["TEXT:", "text:", "", _this] call CBA_fnc_getArg; +private _persist = "PERSIST" in _this; +private _global = "GLOBAL" in _this || _persist; TRACE_6("",_br,_ty,_co,_tx,_persist,_global); @@ -69,4 +68,4 @@ if (_global) then { if (_tx!= "") then { _m setMarkerTextLocal _tx }; }; -_m; +_m diff --git a/addons/common/fnc_getAnimType.sqf b/addons/common/fnc_getAnimType.sqf index 573ded117..84c685924 100644 --- a/addons/common/fnc_getAnimType.sqf +++ b/addons/common/fnc_getAnimType.sqf @@ -23,12 +23,10 @@ Author: #include "script_component.hpp" SCRIPT(getAnimType); -private ["_anim", "_weapon", "_pos"]; - params ["_man","_array"]; -_anim = ""; -_weapon = format["%1", currentWeapon _man]; -_pos = ""; +private _anim = ""; +private _weapon = format["%1", currentWeapon _man]; +private _pos = ""; if (_weapon != "") then { _class = configFile >> "CfgWeapons" >> _weapon; diff --git a/addons/common/fnc_getArg.sqf b/addons/common/fnc_getArg.sqf index b01238f7b..ed2f4d018 100644 --- a/addons/common/fnc_getArg.sqf +++ b/addons/common/fnc_getArg.sqf @@ -20,16 +20,12 @@ Author: #include "script_component.hpp" SCRIPT(getArg); -private["_cLC", "_cUC", "_arg", "_list", "_a", "_v"]; -_cLC = _this select 0; -_cUC = _this select 1; -_arg = _this select 2; -_list = _this select 3; +params ["_cLC", "_cUC", "_arg", "_list"] -_a = -1; +private _a = -1; { _a = _a + 1; - _v = format["%1", _list select _a]; + private _v = format["%1", _list select _a]; if (_v == _cLC || {_v == _cUC}) then { _arg = (_list select _a+1); }; diff --git a/addons/common/fnc_getAspectRatio.sqf b/addons/common/fnc_getAspectRatio.sqf index 49f3aac4b..88848fd24 100644 --- a/addons/common/fnc_getAspectRatio.sqf +++ b/addons/common/fnc_getAspectRatio.sqf @@ -24,16 +24,12 @@ Author: #include "script_component.hpp" SCRIPT(getAspectRatio); +private _output = toUpper _this; +private _aspectStr = ""; +private _aspectArr = []; +private _return = 0; +private _ratio = (round ((safeZoneW / safeZoneH) * 1000)) / 1000; - private ["_output","_aspectStr","_aspectArr","_ratio","_return"]; - -_output = toUpper _this; - -_aspectStr = ""; -_aspectArr = []; -_return = 0; - -_ratio = (round ((safeZoneW / safeZoneH) * 1000)) / 1000; switch (_ratio) do { case 1: { _aspectStr = "4:3"; @@ -72,4 +68,4 @@ if (_output == "ARRAY") then {_return = _aspectArr;}; if (_output == "STRING") then {_return = _aspectStr;}; if (_output == "NUMBER") then {_return = _ratio;}; -_return;; \ No newline at end of file +_return; \ No newline at end of file diff --git a/addons/common/fnc_getConfigEntry.sqf b/addons/common/fnc_getConfigEntry.sqf index a2e97ebf0..8d8b6c1e7 100644 --- a/addons/common/fnc_getConfigEntry.sqf +++ b/addons/common/fnc_getConfigEntry.sqf @@ -27,25 +27,26 @@ Author: #include "script_component.hpp" SCRIPT(getConfigEntry); -private ["_r"]; -switch (toLower(_this select 1)) do { +params ["_configEntry", "_entryType", "_defaultValue"]; + +private _r = _defaultValue; + +switch (toLower _entryType) do { case "text": { - if (isText (_this select 0)) then { - _r = getText (_this select 0); + if (isText _configEntry) then { + _r = getText _configEntry; }; }; case "array": { - if (isArray (_this select 0)) then { - _r = getArray (_this select 0); + if (isArray _configEntry) then { + _r = getArray _configEntry; }; }; case "number": { - if (isNumber (_this select 0)) then { - _r = getNumber (_this select 0); + if (isNumber _configEntry) then { + _r = getNumber _configEntry; }; }; }; -if (isNil "_r") then { _r = _this select 2 }; - _r diff --git a/addons/common/fnc_getFov.sqf b/addons/common/fnc_getFov.sqf index 2b5e7bb4d..80d3403cc 100644 --- a/addons/common/fnc_getFov.sqf +++ b/addons/common/fnc_getFov.sqf @@ -29,23 +29,21 @@ Authors: #define __dist 10000 #define __xOff 5000 -private ["_zoomRef", "_widthReal", "_safeZoneAspectRatio", "_screenAspectRatio", "_pos", "_xPos", "_deltaX", "_trigRatio", "_fovH", "_fovV", "_fovVRads", "_configFov", "_zoom"]; - -_zoomRef = if (IS_SCALAR(_this)) then {_this} else {0.75}; - -_widthReal = safeZoneW / 2; -_safeZoneAspectRatio = (safeZoneW / safeZoneH); -_screenAspectRatio = _safeZoneAspectRatio * (4 / 3); - -_pos = positionCameraToWorld [__xOff, 0, __dist]; -_xPos = (worldToScreen _pos) select 0; -_deltaX = _xPos - 0.5; - -_trigRatio = ((_widthReal * __xOff) / (__dist * _deltaX)); -_fovH = 2 * atan _trigRatio; -_fovV = _fovH / _screenAspectRatio; -_fovVRads = _fovV * pi / 180; -_configFov = _trigRatio / _safeZoneAspectRatio; -_zoom = _zoomRef / _configFov; +private _zoomRef = if (IS_SCALAR(_this)) then {_this} else {0.75}; + +private _widthReal = safeZoneW / 2; +private _safeZoneAspectRatio = (safeZoneW / safeZoneH); +private _screenAspectRatio = _safeZoneAspectRatio * (4 / 3); + +private _pos = positionCameraToWorld [__xOff, 0, __dist]; +private _xPos = (worldToScreen _pos) select 0; +private _deltaX = _xPos - 0.5; + +private _trigRatio = ((_widthReal * __xOff) / (__dist * _deltaX)); +private _fovH = 2 * atan _trigRatio; +private _fovV = _fovH / _screenAspectRatio; +private _fovVRads = _fovV * pi / 180; +private _configFov = _trigRatio / _safeZoneAspectRatio; +private _zoom = _zoomRef / _configFov; [_fovVRads, _zoom] diff --git a/addons/common/fnc_getTerrainProfile.sqf b/addons/common/fnc_getTerrainProfile.sqf index 42ee8c6fc..a7badb6ae 100644 --- a/addons/common/fnc_getTerrainProfile.sqf +++ b/addons/common/fnc_getTerrainProfile.sqf @@ -27,26 +27,26 @@ _posA = _posA call CBA_fnc_getPos; _posB = _posB call CBA_fnc_getPos; _posA set [2,0]; _posB set [2,0]; -DEFAULT_PARAM(2,_resolution,10); +DEFAULT_PARAM(2, _resolution,10); -private ["_angle", "_2Ddistance", "_return", "_z", "_adj", "_pos", "_alt"]; -_angle = [_posA, _posB] call BIS_fnc_dirTo; -_2Ddistance = [_posA, _posB] call BIS_fnc_distance2D; +private _angle = [_posA, _posB] call BIS_fnc_dirTo; +private _2Ddistance = [_posA, _posB] call BIS_fnc_distance2D; -_logic = "logic" createvehiclelocal _posA; +private _logic = "logic" createvehiclelocal _posA; _logic setPosATL _posA; -_z = (getPosASL _logic) select 2; -_return = []; +private _z = (getPosASL _logic) select 2; +private _return = []; +private _pos = []; for "_i" from 0 to (_2Ddistance / _resolution) do { _adj = _resolution * _i; _pos = [_posA, _adj, _angle] call BIS_fnc_relPos; _logic setPosATL _pos; - _alt = ((getPosASL _logic) select 2) - _z; + private _alt = ((getPosASL _logic) select 2) - _z; _return set [_i,[_alt, _adj, _pos]]; }; _logic setPosATL _posB; -_alt = ((getPosASL _logic) select 2) - _z; +private _alt = ((getPosASL _logic) select 2) - _z; _return pushBack [_alt, _2Ddistance, _pos]; deletevehicle _logic; diff --git a/addons/common/fnc_getUISize.sqf b/addons/common/fnc_getUISize.sqf index 5ad6cda99..bb56a9fc0 100644 --- a/addons/common/fnc_getUISize.sqf +++ b/addons/common/fnc_getUISize.sqf @@ -28,72 +28,28 @@ Author: #include "script_component.hpp" SCRIPT(getUISize); +#define C_4to3 [1.818, 1.429, 1.176, 1] +#define C_16to9 [2.424, 1.905, 1.569, 1.333] +#define C_16to10 [2.182, 1.714, 1.412, 1.2] +#define C_12to3 [1.821, 1.430, 1.178, 1.001] +#define ERROR {[-1, "error"] select (_output == "STRING")} - private ["_output", "_ratio", "_4to3", "_16to9", "_16to10", "_12to3", "_error", "_sizes", "_index", "_return"]; - -_output = toUpper (_this); -_ratio = "STRING" call CBA_fnc_getAspectRatio; - -_4to3 = [1.818, 1.429, 1.176, 1]; -_16to9 = [2.424, 1.905, 1.569, 1.333]; -_16to10 = [2.182, 1.714, 1.412, 1.2]; -_12to3 = [1.821, 1.430, 1.178, 1.001]; -_error = false; - -switch (_ratio) do { - case "4:3": { - _sizes = _4to3; - }; - case "5:4": { - _sizes = _4to3; - }; - case "16:9": { - _sizes = _16to9; - }; - case "16:10": { - _sizes = _16to10; - }; - case "12:3": { - _sizes = _12to3; - }; - default { - _error = true; - }; -}; - -if (!_error) then { - _index = _sizes find ((round (safeZoneW * 1000)) / 1000); - //hint str _index; - if (_index == -1) exitWith { - _error = true; - }; -}; - -if (_error) then { - _return = if (_output == "STRING") then { - "error" - } else { - -1 - }; +params ["_output"]; + +private _ratio = "STRING" call CBA_fnc_getAspectRatio; +if (_ratio isEqualTo "") exitWith ERROR; + +private _aspIndex = ["4:3", "5:4", "16:9", "16:10", "12:3"] find _ratio; +if (_aspIndex == -1) exitWith ERROR; + +private _sizes = [C_4to3, C_4to3, C_16to9, C_16to10, C_12to3] select _aspIndex; + +private _index = _sizes find ((round (safeZoneW * 1000)) / 1000); + +if (_index == -1) exitWith ERROR; + +if (_output == "STRING") then { + ["verysmall", "small", "normal", "large"] select _index; } else { - if (_output == "STRING") then { - switch (_index) do { - case 0: { - _return = "verysmall"; - }; - case 1: { - _return = "small"; - }; - case 2: { - _return = "normal"; - }; - case 3: { - _return = "large"; - }; - }; - } else { - _return = _index; - }; -}; - -_return; \ No newline at end of file + _index; +} \ No newline at end of file diff --git a/addons/common/fnc_getUnitAnim.sqf b/addons/common/fnc_getUnitAnim.sqf index aa2568017..83c92fbeb 100644 --- a/addons/common/fnc_getUnitAnim.sqf +++ b/addons/common/fnc_getUnitAnim.sqf @@ -28,20 +28,18 @@ Author: #include "script_component.hpp" SCRIPT(getUnitAnim); -private ["_unit", "_anim", "_upos", "_umov", "_dthstr", "_posstr", "_movstr"]; - -_unit = _this; -_anim = toArray(toLower(animationState _unit)); -_upos = "unknown"; -_umov = "stop"; +private _unit = _this; +private _anim = toArray(toLower(animationState _unit)); +private _upos = "unknown"; +private _umov = "stop"; if (vehicle _unit!= _unit) then { _upos = "vehicle"; } else { if (count _anim < 12) exitWith {}; - _dthstr = toString [_anim select 0, _anim select 1, _anim select 2, _anim select 3]; - _posstr = toString [_anim select 4, _anim select 5, _anim select 6, _anim select 7]; - _movstr = toString [_anim select 8, _anim select 9, _anim select 10, _anim select 11]; + private _dthstr = toString [_anim select 0, _anim select 1, _anim select 2, _anim select 3]; + private _posstr = toString [_anim select 4, _anim select 5, _anim select 6, _anim select 7]; + private _movstr = toString [_anim select 8, _anim select 9, _anim select 10, _anim select 11]; if (_dthstr == "adth" || {_dthstr == "slx_"}) then { _upos = "prone"; } else { diff --git a/addons/common/fnc_getUnitDeathAnim.sqf b/addons/common/fnc_getUnitDeathAnim.sqf index e74b28cc1..9292902dd 100644 --- a/addons/common/fnc_getUnitDeathAnim.sqf +++ b/addons/common/fnc_getUnitDeathAnim.sqf @@ -22,19 +22,19 @@ Author: #include "script_component.hpp" SCRIPT(getUnitDeathAnim); -private ["_unit", "_curAnim", "_deathAnim", "_deathAnimCfg"]; -_unit = _this; -_deathAnim = ""; -_curAnim = (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _unit)); +params ["_unit"]; + +private _deathAnim = ""; +private _curAnim = (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _unit)); if (isText (_curAnim >> "actions")) then { if (vehicle _unit == _unit) then { - _deathAnimCfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_curAnim >> "actions")) >> "die"); + private _deathAnimCfg = (configFile >> "CfgMovesBasic" >> "Actions" >> (getText (_curAnim >> "actions")) >> "die"); if (isText _deathAnimCfg) then { _deathAnim = getText _deathAnimCfg; }; } else { - _deathAnimCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _unit)); + private _deathAnimCfg = (configFile >> "CfgMovesMaleSdr" >> "States" >> (animationState _unit)); if (isArray (_deathAnimCfg >> "interpolateTo")) then { _deathAnim = getArray (_deathAnimCfg >> "interpolateTo") select 0; }; diff --git a/addons/common/fnc_isTurnedOut.sqf b/addons/common/fnc_isTurnedOut.sqf index 4d60b3561..8ef060027 100644 --- a/addons/common/fnc_isTurnedOut.sqf +++ b/addons/common/fnc_isTurnedOut.sqf @@ -31,37 +31,36 @@ Author: #include "script_component.hpp" SCRIPT(isTurnedOut); -private ["_turn","_out","_vehicle","_cfg","_forceHideDriver","_phase","_assignedRole","_turretPath","_turret","_canHideGunner", - "_forceHideGunner","_hatchAnimation","_attenuateCargo","_index"]; -_turn = false; -_out = false; params ["_unit"]; -_vehicle = vehicle _unit; -_cfg = configFile >> "CfgVehicles" >> (typeOf _vehicle); +private _turn = false; +private _out = false; +private _vehicle = vehicle _unit; +private _cfg = configFile >> "CfgVehicles" >> (typeOf _vehicle); + if (_vehicle != _unit) then { if (driver _vehicle == _unit) then { - _forceHideDriver = getNumber(_cfg >> "forceHideDriver"); + private _forceHideDriver = getNumber(_cfg >> "forceHideDriver"); _turn = (_forceHideDriver != 1); _out = (_vehicle animationPhase "hatchDriver") > 0; } else { - _assignedRole = assignedVehicleRole _unit; + private _assignedRole = assignedVehicleRole _unit; if (_assignedRole select 0 == "Turret") then { - _turretPath = _assignedRole select 1; - _turret = [_vehicle, _turretPath] call CBA_fnc_getTurret; + private _turretPath = _assignedRole select 1; + private _turret = [_vehicle, _turretPath] call CBA_fnc_getTurret; - _canHideGunner = getNumber(_turret >> "canHideGunner"); - _forceHideGunner = getNumber(_turret >> "forceHideGunner"); + private _canHideGunner = getNumber(_turret >> "canHideGunner"); + private _forceHideGunner = getNumber(_turret >> "forceHideGunner"); _turn = (_canHideGunner == 1 && _forceHideGunner == 0); - _hatchAnimation = getText(_turret >> "animationSourceHatch"); + private _hatchAnimation = getText(_turret >> "animationSourceHatch"); _out = (_vehicle animationPhase _hatchAnimation) > 0; } else { if ((_assignedRole select 0) == "Cargo") then { - _attenuateCargo = getArray(_cfg >> "soundAttenuationCargo"); + private _attenuateCargo = getArray(_cfg >> "soundAttenuationCargo"); if ((count _attenuateCargo) > 0) then { - _index = (count _attenuateCargo)-1; // wait for command to get cargo index + private _index = (count _attenuateCargo)-1; // wait for command to get cargo index if (_index > -1) then { if(_index > (count _attenuateCargo)-1) then { diff --git a/addons/common/fnc_mapGridToPos.sqf b/addons/common/fnc_mapGridToPos.sqf index 69a739d27..ad0358094 100644 --- a/addons/common/fnc_mapGridToPos.sqf +++ b/addons/common/fnc_mapGridToPos.sqf @@ -29,15 +29,11 @@ Author: SCRIPT(mapGridToPos); -private ["_pos", "_doOffset", "_posArray", "_ea", "_na", "_start", "_check", - "_minus", "_digits", "_maxNorthing", "_height", "_easting", "_northing", - "_eastingSize", "_northingSize", "_eastingMultiple", "_northingMultiple", - "_posX", "_posY", "_offset", "_return", "_reversed"]; +private _height = 0; +private _doOffSet = false; +private _reversed = [] call CBA_fnc_northingReversed; +private _pos = []; - -_doOffSet = false; -_reversed = [] call CBA_fnc_northingReversed; -_pos = []; if (IS_ARRAY(_this)) then { if (count _this > 1) then { if (IS_BOOL(_this select 1)) then { @@ -58,18 +54,16 @@ if (IS_ARRAY(_this)) then { }; if (IS_STRING(_pos)) then { - _posArray = toArray _pos; - _pos = []; - _ea = []; + private _posArray = toArray _pos; + private _ea = []; for "_i" from 0 to (((count _posArray)/2)-1) do { _ea pushBack (_posArray select _i); }; - _na = []; + private _na = []; for "_i" from (((count _posArray)/2)) to (((count _posArray))-1) do { _na pushBack (_posArray select _i); }; - _pos set[0, toString _ea]; - _pos set[1, toString _na]; + _pos = [toString _ea, toString _na]; }; /** @@ -81,16 +75,16 @@ if (IS_STRING(_pos)) then { * map. */ if (_reversed) then { - _start = format["%1", mapGridPosition [0, 0]]; - _check = _start; - _minus = 0; + private _start = format["%1", mapGridPosition [0, 0]]; + private _check = _start; + private _minus = 0; while{_check == _start} do { _check = format["%1", mapGridPosition [0, _minus]]; _minus = _minus - 1; }; - _digits = toArray _start; - _maxNorthing = parseNumber (toString [_digits select 3, _digits select 4, _digits select 5]); + private _digits = toArray _start; + private _maxNorthing = parseNumber (toString [_digits select 3, _digits select 4, _digits select 5]); _height = (_maxNorthing*100) - abs(_minus) + 1; } else { if (isNil QGVAR(rvOriginX) || {isNil QGVAR(rvOriginY)}) then { @@ -123,8 +117,8 @@ if (IS_STRING(_pos)) then { }; }; if (!_ignore) then { - _check = _start; - _minus = 0; + private _check = _start; + private _minus = 0; while {_check == _start} do { _check = format["%1", mapGridPosition [0, _minus]]; _minus = _minus - 1; @@ -146,8 +140,7 @@ if (IS_STRING(_pos)) then { /** * Do the math to get the right internal grid. */ -_easting = _pos select 0; -_northing = _pos select 1; +_pos params ["_easting", "_northing"]; if (IS_NUMBER(_easting)) then { _easting = format["%1", _easting]; @@ -156,22 +149,22 @@ if (IS_NUMBER(_northing)) then { _northing = format["%1", _northing]; }; -_eastingSize = (count (toArray _easting)) min 5; -_northingSize = (count (toArray _northing)) min 5; -_eastingMultiple = (10^((10-(_eastingSize*2))/2)); -_northingMultiple = (10^((10-(_northingSize*2))/2)); -_posY = 0; +private _eastingSize = (count (toArray _easting)) min 5; +private _northingSize = (count (toArray _northing)) min 5; +private _eastingMultiple = (10^((10-(_eastingSize*2))/2)); +private _northingMultiple = (10^((10-(_northingSize*2))/2)); +private _posY = 0; if (_reversed) then { _posY = (_height-((parseNumber _northing)*_northingMultiple))+100; } else { _posY = ((parseNumber _northing)*_northingMultiple); }; -_posX = ((parseNumber _easting)*_eastingMultiple); +private _posX = ((parseNumber _easting)*_eastingMultiple); /** * Do we want the upper left corner of the grid square, or the center? */ -_offset = 0; +private _offset = 0; if (_doOffSet && {(_northingMultiple max _eastingMultiple) > 1}) then { _offset = (_northingMultiple max _eastingMultiple)/2; }; diff --git a/addons/common/fnc_mapRelPos.sqf b/addons/common/fnc_mapRelPos.sqf index c5d29dfff..a442e2dee 100644 --- a/addons/common/fnc_mapRelPos.sqf +++ b/addons/common/fnc_mapRelPos.sqf @@ -29,30 +29,23 @@ Author: SCRIPT(mapRelPos); -private ["_pos","_dist","_dir","_northing","_easting","_northingSize", - "_eastingSize","_e","_n","_posArray","_ea","_na","_reversed"]; +params ["_pos", "_dist", "_dir"]; -_pos = _this select 0; -_dist = _this select 1; -_dir = _this select 2; -_reversed = [] call CBA_fnc_northingReversed; +private _reversed = [] call CBA_fnc_northingReversed; if (IS_STRING(_pos)) then { - _posArray = toArray _pos; - _pos = []; - _ea = []; + private _posArray = toArray _pos; + private _ea = []; for "_i" from 0 to (((count _posArray)/2)-1) do { _ea pushBack (_posArray select _i); }; - _na = []; + private _na = []; for "_i" from (((count _posArray)/2)) to (((count _posArray))-1) do { _na pushBack (_posArray select _i); }; - _pos set[0, (toString _ea)]; - _pos set[1, (toString _na)]; + _pos = [toString _ea, toString _na]; }; -_easting = _pos select 0; -_northing = _pos select 1; +_pos params ["_easting", "_northing"]; if (IS_NUMBER(_easting)) then { _easting = format["%1", _easting]; @@ -61,12 +54,12 @@ if (IS_NUMBER(_northing)) then { _northing = format["%1", _northing]; }; -_eastingSize = (count (toArray _easting)) min 5; -_northingSize = (count (toArray _northing)) min 5; +private _eastingSize = (count (toArray _easting)) min 5; +private _northingSize = (count (toArray _northing)) min 5; // Convert the numbers into 5 digits out of a 10 digit ref -_e = (parseNumber _easting)*(10^((10-(_eastingSize*2))/2)); -_n = (parseNumber _northing)*(10^((10-(_northingSize*2))/2)); +private _e = (parseNumber _easting)*(10^((10-(_eastingSize*2))/2)); +private _n = (parseNumber _northing)*(10^((10-(_northingSize*2))/2)); _pos = [_e, _n]; diff --git a/addons/common/fnc_modelHeadDir.sqf b/addons/common/fnc_modelHeadDir.sqf index 0f3002a84..90942e8a3 100644 --- a/addons/common/fnc_modelHeadDir.sqf +++ b/addons/common/fnc_modelHeadDir.sqf @@ -42,22 +42,19 @@ Author: #include "script_component.hpp" SCRIPT(modelHeadDir); -private["_pilotPos", "_neckPos", "_polar", "_pitch", "_abs", "_dif", "_world", "_return"]; params ["_unit"]; -_return = []; +private _return = []; if (_unit isKindOf "CAManBase" ) then { - _pilotPos = (_unit selectionPosition "pilot"); - _neckPos = (_unit selectionPosition "neck"); - _polar = ([_neckPos, _pilotPos] call BIS_fnc_vectorFromXToY) call CBA_fnc_vect2polar; - _pitch = (_polar select 2) - 23; // Subtract to compensate for mem point height dif - _abs = _polar select 1; - _dif = 0; - - _dif = if (_abs > 180) then {_abs - 360} else {_abs}; - _world = (getDir _unit) + _dif mod 360; + private _pilotPos = (_unit selectionPosition "pilot"); + private _neckPos = (_unit selectionPosition "neck"); + private _polar = ([_neckPos, _pilotPos] call BIS_fnc_vectorFromXToY) call CBA_fnc_vect2polar; + private _pitch = (_polar select 2) - 23; // Subtract to compensate for mem point height dif + private _abs = _polar select 1; + private _dif = if (_abs > 180) then {_abs - 360} else {_abs}; + private _world = (getDir _unit) + _dif mod 360; _return = [_world, _dif, _pitch]; }; diff --git a/addons/common/fnc_northingReversed.sqf b/addons/common/fnc_northingReversed.sqf index c688a2ba1..fd6842aae 100644 --- a/addons/common/fnc_northingReversed.sqf +++ b/addons/common/fnc_northingReversed.sqf @@ -21,14 +21,13 @@ Author: ---------------------------------------------------------------------------- */ #include "script_component.hpp" -private ["_test", "_reversed", "_start", "_check", "_plus"]; -_reversed = false; +private _reversed = false; if (isNil QGVAR(mapReversed)) then { - _test = getNumber (configFile >> "CfgWorlds" >> worldName >> "Grid" >> "Zoom1" >> "stepY"); + private _test = getNumber (configFile >> "CfgWorlds" >> worldName >> "Grid" >> "Zoom1" >> "stepY"); if (_test > 0) then { - _check = parseNumber(format["%1", mapGridPosition [0, 0]]); - _start = _check; - _plus = 0; + private _check = parseNumber(format["%1", mapGridPosition [0, 0]]); + private _start = _check; + private _plus = 0; diag_log text "---------------------"; while {_check == _start} do { _check = parseNumber(format["%1", mapGridPosition [0, _plus]]); diff --git a/addons/common/fnc_objectRandom.sqf b/addons/common/fnc_objectRandom.sqf index 8ad2b0d0f..156e2a002 100644 --- a/addons/common/fnc_objectRandom.sqf +++ b/addons/common/fnc_objectRandom.sqf @@ -23,17 +23,15 @@ SCRIPT(objectRandom); params ["_o"]; -private ["_r", "_v", "_s", "_a", "_b", "_c"]; - -_r = 0; +private _r = 0; if !(isNull _o) then { - _v = velocity (vehicle _o); - _s = sqrt ((_v select 0) ^ 2 + (_v select 1) ^ 2 + (_v select 2) ^ 2); + private _v = velocity (vehicle _o); + private _s = sqrt ((_v select 0) ^ 2 + (_v select 1) ^ 2 + (_v select 2) ^ 2); if (_s > 0) then { - _a = acos ((_v select 0) / _s); - _b = acos ((_v select 1) / _s); - _c = acos ((_v select 2) / _s); + private _a = acos ((_v select 0) / _s); + private _b = acos ((_v select 1) / _s); + private _c = acos ((_v select 2) / _s); _r = (_a + _b + _c) % 10; _r = _r - (_r % 1); diff --git a/addons/common/fnc_switchPlayer.sqf b/addons/common/fnc_switchPlayer.sqf index 541a84066..a4d856407 100644 --- a/addons/common/fnc_switchPlayer.sqf +++ b/addons/common/fnc_switchPlayer.sqf @@ -33,13 +33,12 @@ Author: #include "script_component.hpp" SCRIPT(switchPlayer); -private ["_ar", "_oldUnit", "_newUnit", "_dummyUnit", "_dummyGroup"]; params ["_type"]; -_oldUnit = player; +private _oldUnit = player; -_ar = [weapons _oldUnit, magazines _oldUnit, rank _oldUnit, score _oldUnit, group _oldUnit, getPos _oldUnit, (leader _oldUnit) == _oldUnit, vehicleVarName _oldUnit]; +private _ar = [weapons _oldUnit, magazines _oldUnit, rank _oldUnit, score _oldUnit, group _oldUnit, getPos _oldUnit, (leader _oldUnit) == _oldUnit, vehicleVarName _oldUnit]; -_dummyGroup = createGroup (side _oldUnit); +private _dummyGroup = createGroup (side _oldUnit); if (isNull _dummyGroup) exitWith { hint "Sorry, something went wrong, dummyGroup is null" }; _dummyUnit = (_ar select 4) createUnit [_type, [0, 0, 0], [], 0, "NONE"]; // Join in the old group incase there was only 1 member if (isNull _dummyUnit) exitWith { hint "Sorry, something went wrong, dummyUnit is null" }; @@ -47,7 +46,7 @@ if (isNull _dummyUnit) exitWith { hint "Sorry, something went wrong, dummyUnit i LOG(format["1.Dummy created, State saved and put oldUnit in new group: %1", _dummyGroup]); -_newUnit = _dummyGroup createUnit [_type, _ar select 5, [], 0, "NONE"]; +private _newUnit = _dummyGroup createUnit [_type, _ar select 5, [], 0, "NONE"]; if (isNull _newUnit) exitWith { hint "Sorry, something went wrong, newUnit is null" }; diff --git a/addons/common/init_delayLess.sqf b/addons/common/init_delayLess.sqf index b7fa5a3ac..a39605a9c 100644 --- a/addons/common/init_delayLess.sqf +++ b/addons/common/init_delayLess.sqf @@ -5,11 +5,10 @@ GVAR(d) = []; [QFUNC(addTriggerHandler), { - private ["_c"]; // #include "script_component.hpp" // #define DEBUG_MODE_FULL // [[_param1, _param2], { _param1 = _this select 0; _param2 = _this select 1; /* do stuff */}] call cba_fnc_addTriggerHandler; - _c = GVAR(d) pushBack _this; + private _c = GVAR(d) pushBack _this; // Create the trigger, only on first use if (isNil QGVAR(d_trigger)) then { diff --git a/addons/diagnostic/XEH_preInit.sqf b/addons/diagnostic/XEH_preInit.sqf index 8fd95c477..d077cb9b7 100644 --- a/addons/diagnostic/XEH_preInit.sqf +++ b/addons/diagnostic/XEH_preInit.sqf @@ -27,7 +27,7 @@ if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFil private _timeStart = diag_tickTime; private _returnString = _statementText call { - private ["_clientID", "_statementText", "_varName", "_timeStart", "_x"]; + private ["_clientID", "_statementText", "_varName", "_timeStart", "_x"]; // prevent these variables from being overwritten _this = ([nil] apply compile _this) select 0; if (isNil "_this") exitWith {"#NIL"}; str _this diff --git a/addons/help/XEH_preClientInit.sqf b/addons/help/XEH_preClientInit.sqf index 30d1d2ec6..d6396050f 100644 --- a/addons/help/XEH_preClientInit.sqf +++ b/addons/help/XEH_preClientInit.sqf @@ -83,21 +83,18 @@ private _config = configFile >> "CfgSettings" >> "CBA" >> "events"; _actionName = [_actionName, "_", " "] call CBA_fnc_replace; - private ["_key", "_shift", "_ctrl", "_alt"]; - - if (isNumber _entry) then { - _key = getNumber _entry; - _shift = 0; - _ctrl = 0; - _alt = 0; + private _keyState = if (isNumber _entry) then { + [getNumber _entry, 0, 0, 0 ] } else { - _key = getNumber (_entry >> "key"); - _shift = getNumber (_entry >> "shift"); - _ctrl = getNumber (_entry >> "ctrl"); - _alt = getNumber (_entry >> "alt"); + [ + getNumber (_entry >> "key"), + getNumber (_entry >> "shift"), + getNumber (_entry >> "ctrl"), + getNumber (_entry >> "alt") + ] }; - private _keyName = [_key, _shift, _ctrl, _alt] call _fnc_getKeyName; + private _keyName = _keyState call _fnc_getKeyName; _actionName = format [" %1: %2", _actionName, _keyName]; diff --git a/addons/strings/fnc_formatElapsedTime.sqf b/addons/strings/fnc_formatElapsedTime.sqf index a3c955215..73f1d2ffb 100644 --- a/addons/strings/fnc_formatElapsedTime.sqf +++ b/addons/strings/fnc_formatElapsedTime.sqf @@ -27,12 +27,10 @@ SCRIPT(formatElapsedTime); params ["_seconds", ["_format", "H:MM:SS"]]; -private ["_minutes", "_hours", "_secondsDecimals"]; - // Discover all the digits to use. -_hours = floor (_seconds / 3600); +private _hours = floor (_seconds / 3600); _seconds = _seconds - (_hours * 3600); -_minutes = floor (_seconds / 60); +private _minutes = floor (_seconds / 60); _seconds = _seconds - (_minutes * 60); // Add the milliseconds if required. diff --git a/addons/strings/fnc_split.sqf b/addons/strings/fnc_split.sqf index 47e1bf6a9..6a8302555 100644 --- a/addons/strings/fnc_split.sqf +++ b/addons/strings/fnc_split.sqf @@ -31,12 +31,12 @@ SCRIPT(split); // ---------------------------------------------------------------------------- -private ["_split", "_index", "_inputCount", "_separatorCount", "_find", "_lastWasSeperator"]; params [["_input", ""], ["_separator", ""]]; -_split = []; -_index = 0; -_inputCount = count _input; -_separatorCount = count _separator; + +private _split = []; +private _index = 0; +private _inputCount = count _input; +private _separatorCount = count _separator; // Corner cases if (_separatorCount == 0 && _inputCount == 0) exitWith {[]}; @@ -44,9 +44,9 @@ if (_separatorCount == 0) exitWith {_input splitString ""}; if (_inputCount > 0 && _separatorCount > _inputCount) exitWith {[_input]}; if (_input == _separator) exitWith {["",""]}; -_lastWasSeperator = true; +private _lastWasSeperator = true; while {_index < _inputCount} do { - _find = (_input select [_index]) find _separator; + private _find = (_input select [_index]) find _separator; if (_find == 0) then { _index = _index + _separatorCount; diff --git a/addons/ui/flexiMenu/fnc_add.sqf b/addons/ui/flexiMenu/fnc_add.sqf index b992559e0..702ccff5b 100644 --- a/addons/ui/flexiMenu/fnc_add.sqf +++ b/addons/ui/flexiMenu/fnc_add.sqf @@ -3,12 +3,11 @@ TRACE_1("",_this); -private ["_msg", "_exit", "_list", "_key"]; // _this = ["player", [DIK_LSHIFT], -3, ["mission\weapon_menuDef.sqf", ["main"]]] // Note: calling script may require this file for dik codes: #include "\a3\editor_f\Data\Scripts\dikCodes.h" -_msg = "FLEXIMENU: Unknown Error in fnc_add.sqf"; //Initialize -_key = []; +private _msg = "FLEXIMENU: Unknown Error in fnc_add.sqf"; //Initialize +private _key = []; // validate params _msg = format ["Error: invalid params. %1 (%2)", _this, __FILE__]; @@ -53,7 +52,7 @@ GVAR(typeMenuSources) pushBack _this; [GVAR(typeMenuSources), _flexiMenu_typeMenuSources_ID_priority] call CBA_fnc_sortNestedArray; // reverse the order of sorting, so highest priority is at the top -_list = []; +private _list = []; for "_e" from (count GVAR(typeMenuSources) - 1) to 0 step -1 do { _list pushBack (GVAR(typeMenuSources) select _e); }; diff --git a/addons/ui/flexiMenu/fnc_execute.sqf b/addons/ui/flexiMenu/fnc_execute.sqf index 1b1da5a6d..dad51d6fb 100644 --- a/addons/ui/flexiMenu/fnc_execute.sqf +++ b/addons/ui/flexiMenu/fnc_execute.sqf @@ -4,17 +4,10 @@ //----------------------------------------------------------------------------- #include "\x\cba\addons\ui\script_component.hpp" -private [ - "_arrayID", "_actionData", "_action", "_subMenu", "_multiReselect", "_useListBox", - "_subMenuSource", "_params", "_pathName", "_actionCode", "_actionParams" -]; +private _arrayID = _this; +private _actionData = GVAR(menuActionData) select _arrayID; -_arrayID = _this; -_actionData = GVAR(menuActionData) select _arrayID; - -_action = _actionData select 0; -_subMenu = _actionData select 1; -_multiReselect = _actionData select 2; +_actionData params ["_action", "_subMenu", "_multiReselect"]; //----------------------------------------------------------------------------- // indicates an option/button was selected, (to allow menu to close upon release of interact key), except if _multiReselect enabled. if (_multiReselect == 0) then { @@ -22,10 +15,10 @@ if (_multiReselect == 0) then { }; // determine optional sub menu source -_subMenuSource = ""; -_params = ["?"]; -_useListBox = 0; -if (typeName _subMenu == typeName []) then { +private _subMenuSource = ""; +private _params = ["?"]; +private _useListBox = 0; +if (_subMenu isEqualType []) then { IfCountDefault(_subMenuSource,_subMenu,0,""); IfCountDefault(_params,_subMenu,1,[]); IfCountDefault(_useListBox,_subMenu,2,0); @@ -42,18 +35,19 @@ if (_useListBox == 0 && {_multiReselect == 0}) then { // if using embedded listB }; //----------------------------------------------------------------------------- // execute main menu action (unless submenu) -if (typeName _action == typename []) then { + +private _actionParams = 1; +private _actionCode = _action; + +if (_action isEqualType []) then { _actionParams = _action select 0; _actionCode = _action select 1; -} else { - _actionParams = 1; - _actionCode = _action; }; -if (typeName _actionCode == typename {}) then { +if (_actionCode isEqualType {}) then { _actionParams call _actionCode } else { - if (typename _actionCode == typename "") then { + if (_actionCode isEqualType "") then { if(_actionCode != "") then { _actionParams call compile _actionCode; }; @@ -63,7 +57,7 @@ if (typeName _actionCode == typename {}) then { // show sub menu if (_subMenuSource != "") then { // TODO: Find a way to combine the menu and list scripts together. - _pathName = QUOTE(PATHTO_SUB(PREFIX,COMPONENT_F,flexiMenu,%1)); + private _pathName = QUOTE(PATHTO_SUB(PREFIX,COMPONENT_F,flexiMenu,%1)); _pathName = format [_pathName, if (_useListBox == 0) then {'fnc_menu'} else {'fnc_list'}]; [GVAR(target), [[_subMenuSource, _params]]] call COMPILE_FILE2_SYS(_pathName); diff --git a/addons/ui/flexiMenu/fnc_getMenuDef.sqf b/addons/ui/flexiMenu/fnc_getMenuDef.sqf index 1c63f4b6c..ea81aad1c 100644 --- a/addons/ui/flexiMenu/fnc_getMenuDef.sqf +++ b/addons/ui/flexiMenu/fnc_getMenuDef.sqf @@ -3,23 +3,20 @@ //#define DEBUG_MODE_FULL #include "\x\cba\addons\ui\script_component.hpp" -private ["_menuDefs", "_target", "_menuSources"]; - -_target = _this select 0; -_menuSources = _this select 1; // [_target, _menuSources]; - -_menuDefs = []; +private _target = _this select 0; +private _menuSources = _this select 1; // [_target, _menuSources]; +private _menuDefs = []; { // forEach - private ["_params", "_menuSource", "_menuParams", "_array", "_menuDef"]; // declare locally to safe guard variables after _menuSource call, which is beyond our control of correctness. + private ["_menuDef"]; // declare locally to safe guard variables after _menuSource call, which is beyond our control of correctness. - _params = _x; + private _params = _x; if (isNil "_params") then { diag_log format ["%1:%2: CBA WARNING: Menu sources item is nil! Check Source: %3", __FILE__, __LINE__, _params]; }; - _menuSource = ""; - _menuParams = [_target]; + private _menuSource = ""; + private _menuParams = [_target]; // Syntax 1 if (typeName _params == typeName "") then { @@ -46,7 +43,7 @@ _menuDefs = []; } else { // check which string syntax was used: function, code string or sqf filename LOG("_menuSource alternate format"); - _array = toArray _menuSource; + private _array = toArray _menuSource; _menuDef = if (_array find 46 >= 0 && {_array find 34 < 0} && {_array find 39 < 0}) then { // 46='.',34=("),39=(') (eg: as in 'path\file.sqf') // sqf filename. Eg: 'path\file.sqf' _menuParams call COMPILE_FILE2_SYS(_menuSource); diff --git a/addons/ui/flexiMenu/fnc_getMenuOption.sqf b/addons/ui/flexiMenu/fnc_getMenuOption.sqf index fc04fc16f..d9d0022d1 100644 --- a/addons/ui/flexiMenu/fnc_getMenuOption.sqf +++ b/addons/ui/flexiMenu/fnc_getMenuOption.sqf @@ -114,12 +114,10 @@ if (_enabled != 0 && {_visible > 0}) then { // remove "^" from caption and substitute coloured shortcut letter if enabled. if (_index >= 0) then { - if (_enabled != 0) then { - private ["_offset"]; + if (_enabled != 0) then { + // TODO: Read an appropriate color from the menu class. -// TODO: Read an appropriate color from the menu class. - - _offset = (if (_containCaret) then {1} else {0}); + private _offset = (if (_containCaret) then {1} else {0}); if (!_fastPartialResult) then { _caption = [_array, _index, _offset, format ["", GVAR(hotKeyColor)]] call FUNC(highlightCaretKey); }; @@ -131,8 +129,7 @@ if (_index >= 0) then { // map menu shortcut DIK code // Note: don't append shortcut to empty caption, which is usually an "icon only" menu, without text captions. if (_shortcut_DIK != -1 && {_caption != ""}) then { - private ["_keyName"]; - _keyName = keyName _shortcut_DIK; + private _keyName = keyName _shortcut_DIK; _array = toArray _keyName; if (count _array > 2) then { _array = _array - [34]; // 34=("). Strip off leading and trailing quotes. diff --git a/addons/ui/flexiMenu/fnc_highlightCaretKey.sqf b/addons/ui/flexiMenu/fnc_highlightCaretKey.sqf index 46bec890a..6852d4d68 100644 --- a/addons/ui/flexiMenu/fnc_highlightCaretKey.sqf +++ b/addons/ui/flexiMenu/fnc_highlightCaretKey.sqf @@ -9,11 +9,10 @@ in order to avoid the millions of Deprecated function warnings: WARNING: Deprecated function used: KRON_StrToArray (new: cba_fnc_split) in cba_common */ -private ["_captionArray", "_len", "_array2"]; params ["_array", "_index", "_offset", "_hotKeyColor_ST"]; // (ST=structured text) "" -_captionArray = []; -_len = 0; +private _captionArray = []; +private _len = 0; // ([_caption, _index] call KRON_StrLeft)+ for "_i" from 0 to (_index - 1) do { @@ -33,7 +32,7 @@ for "_i" from (_index + _offset) to (_index + _offset) do { _len = _len + 1; }; -_array2 = toArray ""; +private _array2 = toArray ""; for "_i" from 0 to (count _array2 - 1) do { _captionArray set [_len, _array2 select _i]; _len = _len + 1; diff --git a/addons/ui/flexiMenu/fnc_keyDown.sqf b/addons/ui/flexiMenu/fnc_keyDown.sqf index 7c9e48bd8..08052a458 100644 --- a/addons/ui/flexiMenu/fnc_keyDown.sqf +++ b/addons/ui/flexiMenu/fnc_keyDown.sqf @@ -111,9 +111,8 @@ if (!GVAR(optionSelected) || !GVAR(holdKeyDown)) then { } forEach GVAR(typeMenuSources); if (!isNull _target) then { - private ["_menuSources", "_menuSource"]; // sometimes nil - _menuSources = []; - _menuSource = _target getVariable QGVAR(flexiMenu_source); + private _menuSources = []; + private _menuSource = _target getVariable QGVAR(flexiMenu_source); if (isNil "_menuSource") then {_menuSource = []} else {_menuSources pushBack _menuSource}; TRACE_2("",_menuSource,_menuSources); { diff --git a/addons/ui/flexiMenu/fnc_keyUp.sqf b/addons/ui/flexiMenu/fnc_keyUp.sqf index f68f5d52a..f542d60a0 100644 --- a/addons/ui/flexiMenu/fnc_keyUp.sqf +++ b/addons/ui/flexiMenu/fnc_keyUp.sqf @@ -1,14 +1,13 @@ #include "\x\cba\addons\ui\script_component.hpp" -private ["_handled", /* "_ctrl", */ "_active", "_potentialKeyMatch"]; params ["", "_dikCode", "_shift", "_ctrlKey", "_alt"]; -_handled = false; +private _handled = false; if (!GVAR(holdKeyDown)) exitWith {_handled}; // key release monitoring not required. // scan typeMenuSources key list (optimise overhead) -_potentialKeyMatch = false; +private _potentialKeyMatch = false; { // syntax of _keys: [[_dikCode1, [_shift, _ctrlKey, _alt]], [_dikCode2, [...]], ...] _keys = (_x select _flexiMenu_typeMenuSources_ID_DIKCodes); @@ -31,7 +30,7 @@ if !(_potentialKeyMatch) exitWith { _handled }; //----------------------------------------------------------------------------- -_active = (!isNil {uiNamespace getVariable QGVAR(display)}); +private _active = (!isNil {uiNamespace getVariable QGVAR(display)}); if (_active) then { _active = (!isNull (uiNamespace getVariable QGVAR(display))); }; diff --git a/addons/ui/flexiMenu/fnc_list.sqf b/addons/ui/flexiMenu/fnc_list.sqf index b9d94c788..4646a9a6c 100644 --- a/addons/ui/flexiMenu/fnc_list.sqf +++ b/addons/ui/flexiMenu/fnc_list.sqf @@ -3,31 +3,24 @@ disableSerialization; //----------------------------------------------------------------------------- #include "\x\cba\addons\ui\script_component.hpp" -private [ - "_msg", "_menuSources", "_menuDefs", "_idc", "_iconFolder", "_menuOption", "_caption", - "_action", "_icon", "_tooltip", "_shortcut_DIK", "_visible", "_enabled", "_array" -]; - -_menuDefs = _this call FUNC(getMenuDef); +private _menuDefs = _this call FUNC(getMenuDef); //----------------------------------------------------------------------------- // replace primary menu's key EH and menuDefs with same key EH but using secondary menu's menuDefs -private "_disp"; -_disp = uiNamespace getVariable QGVAR(display); +private _disp = uiNamespace getVariable QGVAR(display); _disp displayRemoveEventHandler ["keyDown", GVAR(keyDownEHID)]; params ["", "_menuSources"]; GVAR(keyDownEHID) = _disp displayAddEventHandler ["keyDown", format ["[_this, [%1, %2]] call %3", QGVAR(target), _menuSources, QUOTE(FUNC(menuShortcut))]]; -_caption = if (count (_menuDefs select 0) > _flexiMenu_menuProperty_ID_menuDesc) then {_menuDefs select 0 select _flexiMenu_menuProperty_ID_menuDesc} else {""}; +private _caption = if (count (_menuDefs select 0) > _flexiMenu_menuProperty_ID_menuDesc) then {_menuDefs select 0 select _flexiMenu_menuProperty_ID_menuDesc} else {""}; (_disp displayCtrl _flexiMenu_IDC_listMenuDesc) ctrlSetText _caption; -_iconFolder = if (count (_menuDefs select 0) > _flexiMenu_menuProperty_ID_iconFolder) then {_menuDefs select 0 select _flexiMenu_menuProperty_ID_iconFolder} else {""}; // base icon folder (eg: "\ca\ui\data\") +private _iconFolder = if (count (_menuDefs select 0) > _flexiMenu_menuProperty_ID_iconFolder) then {_menuDefs select 0 select _flexiMenu_menuProperty_ID_iconFolder} else {""}; // base icon folder (eg: "\ca\ui\data\") //----------------------------------------------------------------------------- -_menuRsc = _menuDefs select 0 select _flexiMenu_menuProperty_ID_menuResource; -_msg = ""; -_msg = format ["%1: Invalid params c4: %2", __FILE__, _this]; +private _menuRsc = _menuDefs select 0 select _flexiMenu_menuProperty_ID_menuResource; +private _msg = format ["%1: Invalid params c4: %2", __FILE__, _this]; if (isNil "_msg") then {_msg = "FLEXIMENU: Unknown Error in fnc_list.sqf"}; if (typeName _menuRsc != typeName "") exitWith {diag_log _msg}; @@ -37,15 +30,15 @@ if (!isClass (configFile >> _menuRsc) && {!isClass (missionConfigFile >> _menuRs }; // TODO: Support missionConfigFile too -_width = getNumber (configFile >> _menuRsc >> "flexiMenu_subMenuCaptionWidth"); +private _width = getNumber (configFile >> _menuRsc >> "flexiMenu_subMenuCaptionWidth"); if (_width == 0) then { player sideChat format ["Error: missing flexiMenu_subMenuCaptionWidth: %1", _menuRsc]; _width = __SMW_default; }; -_idc = _flexiMenu_IDC_listMenuDesc; -_ctrl = _disp displayCtrl _idc; -_array = ctrlPosition _ctrl; +private _idc = _flexiMenu_IDC_listMenuDesc; +private _ctrl = _disp displayCtrl _idc; +private _array = ctrlPosition _ctrl; if ({_x == 0} count _array != 4 && {_array select 2 == 0}) then { _array = [_array select 0, _array select 1, _width, _array select 3]; @@ -76,16 +69,16 @@ if (GVAR(hotKeyColor) == "") then { _idc = _flexiMenu_baseIDC_listButton; //----------------------------------------------------------------------------- { // forEach - _menuOption = [_menuDefs select 0, _x] call FUNC(getMenuOption); - - _caption = _menuOption select _flexiMenu_menuDef_ID_caption; - _action = _menuOption select _flexiMenu_menuDef_ID_action; - _icon = _menuOption select _flexiMenu_menuDef_ID_icon; - _tooltip = _menuOption select _flexiMenu_menuDef_ID_tooltip; - _subMenu = _menuOption select _flexiMenu_menuDef_ID_subMenuSource; - _shortcut_DIK = _menuOption select _flexiMenu_menuDef_ID_shortcut; - _enabled = _menuOption select _flexiMenu_menuDef_ID_enabled; - _visible = _menuOption select _flexiMenu_menuDef_ID_visible; + private _menuOption = [_menuDefs select 0, _x] call FUNC(getMenuOption); + + private _caption = _menuOption select _flexiMenu_menuDef_ID_caption; + private _action = _menuOption select _flexiMenu_menuDef_ID_action; + private _icon = _menuOption select _flexiMenu_menuDef_ID_icon; + private _tooltip = _menuOption select _flexiMenu_menuDef_ID_tooltip; + private _subMenu = _menuOption select _flexiMenu_menuDef_ID_subMenuSource; + private _shortcut_DIK = _menuOption select _flexiMenu_menuDef_ID_shortcut; + private _enabled = _menuOption select _flexiMenu_menuDef_ID_enabled; + private _visible = _menuOption select _flexiMenu_menuDef_ID_visible; _ctrl = _disp displayCtrl _idc; _array = ctrlPosition _ctrl; diff --git a/addons/ui/flexiMenu/fnc_menuShortcut.sqf b/addons/ui/flexiMenu/fnc_menuShortcut.sqf index 290c8e199..b966f1bca 100644 --- a/addons/ui/flexiMenu/fnc_menuShortcut.sqf +++ b/addons/ui/flexiMenu/fnc_menuShortcut.sqf @@ -4,13 +4,9 @@ if (isDedicated || !dialog) exitWith {}; -private [ - "_handled", "_menuDefs", "_caption", "_action", "_icon", "_tooltip", "_subMenu", "_shortcut", - "_visible", "_enabled" -]; (_this select 0) params ["_control", "_dikCode", "_shiftKey", "_ctrlKey", "_altKey"]; -_handled = false; +private _handled = false; // prevent unneeded cpu usage due to key down causing repeated event trigger if (GVAR(holdKeyDown)) then { @@ -23,19 +19,19 @@ if (!GVAR(holdKeyDown) && {(_dikCode in (actionKeys "menuBack"))}) exitWith { true }; -_menuDefs = (_this select 1) call FUNC(getMenuDef); +private _menuDefs = (_this select 1) call FUNC(getMenuDef); //----------------------------------------------------------------------------- { // forEach - _menuOption = [_menuDefs select 0, _x, true] call FUNC(getMenuOption); // get fast partial record - - //_caption = _menuOption select _flexiMenu_menuDef_ID_caption; - //_action = _menuOption select _flexiMenu_menuDef_ID_action; - //_icon = _menuOption select _flexiMenu_menuDef_ID_icon; - //_tooltip = _menuOption select _flexiMenu_menuDef_ID_tooltip; - //_subMenu = _menuOption select _flexiMenu_menuDef_ID_subMenuSource; - _shortcut = _menuOption select _flexiMenu_menuDef_ID_shortcut; - _enabled = _menuOption select _flexiMenu_menuDef_ID_enabled; - _visible = _menuOption select _flexiMenu_menuDef_ID_visible; + private _menuOption = [_menuDefs select 0, _x, true] call FUNC(getMenuOption); // get fast partial record + + //private _caption = _menuOption select _flexiMenu_menuDef_ID_caption; + //private _action = _menuOption select _flexiMenu_menuDef_ID_action; + //private _icon = _menuOption select _flexiMenu_menuDef_ID_icon; + //private _tooltip = _menuOption select _flexiMenu_menuDef_ID_tooltip; + //private _subMenu = _menuOption select _flexiMenu_menuDef_ID_subMenuSource; + private _shortcut = _menuOption select _flexiMenu_menuDef_ID_shortcut; + private _enabled = _menuOption select _flexiMenu_menuDef_ID_enabled; + private _visible = _menuOption select _flexiMenu_menuDef_ID_visible; if (_dikCode == _shortcut && {_enabled != 0} && {_visible > 0}) exitWith { _menuOption = [_menuDefs select 0, _x, false] call FUNC(getMenuOption); // get complete same record diff --git a/addons/ui/flexiMenu/fnc_openMenuByDef.sqf b/addons/ui/flexiMenu/fnc_openMenuByDef.sqf index 2d828b3ff..d1f057c7f 100644 --- a/addons/ui/flexiMenu/fnc_openMenuByDef.sqf +++ b/addons/ui/flexiMenu/fnc_openMenuByDef.sqf @@ -79,10 +79,8 @@ if (!GVAR(optionSelected) || !GVAR(holdKeyDown)) then { // If a matching target was found, open the highest priority menu associated with it // by calling FUNC(menu). if (!isNull _target) then { - private ["_menuSources", "_menuSource"]; - - _menuSources = []; - _menuSource = _target getVariable QGVAR(flexiMenu_source); + private _menuSources = []; + private _menuSource = _target getVariable QGVAR(flexiMenu_source); if (isNil "_menuSource") then {_menuSource = []} else {_menuSources pushBack _menuSource}; { _menuSources pushBack _x; diff --git a/addons/ui/flexiMenu/fnc_remove.sqf b/addons/ui/flexiMenu/fnc_remove.sqf index 770121ad5..7f1679852 100644 --- a/addons/ui/flexiMenu/fnc_remove.sqf +++ b/addons/ui/flexiMenu/fnc_remove.sqf @@ -1,12 +1,10 @@ //#define DEBUG_MODE_FULL #include "\x\cba\addons\ui\script_component.hpp" -private ["_msg", "_i"]; - // _this = ["player", [DIK_LSHIFT], -3, ["mission\weapon_menuDef.sqf", ["main"]]] // validate params -_msg = ""; +private _msg = ""; _msg = format ["Error: invalid params. %1 (%2)", _this, __FILE__ ]; if (isNil "_msg") then {_msg = "FLEXIMENU: Unknown Error in fnc_remove.sqf"}; @@ -18,7 +16,7 @@ if (typeName (_this select _flexiMenu_typeMenuSources_ID_DIKCodes) != typeName [ if (typeName (_this select _flexiMenu_typeMenuSources_ID_priority) != typeName 2) exitWith {diag_log _msg}; if !(typeName (_this select _flexiMenu_typeMenuSources_ID_menuSource) in [typeName [], typeName ""]) exitWith {diag_log _msg}; -_i = 0; +private _i = 0; { if (str _x == str _this) then { GVAR(typeMenuSources) set [_i, -1]; diff --git a/addons/ui/fnc_progressBar.sqf b/addons/ui/fnc_progressBar.sqf index 89dd1da9e..ae32d0df0 100644 --- a/addons/ui/fnc_progressBar.sqf +++ b/addons/ui/fnc_progressBar.sqf @@ -90,6 +90,7 @@ _ctrlScript ctrlAddEventHandler ["Draw", { private _elapsedTime = (CBA_missionTime - _startTime) min _totalTime; private _continue = [[_arguments, true, _elapsedTime, _totalTime], _condition] call { + // prevent these variables from being overwritten private ["_ctrlScript", "_display", "_arguments", "_condition", "_onSuccess", "_onFailure", "_startTime", "_totalTime", "_elapsedTime"]; _this#0 call _this#1; }; diff --git a/addons/vectors/fnc_vectCross.sqf b/addons/vectors/fnc_vectCross.sqf index 99b8c8b5c..51fa83f31 100644 --- a/addons/vectors/fnc_vectCross.sqf +++ b/addons/vectors/fnc_vectCross.sqf @@ -23,4 +23,6 @@ Author: ---------------------------------------------------------------------------- */ //Function is complete replica, deprecated -_this call BIS_fnc_crossProduct \ No newline at end of file +params ["_v1", "_v2"]; + +_v1 vectorCrossProduct _v2 diff --git a/addons/versioning/XEH_postInit.sqf b/addons/versioning/XEH_postInit.sqf index 9a6d28680..1f8ba5842 100644 --- a/addons/versioning/XEH_postInit.sqf +++ b/addons/versioning/XEH_postInit.sqf @@ -6,9 +6,8 @@ SCRIPT(XEH_postInit); */ if (!SLX_XEH_DisableLogging) then { - private ["_logMsg", "_filter"]; - _logMsg = "CBA_VERSIONING: "; - _filter = {if (_x isEqualType 1) then {[_x] call CBA_fnc_formatNumber} else {_x}}; + private _logMsg = "CBA_VERSIONING: "; + private _filter = {if (_x isEqualType 1) then {[_x] call CBA_fnc_formatNumber} else {_x}}; [GVAR(versions), { _logMsg = (_logMsg + format["%1=%2, ", _key, ([_value select 0, _filter] call CBA_fnc_filter) joinString "."])}] call CBA_fnc_hashEachPair; diag_log [diag_frameNo, diag_tickTime, time, _logMsg]; @@ -16,16 +15,15 @@ if (!SLX_XEH_DisableLogging) then { // Dependency check and warn [GVAR(dependencies), { - private ["_mod", "_dependencyInfo", "_class", "_f","_dependencyIsPresent"]; - _f = { + private _f = { diag_log text _this; sleep 1; CBA_logic globalChat _this; }; { - _mod = _x select 0; - _dependencyInfo = _x select 1; - _class = (configFile >> "CfgPatches" >> (_dependencyInfo select 0)); + private _mod = _x select 0; + private _dependencyInfo = _x select 1; + private _class = (configFile >> "CfgPatches" >> (_dependencyInfo select 0)); private _dependencyIsPresent = call compile format ["%1", (_dependencyInfo select 2)]; if ((isNil "_dependencyIsPresent") || {!(_dependencyIsPresent isEqualType false)}) then { //https://dev.withsix.com/issues/74516 - The code could return non-bool, if "true" is converted to "1" durring binarization diff --git a/addons/versioning/XEH_preInit.sqf b/addons/versioning/XEH_preInit.sqf index 6fe202819..47503528d 100644 --- a/addons/versioning/XEH_preInit.sqf +++ b/addons/versioning/XEH_preInit.sqf @@ -16,23 +16,23 @@ if (isNil QGVAR(mismatch)) then { GVAR(mismatch) = [] }; // Build versions hashes GVAR(versions) = [[], [[0, 0, 0], 0]] call (uiNamespace getVariable "CBA_fnc_hashCreate"); GVAR(dependencies) = [[], ["", [0, 0, 0], "true"]] call (uiNamespace getVariable "CBA_fnc_hashCreate"); -private ["_prefix", "_version", "_verCfg", "_level", "_deps", "_dependencies", "_entry", "_cfgPatches"]; + #define DATA configName _entry,(getArray(_entry)) for "_i" from 0 to (count (CFGSETTINGS) - 1) do { - _prefix = (CFGSETTINGS) select _i; + private _prefix = (CFGSETTINGS) select _i; if (isClass _prefix) then { - _cfgPatches = if (isText(_prefix >> "main_addon")) then { getText(_prefix >> "main_addon") } else { format["%1_main", configName _prefix] }; - _verCfg = (configFile >> "CfgPatches" >> _cfgPatches >> "versionAr"); - _level = if (isNumber(_prefix >> "level")) then { getNumber(_prefix >> "level") } else { -1 }; - _version = if (isArray(_verCfg)) then { [getArray(_verCfg), _level] } else { [[0, 0, 0], 0] }; + private _cfgPatches = if (isText(_prefix >> "main_addon")) then { getText(_prefix >> "main_addon") } else { format["%1_main", configName _prefix] }; + private _verCfg = (configFile >> "CfgPatches" >> _cfgPatches >> "versionAr"); + private _level = if (isNumber(_prefix >> "level")) then { getNumber(_prefix >> "level") } else { -1 }; + private _version = if (isArray(_verCfg)) then { [getArray(_verCfg), _level] } else { [[0, 0, 0], 0] }; [GVAR(versions), toLower(configName _prefix), _version] call (uiNamespace getVariable "CBA_fnc_hashSet"); - _deps = (_prefix >> "dependencies"); + private _deps = (_prefix >> "dependencies"); if (isClass(_deps)) then { - _dependencies = []; + private _dependencies = []; for "_j" from 0 to ((count _deps) - 1) do { - _entry = _deps select _j; + private _entry = _deps select _j; if (isArray(_entry)) then { _dependencies pushBack [DATA]; }; @@ -44,15 +44,14 @@ for "_i" from 0 to (count (CFGSETTINGS) - 1) do PREP(version_check); FUNC(version_compare) = { - private ["_failed", "_c"]; params ["_value","_localValue"]; //Handle non-number arrays - eg. {"mod", {"1.0"}, "(true)"} if ((!(_value isEqualTo [])) && {!(_value isEqualTypeAll 0)}) exitWith {true}; if ((!(_localValue isEqualTo [])) && {!(_localValue isEqualTypeAll 0)}) exitWith {true}; - _failed = false; - _c = count _localValue; + private _failed = false; + private _c = count _localValue; for "_i" from 0 to ((count _value) - 1) do { if (_i == _c) exitWith { _failed = true}; // Woobs diff --git a/addons/versioning/fnc_version_check.sqf b/addons/versioning/fnc_version_check.sqf index e8a2097bf..c07b51459 100644 --- a/addons/versioning/fnc_version_check.sqf +++ b/addons/versioning/fnc_version_check.sqf @@ -1,15 +1,14 @@ #include "script_component.hpp" -private ["_localValue", "_remoteVersion", "_localVersion", "_lc", "_rc", "_level", "_local", "_remote", "_failed"]; // _key, _value are injected by the CBA_fnc_hashEachPair +// _key, _value are injected by the CBA_fnc_hashEachPair -_localValue = [GVAR(versions), _key] call CBA_fnc_hashGet; +private _localValue = [GVAR(versions), _key] call CBA_fnc_hashGet; TRACE_3("Version Check",_key,_value,_localValue); -_failed = false; -_localVersion = _localValue select 0; -_remoteVersion = _value select 0; -_level = _value select 1; -_lc = count _localVersion; _rc = count _remoteVersion; +private _failed = false; +private _localVersion = _localValue select 0; +_value params ["_remoteVersion", "_level"]; +private _lc = count _localVersion; private _rc = count _remoteVersion; switch _level do { case -1: { _level = _rc }; // All must match case -2: { _level = if (_lc == 0) then { 0 } else { _rc } }; // All must match, IF the addon is installed, otherwise ignore @@ -21,8 +20,8 @@ if (_lc >= _level) then { for "_i" from 0 to (_level - 1) do { - _local = _localVersion select _i; - _remote = _remoteVersion select _i; + private _local = _localVersion select _i; + private _remote = _remoteVersion select _i; if (_local != _remote) exitWith { _failed = true; }; }; } else { diff --git a/addons/xeh/fnc_init.sqf b/addons/xeh/fnc_init.sqf index bd74cfa14..f47a516d2 100644 --- a/addons/xeh/fnc_init.sqf +++ b/addons/xeh/fnc_init.sqf @@ -55,7 +55,7 @@ if !(ISINITIALIZED(_this)) then { SETINITIALIZED(_vehicle); { - private ["_vehicle", "_wreck"]; + private ["_vehicle", "_wreck"]; // prevent these variables from being overwritten call _x; } forEach (_wreck getVariable QGVAR(respawn)); diff --git a/addons/xeh/fnc_initDisplay.sqf b/addons/xeh/fnc_initDisplay.sqf index 6a834d990..7612dcee9 100644 --- a/addons/xeh/fnc_initDisplay.sqf +++ b/addons/xeh/fnc_initDisplay.sqf @@ -12,7 +12,7 @@ _event = ["", "DisplayLoad", "DisplayUnload"] param [["", "onload", "onunload"] if !(_event isEqualTo "") then { { { - private ["_event", "_className"]; + private ["_event", "_className"]; // prevent these variables from being overwritten _args call compile getText _x; } forEach configProperties [_x >> XEH_FORMAT_CONFIG_NAME(_event) >> _className, "isText _x"]; } forEach XEH_MAIN_CONFIGS;