Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup - Add private and remove some unused vars #1697

Merged
merged 8 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .hemtt/lints.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[config.file_type]
options.allow_no_extension = true

[sqf.banned_commands]
options.ignore = [
"addPublicVariableEventHandler", # Alt syntax is broken, we are using main syntax
Expand Down
6 changes: 3 additions & 3 deletions addons/common/fnc_getAnimType.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ private _weapon = format["%1", currentWeapon _man];
private _pos = "";

if (_weapon != "") then {
_class = configFile >> "CfgWeapons" >> _weapon;
private _class = configFile >> "CfgWeapons" >> _weapon;

if (isClass _class) then {
_temp = "";
private _temp = "";
while { isClass _class && {_temp == ""} } do {
_temp = switch (configName _class) do {
case "RifleCore": {"rfl"};
Expand All @@ -50,7 +50,7 @@ if (_weapon != "") then {
};

if (typeName (_array select 0) == "ARRAY") then {
_stance = (_man call CBA_fnc_getUnitAnim) select 0;
private _stance = (_man call CBA_fnc_getUnitAnim) select 0;
_pos = switch ( _stance ) do {
case "stand": {0};
case "kneel": {1};
Expand Down
2 changes: 1 addition & 1 deletion addons/common/fnc_getNearest.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ params [
private _return = [[], objNull] select (isNil {param [2]});

{
_distance = [_position, _x] call CBA_fnc_getDistance;
private _distance = [_position, _x] call CBA_fnc_getDistance;

if (_distance < _radius) then {
if !(call _code) exitWith {}; // don't move up. condition has to return false, vs. has to return true. Can be nil!
Expand Down
2 changes: 1 addition & 1 deletion addons/common/fnc_getTerrainProfile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private _return = [];
private _pos = [];

for "_i" from 0 to (_2Ddistance / _resolution) do {
_adj = _resolution * _i;
private _adj = _resolution * _i;
_pos = [_posA, _adj, _angle] call BIS_fnc_relPos;
_logic setPosATL _pos;
private _alt = ((getPosASL _logic) select 2) - _z;
Expand Down
4 changes: 0 additions & 4 deletions addons/common/fnc_isTurnedOut.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ private _cfg = configOf _vehicle;

if (_vehicle != _unit) then {
if (driver _vehicle == _unit) then {
private _forceHideDriver = getNumber (_cfg >> "forceHideDriver");
_out = _vehicle animationPhase "hatchDriver" > 0;
} else {
private _assignedRole = assignedVehicleRole _unit;
Expand All @@ -47,9 +46,6 @@ if (_vehicle != _unit) then {
private _turretPath = _assignedRole select 1;
private _turret = [_vehicle, _turretPath] call CBA_fnc_getTurret;

private _canHideGunner = getNumber (_turret >> "canHideGunner");
private _forceHideGunner = getNumber (_turret >> "forceHideGunner");

private _hatchAnimation = getText (_turret >> "animationSourceHatch");
_out = (_vehicle animationPhase _hatchAnimation) > 0;
} else {
Expand Down
15 changes: 7 additions & 8 deletions addons/common/fnc_mapGridToPos.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ if (IS_STRING(_pos)) then {
_height = (_maxNorthing*100) - abs(_minus) + 1;
} else {
if (isNil QGVAR(rvOriginX) || {isNil QGVAR(rvOriginY)}) then {
_start = format["%1", mapGridPosition [0, 0]];
_size = toArray _start;
_rvOriginY = 0;
_rvOriginX = 0;
_ignore = false;
private _start = format["%1", mapGridPosition [0, 0]];
private _size = toArray _start;
private _rvOriginY = 0;
private _rvOriginX = 0;
private _ignore = false;
switch (count _size) do {
case 2: {
_rvOriginY = (parseNumber (toString [(_size select 1)]))*10000;
Expand Down Expand Up @@ -170,9 +170,8 @@ if (_doOffSet && {(_northingMultiple max _eastingMultiple) > 1}) then {
};

// Return position.
_return = if (_reversed) then {
if (_reversed) then {
[_posX+_offset, _posY-_offset, 0]
} else {
[_posX+_offset-GVAR(rvOriginX), _posY+_offset-GVAR(rvOriginY), 0]
};
_return
}
2 changes: 1 addition & 1 deletion addons/common/fnc_switchPlayer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private _ar = [weapons _oldUnit, magazines _oldUnit, rank _oldUnit, score _oldUn

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
private _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" };
[_oldUnit] join _dummyGroup;

Expand Down
2 changes: 1 addition & 1 deletion addons/diagnostic/fnc_initExtendedDebugConsole.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ FUNC(nextStatement) = {
};

FUNC(removeIndentation) = {
params ["_control", "_text", "_index"];
params ["_expression", "_text", "_index"];

private _chars = toArray _text;
private _indexRev = count _chars - _index;
Expand Down
2 changes: 1 addition & 1 deletion addons/hashes/fnc_parseYAML.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ if (count _yaml > 0) then

_pos = -1;

_retVal = ([_yaml, _pos, -1, [[]]] call _parse);
private _retVal = ([_yaml, _pos, -1, [[]]] call _parse);
_pos = _retVal select 0;
_value = _retVal select 1;
_error = _retVal select 2;
Expand Down
8 changes: 4 additions & 4 deletions addons/keybinding/fnc_addKeybindToFleximenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Author:
// Clients only.
if (isDedicated) exitWith {};

_nullKeybind = [-1, [false, false, false]];
private _nullKeybind = [-1, [false, false, false]];

params ["_modName", "_actionId", "_displayName", "_fleximenuDef", ["_defaultKeybind", _nullKeybind], ["_holdKey", true], ["_holdDelay", 0], ["_overwrite", false]];

Expand All @@ -52,10 +52,10 @@ if (count (_fleximenuDef select 1) > 0) then {
_fleximenuDef call cba_fnc_flexiMenu_add;

// Create the code to open the fleximenu.
_downCode = compile format ["%1 call cba_fnc_fleximenu_openMenuByDef;", _fleximenuDef];
_upCode = {};
private _downCode = compile format ["%1 call cba_fnc_fleximenu_openMenuByDef;", _fleximenuDef];
private _upCode = {};

// Pass everything to the new API cba_fnc_addKeybind.
_keybind = [_modName, _actionId, _displayName, _downCode, _upCode, _defaultKeybind, _holdKey, _holdDelay, _overwrite] call CBA_fnc_addKeybind;
private _keybind = [_modName, _actionId, _displayName, _downCode, _upCode, _defaultKeybind, _holdKey, _holdDelay, _overwrite] call CBA_fnc_addKeybind;

_keybind;
20 changes: 10 additions & 10 deletions addons/keybinding/fnc_gui_configure.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ params ["_control"];
// get dialog
private _display = ctrlParent _control;

_ctrlKeyboardGroup = _display displayCtrl 2300;
_ctrlMouseGroup = _display displayCtrl 2301;
_ctrlKeyboardButton = _display displayCtrl 2400;
_ctrlMouseButton = _display displayCtrl 2401;
_ctrlControllerButton = _display displayCtrl 106;
_ctrlPresetButton = _display displayCtrl 114;
_ctrlDefaultButton = _display displayCtrl 101;
private _ctrlKeyboardGroup = _display displayCtrl 2300;
private _ctrlMouseGroup = _display displayCtrl 2301;
private _ctrlKeyboardButton = _display displayCtrl 2400;
private _ctrlMouseButton = _display displayCtrl 2401;
private _ctrlControllerButton = _display displayCtrl 106;
private _ctrlPresetButton = _display displayCtrl 114;
private _ctrlDefaultButton = _display displayCtrl 101;

_ctrlKeyboardButtonFake = _display displayCtrl IDC_BTN_KEYBOARD_FAKE;
_ctrlAddonsGroup = _display displayCtrl IDC_ADDONS_GROUP;
_ctrlToggleButton = _display displayCtrl IDC_BTN_CONFIGURE_ADDONS;
private _ctrlKeyboardButtonFake = _display displayCtrl IDC_BTN_KEYBOARD_FAKE;
private _ctrlAddonsGroup = _display displayCtrl IDC_ADDONS_GROUP;
private _ctrlToggleButton = _display displayCtrl IDC_BTN_CONFIGURE_ADDONS;

// Toggle displayed groups and buttons.
if !(ctrlShown _ctrlAddonsGroup) then {
Expand Down
2 changes: 1 addition & 1 deletion addons/keybinding/fnc_initDisplayConfigure.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ _ctrlButtonOK ctrlAddEventHandler ["ButtonClick", {

// overwrite with new keyhandlers
{
_keybind = _x;
private _keybind = _x;

if (_downCode isNotEqualTo {}) then {
[_keybind select 0, _keybind select 1, _downCode, "keyDown", format ["%1_down_%2", _action, _forEachIndex], _holdKey, _holdDelay] call CBA_fnc_addKeyHandler;
Expand Down
4 changes: 2 additions & 2 deletions addons/keybinding/fnc_registerKeybind.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Author:
if (isDedicated) exitWith {};
diag_log text format ["[CBA Keybinding] WARNING: %1=>%2 called cba_fnc_registerKeybind is no longer a valid function and has been replaced with cba_fnc_addKeybind. Contact the developer of mod %1 to change the code to use the new function.", _this select 0, _this select 1];

_nullKeybind = [-1, false, false, false];
private _nullKeybind = [-1, false, false, false];

params ["_modName", "_actionName", "_code", ["_defaultKeybind", _nullKeybind], ["_overwrite", false], ["_keypressType", "KeyDown"]];

Expand All @@ -26,7 +26,7 @@ if (count _defaultKeybind != 4) then {
// Key format is not known, set to nil and warn
_defaultKeybind = _nullKeybind;

_warn = ["[CBA Keybinding] ERROR: Invalid keybind format %1 for %2 %3. Using null keybind.", _defaultKeybind, _modName, _actionName];
private _warn = ["[CBA Keybinding] ERROR: Invalid keybind format %1 for %2 %3. Using null keybind.", _defaultKeybind, _modName, _actionName];
_warn call BIS_fnc_error;
diag_log format _warn;
};
Expand Down
6 changes: 3 additions & 3 deletions addons/keybinding/fnc_registerKeybindToFleximenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Author:
if (isDedicated) exitWith {};
diag_log text format ["[CBA Keybinding] WARNING: %1=>%2 called CBA_fnc_registerKeybindToFleximenu is no longer a valid function and has been replaced with CBA_fnc_addKeybindToFleximenu. Contact the developer of mod %1 to change the code to use the new function.", _this select 0,_this select 1];

_nullKeybind = [-1, false, false, false];
private _nullKeybind = [-1, false, false, false];

params ["_modName", "_actionName", "_fleximenuDef", ["_defaultKeybind", _nullKeybind], ["_overwrite", false], ["_keypressType", "KeyDown"]];

Expand All @@ -48,9 +48,9 @@ if (count (_fleximenuDef select 1) > 0) then {
_fleximenuDef call cba_fnc_flexiMenu_add;

// Create the code to open the fleximenu.
_code = compile format ["%1 call cba_fnc_fleximenu_openMenuByDef;", _fleximenuDef];
private _code = compile format ["%1 call cba_fnc_fleximenu_openMenuByDef;", _fleximenuDef];

// Pass everything to the real cba_fnc_registerKeybind.
_keybind = [_modName, _actionName, _code, _defaultKeybind, _overwrite, _keypressType] call CBA_fnc_registerKeybind;
private _keybind = [_modName, _actionName, _code, _defaultKeybind, _overwrite, _keypressType] call CBA_fnc_registerKeybind;

_keybind;
2 changes: 1 addition & 1 deletion addons/modules/fnc_moduleDefend.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if (isNil "_defendPos") then {_defendSetPos = true;};

// Define if allowed to patrol
_canPatrol = _logic getVariable ["canPatrol", 0.1];
_shouldHold = _logic getVariable ["shouldHold", 0];
private _shouldHold = _logic getVariable ["shouldHold", 0];

// Command local group leaders to defend area
_defendRadius = _logic getVariable ["defendRadius", 25];
Expand Down
4 changes: 2 additions & 2 deletions addons/modules/fnc_modulePatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ _localGroups = _groups select {local _x};
if (_localGroups isEqualTo []) exitWith {};

// Define variables
_patrolLocType = _logic getVariable ["patrolLocType", ""];
private _patrolLocType = _logic getVariable ["patrolLocType", ""];
_patrolPos = _logic getVariable ["patrolPosition", objNull];
_patrolSetPos = false;
private _patrolSetPos = false;

// Parse patrol position from string
_patrolPos = [_patrolLocType, _patrolPos] call CBA_fnc_getPosFromString;
Expand Down
4 changes: 2 additions & 2 deletions addons/music/fnc_findMusic.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ private _results = [];

_tags pushBackUnique _theme; //Take the theme if no tags found

for [{_i=0}, {_i < (count _tags)}, {_i = _i + 1}] do {
_tag = toLower (_tags select _i);
for [{private _i=0}, {_i < (count _tags)}, {_i = _i + 1}] do {
private _tag = toLower (_tags select _i);
if (count _searchTags == 0 || {_tag in _searchTags}) then {
_i = count _tags;
_results pushBackUnique _track;
Expand Down
2 changes: 1 addition & 1 deletion addons/settings/fnc_gui_export.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

params ["_parentDisplay", "_mode"];

_display = _parentDisplay createDisplay QGVAR(export);
private _display = _parentDisplay createDisplay QGVAR(export);

private _ctrlPresetsGroup = _display displayCtrl IDC_EXPORT_GROUP;
private _ctrlTitle = _display displayCtrl IDC_EXPORT_TITLE;
Expand Down
2 changes: 1 addition & 1 deletion addons/settings/fnc_gui_preset.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// get button
params ["_parentDisplay", "_mode"];

_display = _parentDisplay createDisplay QGVAR(presets);
private _display = _parentDisplay createDisplay QGVAR(presets);

private _ctrlPresetsGroup = _display displayCtrl IDC_PRESETS_GROUP;
private _ctrlTitle = _display displayCtrl IDC_PRESETS_TITLE;
Expand Down
2 changes: 1 addition & 1 deletion addons/strings/fnc_formatElapsedTime.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private _minutes = floor (_seconds / 60);
_seconds = _seconds - (_minutes * 60);

// Add the milliseconds if required.
_elapsed = switch (_format) do {
private _elapsed = switch (_format) do {
case "H:MM:SS": {
format ["%1:%2:%3",
_hours,
Expand Down
14 changes: 7 additions & 7 deletions addons/ui/fnc_initDisplayInterrupt.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -76,26 +76,26 @@ _button ctrlRemoveEventHandler ["ButtonClick", 0]; // remove vanilla button
_button ctrlAddEventHandler ["ButtonClick", {
// this is an edit of a BI script, don't change unnecessarily
params ["_ctrl"];
_display = ctrlParent _ctrl;
private _display = ctrlParent _ctrl;

if (!ctrlCommitted _ctrl) exitWith {};

_buttons = + (_display getVariable QGVAR(MenuButtons));
private _buttons = + (_display getVariable QGVAR(MenuButtons));

_offset = 0;
private _offset = 0;
if (!isMultiplayer && {getNumber (missionConfigFile >> "replaceAbortButton") > 0}) then {
_offset = 1.1;
};

_upperPartTime = 0.05 * count _buttons;
_buttonsTime = 0.05;
private _upperPartTime = 0.05 * count _buttons;
private _buttonsTime = 0.05;

//hide buttons and collapse accordion
if (uiNamespace getVariable "BIS_DisplayInterrupt_isOptionsExpanded") then {
//move down - background, title, player's name, play, editor, profile, options

//Title background
_control = _display displayCtrl 1050;
private _control = _display displayCtrl 1050;
_control ctrlSetPosition [1 * GUI_GRID_W + GUI_GRID_X, (14.2 - _offset) * GUI_GRID_H + GUI_GRID_Y];
_control ctrlCommit _upperPartTime;

Expand Down Expand Up @@ -167,7 +167,7 @@ _button ctrlAddEventHandler ["ButtonClick", {
_offset = _offset + (count _buttons - 4) * 1.1;

//Title background
_control = _display displayCtrl 1050;
private _control = _display displayCtrl 1050;
_control ctrlSetPosition [1 * GUI_GRID_W + GUI_GRID_X, (9.8 - _offset) * GUI_GRID_H + GUI_GRID_Y];
_control ctrlCommit _upperPartTime;

Expand Down
2 changes: 1 addition & 1 deletion addons/ui/fnc_initDisplayInventory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ if !(isNil QGVAR(renamedItems)) then {
private _control = _x;

if (ctrlShown _control) then {
for [{_i = 0}, {_i < (lbSize _control)}, {_i = _i + 1}] do {
for [{private _i = 0}, {_i < (lbSize _control)}, {_i = _i + 1}] do {
private _classname = ([_control, _i] call FUNC(getInventoryItemData)) select 0;
if (!isNil "_classname") then {
private _renameParams = GVAR(renamedItems) getOrDefault [_classname, []];
Expand Down
2 changes: 1 addition & 1 deletion addons/ui/fnc_preload3DEN.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ private _cache = [];
private _listItem = _list select _index;

if (_isPublic) then {
_displayName = getText (_weaponConfig >> "displayName");
private _displayName = getText (_weaponConfig >> "displayName");

// append display name with attachment names
{
Expand Down
4 changes: 2 additions & 2 deletions addons/ui/fnc_preloadCurator.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private _cache = [];

{
private _patchConfig = _cfgPatches >> _x;
_addon = toLower _x;
private _addon = toLower _x;

private _addonList = [[],[],[],[],[],[],[],[],[],[],[],[]];

Expand All @@ -109,7 +109,7 @@ private _cache = [];
private _listItem = _addonList select _index;

if (_isPublic) then {
_displayName = getText (_weaponConfig >> "displayName");
private _displayName = getText (_weaponConfig >> "displayName");

// append display name with attachment names
{
Expand Down
4 changes: 2 additions & 2 deletions addons/versioning/XEH_postInitServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ QGVAR(mismatch) addPublicVariableEventHandler { (_this select 1) call FUNC(handl
private "_str";
_str = 'if(isServer)exitWith{};if (isNil "CBA_display_ingame_warnings") then { CBA_display_ingame_warnings = true; };LOG("cba_versioning_check");0 = objNull spawn { sleep 1; sleep 1; _func={GVAR(mismatch)=[format["%2 (%1)",name player, player],_this];publicVariable QGVAR(mismatch);_this spawn{_t=format["You are missing the following mod: %1",_this];diag_log text _t;sleep 2;if (CBA_display_ingame_warnings) then {player globalChat _t}}};';
[GVAR(versions_serv), {
_cfg = (configFile >> "CfgSettings" >> "CBA" >> "Versioning" >> _key);
_addon = if (isClass _cfg) then { if (isText (_cfg >> "main_addon")) then { getText (_cfg >> "main_addon") } else { _key + "_main" }; } else { _key + "_main" };
private _cfg = (configFile >> "CfgSettings" >> "CBA" >> "Versioning" >> _key);
private _addon = if (isClass _cfg) then { if (isText (_cfg >> "main_addon")) then { getText (_cfg >> "main_addon") } else { _key + "_main" }; } else { _key + "_main" };
// TODO: Make sensitive to level, if -2, do not check for mod
_str = _str + format['if !(isClass(configFile >> "CfgPatches" >> "%1"))exitWith{"%1" call _func};', _addon];
}] call CBA_fnc_hashEachPair;
Expand Down
Loading