Skip to content

Commit 7c19350

Browse files
authored
Minor code improvements and optimizations (#226)
* Minor code improvements * appease the linter * optimize nametags a tiny bit * up required version
1 parent 6ea2597 commit 7c19350

File tree

6 files changed

+31
-46
lines changed

6 files changed

+31
-46
lines changed

addons/main/script_mod.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#define VERSION_AR MAJOR,MINOR,PATCHLVL,BUILD
99
#define VERSION_PLUGIN MAJOR.MINOR.PATCHLVL.BUILD
1010

11-
#define REQUIRED_VERSION 2.16
11+
#define REQUIRED_VERSION 2.18
1212

1313
#ifdef COMPONENT_BEAUTIFIED
1414
#define COMPONENT_NAME QUOTE(DUI - COMPONENT_BEAUTIFIED)

addons/nametags/XEH_postInit.sqf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
if !(hasInterface) exitWith {};
44

5-
GVAR(targetedFade) = 1;
6-
75
call FUNC(cacheLoop);
86

97
player setVariable [QGVAR(name), name player];

addons/nametags/functions/fnc_onDraw.sqf

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ if ((ctrlPosition _ctrl) isNotEqualTo _pos) then {
1010

1111
private _target = cursorObject;
1212
private _player = call CBA_fnc_currentUnit;
13+
private _targetedFade = 1;
1314

1415
if (GVAR(useLIS)) then {
1516
private _skipVicCheck = (netId _target) isEqualTo "1:0"; // only ever true when cursorObject returns the weapon of a
@@ -42,10 +43,7 @@ if (GVAR(useLIS)) then {
4243
} forEach _lis;
4344
};
4445

45-
if (isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _target}}) then {
46-
GVAR(targetedFade) = 1;
47-
} else {
48-
46+
if !(isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _target}}) then {
4947
private _effectiveCommander = effectiveCommander _target;
5048
if !(isNull _effectiveCommander) then {
5149
_target = _effectiveCommander;
@@ -59,8 +57,8 @@ if (isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _t
5957
_targetSide isEqualTo _playerSide;
6058
};
6159
if (_target isKindOf "AllVehicles" && {_areFriendly}) then {
62-
GVAR(targetedFade) = [_target, _player] call FUNC(calculateFadeValue);
63-
if (GVAR(targetedFade) < 1) then {
60+
_targetedFade = (([_target, _player] call FUNC(calculateFadeValue)) min 1) max 0;
61+
if (_targetedFade < 1) then {
6462
private _color = EGVAR(main,colors_custom) getVariable ["otherName", "#33FF00"]; // Other Group Default Color
6563
private _colorGroup = EGVAR(main,colors_custom) getVariable ["otherGroup", "#99D999"]; // Other Group Default Color
6664
if ((group _target) isEqualTo (group _player)) then {
@@ -93,17 +91,8 @@ if (isNull _target || {!(player call EFUNC(main,canHudBeShown)) || {unitIsUAV _t
9391
// TODO(joko): Add Extra Fade for Group?
9492
_ctrl ctrlSetStructuredText parseText (_data joinString "");
9593
};
96-
} else {
97-
GVAR(targetedFade) = 1;
9894
};
9995
};
10096

101-
GVAR(targetedFade) = (GVAR(targetedFade) min 1) max 0;
102-
103-
private _fadeIn = GVAR(targetedFade) <= ctrlFade _ctrl;
104-
_ctrl ctrlSetFade GVAR(targetedFade);
105-
if (_fadeIn) then {
106-
_ctrl ctrlCommit GVAR(fadeInTime);
107-
} else {
108-
_ctrl ctrlCommit GVAR(fadeOutTime);
109-
};
97+
_ctrl ctrlSetFade _targetedFade;
98+
_ctrl ctrlCommit ([GVAR(fadeOutTime), GVAR(fadeInTime)] select (_targetedFade <= ctrlFade _ctrl));

addons/radar/functions/fnc_cacheLoop.sqf

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ if (GVAR(syncGroup) && {isMultiplayer && {GVAR(sortType) isEqualTo "none" && {lo
1313

1414
// if both compass and namelist are not enabled, just remove the controls if there are any
1515
if !(diwako_dui_enable_compass || diwako_dui_namelist) exitWith {
16-
for "_i" from 0 to (count GVAR(namebox_lists)) do {
16+
{
1717
ctrlDelete ctrlParentControlsGroup (GVAR(namebox_lists) deleteAt 0);
18-
};
18+
} forEach GVAR(namebox_lists);
1919
"diwako_dui_namebox" cutRsc ["diwako_dui_RscNameBox","PLAIN", 0, true];
2020
};
2121

2222
_group = (group _player) getVariable [QGVAR(syncGroup), _group];
23-
if (diwako_dui_compass_hide_blip_alone_group && {(count _group) <= 1}) then {
23+
private _isAloneInGroup = (count _group) <= 1;
24+
if (diwako_dui_compass_hide_blip_alone_group && {_isAloneInGroup}) then {
2425
_group = [];
2526
};
2627

@@ -168,10 +169,10 @@ private _lists = GVAR(namebox_lists);
168169

169170
// delete all name list controls if not active
170171
if (!diwako_dui_namelist || {GVAR(namelist_hideWhenLeader) && (leader _player) isEqualTo _player}) exitWith {
171-
if ((count _lists) > 0) then {
172-
for "_i" from (count _lists) -1 to 0 step -1 do {
173-
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _i);
174-
};
172+
if (_lists isNotEqualTo []) then {
173+
{
174+
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _forEachIndex);
175+
} forEachReversed _lists;
175176
"diwako_dui_namebox" cutText ["","PLAIN"];
176177
};
177178
};
@@ -208,12 +209,10 @@ ctrlPosition _grpCtrl params ["", "", "", "_height"];
208209
private _curNameListHeight = (_height / pixelH) - ((15 * _uiScale) max 15);
209210

210211
// no need to show any names if you are alone in the group
211-
if (count _group <= 1) exitWith {
212-
if ((count _lists) > 0) then {
213-
for "_i" from (count _lists) -1 to 0 step -1 do {
214-
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _i);
215-
};
216-
};
212+
if (_isAloneInGroup) exitWith {
213+
{
214+
ctrlDelete ctrlParentControlsGroup (_lists deleteAt _forEachIndex);
215+
} forEachReversed _lists;
217216
};
218217
if !(ctrlShown _grpCtrl) then {
219218
_grpCtrl ctrlShow true;

addons/radar/functions/fnc_compassPFH.sqf

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ if !(diwako_dui_enable_compass) exitWith {
1414

1515
private _player = [] call CBA_fnc_currentUnit;
1616
private _grp = GVAR(group);
17-
private _pointers = GVAR(pointers);
1817

1918
if (diwako_dui_compass_hide_alone_group && {count (units group _player) <= 1}) exitWith {
2019
_compassCtrl ctrlShow false;
@@ -65,22 +64,22 @@ if ([_player] call EFUNC(main,canHudBeShown)) then {
6564
ctrlDelete _x;
6665
} forEach (_ctrls - _usedCtrls);
6766

68-
if (diwako_dui_compass_hide_blip_alone_group && { _grp isEqualTo (missionNamespace getVariable ["diwako_dui_special_track", []]) && {(count _usedCtrls) > 0}}) then {
67+
if (diwako_dui_compass_hide_blip_alone_group && {
68+
_grp isEqualTo (missionNamespace getVariable ["diwako_dui_special_track", []]) && {
69+
_usedCtrls isNotEqualTo []}}) then {
6970
_usedCtrls pushBack (([[_player], _display, _dir, _playerDir, _player, _ctrlGrp] call FUNC(displayUnitOnCompass)) select 0);
7071
};
7172
_ctrlGrp setVariable ["diwako_dui_ctrlArr", _usedCtrls];
7273

73-
if (_pointers isNotEqualTo []) then {
74-
for "_i" from (count _pointers) -1 to 0 step -1 do {
75-
(_pointers select _i) params [["_pointer", controlNull], "_pointerPos"];
76-
if (isNull _pointer) then {
77-
_pointers deleteAt _i;
78-
} else {
79-
_pointer ctrlSetAngle [(((_player getRelDir (_pointerPos)) - (_dir - _playerDir) ) mod 360), 0.5, 0.5, false];
80-
_pointer ctrlCommit 0;
81-
};
74+
{
75+
_x params [["_pointer", controlNull], "_pointerPos"];
76+
if (isNull _pointer) then {
77+
GVAR(pointers) deleteAt _forEachIndex;
78+
} else {
79+
_pointer ctrlSetAngle [(((_player getRelDir (_pointerPos)) - (_dir - _playerDir) ) mod 360), 0.5, 0.5, false];
80+
_pointer ctrlCommit 0;
8281
};
83-
};
82+
} forEachReversed GVAR(pointers);
8483

8584
if !(isNil "diwako_dui_custom_code") then {
8685
/*

tools/sqf_linter_LogChecker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import os
33

4-
defaultFalsePositives = 38 # Change 0 to Current number of false positives
4+
defaultFalsePositives = 42 # Change 0 to Current number of false positives
55
def main():
66
f = open("sqf.log", "r")
77
log = f.readlines()

0 commit comments

Comments
 (0)