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

Common - Cleanup DEFAULT_PARAM, _this #1706

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
20 changes: 10 additions & 10 deletions addons/ai/fnc_taskPatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ _position = _position call CBA_fnc_getPos;
} forEach units _group;

// Can pass parameters straight through to addWaypoint
_this =+ _this;
_this set [2,-1];
if (count _this > 3) then {
_this deleteAt 3;
private _args = +_this;
_args set [2,-1];
if (count _args > 3) then {
_args deleteAt 3;
};

// Using angles create better patrol patterns
Expand All @@ -71,12 +71,12 @@ for "_i" from 1 to _count do {
// Alternate sides of circle & modulate offset
private _theta = (_i % 2) * 180 + sin (deg (_step * _i)) * _offset + _step * _i;

_this set [1, _position getPos [_rad, _theta]];
_this call CBA_fnc_addWaypoint;
_args set [1, _position getPos [_rad, _theta]];
_args call CBA_fnc_addWaypoint;
};

// Close the patrol loop
_this set [1, _position];
_this set [2, _radius];
_this set [3, "CYCLE"];
_this call CBA_fnc_addWaypoint;
_args set [1, _position];
_args set [2, _radius];
_args set [3, "CYCLE"];
_args call CBA_fnc_addWaypoint;
4 changes: 1 addition & 3 deletions addons/common/fnc_getTerrainProfile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ Author:
---------------------------------------------------------------------------- */

params ["_posA","_posB"];
params ["_posA","_posB", ["_resolution", 10]];
_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);

private _angle = [_posA, _posB] call BIS_fnc_dirTo;
private _2Ddistance = [_posA, _posB] call BIS_fnc_distance2D;

Expand Down
6 changes: 3 additions & 3 deletions addons/diagnostic/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ if (getMissionConfigValue ["EnableTargetDebug", 0] == 1 || {getNumber (configFil
private _timeStart = diag_tickTime;
private _returnString = _statementText call {
private ["_clientID", "_statementText", "_varName", "_timeStart", "_x"]; // prevent these variables from being overwritten
_this = ([nil] apply compile _this) select 0;
if (isNil "_this") exitWith {"<any>"};
str _this
private _str = ([nil] apply compile _this) select 0;
if (isNil "_str") exitWith {"<any>"};
str _str
};
_returnString = _returnString select [0, 1000]; // limit string length
private _duration = diag_tickTime - _timeStart;
Expand Down
3 changes: 1 addition & 2 deletions addons/diagnostic/fnc_test.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ Author:

// ----------------------------------------------------------------------------

DEFAULT_PARAM(0,_addon,"cba");
DEFAULT_PARAM(1,_component,"main");
params [["_addon", "cba"], ["_component", "main"]];

LOG('===== STARTING TESTS =====');

Expand Down
8 changes: 5 additions & 3 deletions addons/ui/fnc_notify.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@ if (canSuspend) exitWith {

if (!hasInterface) exitWith {};

private _args = _this;

// compose structured text
if !(_this isEqualType []) then {
_this = [_this];
_args = [_this];
};

if !(_this select 0 isEqualType []) then {
_this = [_this];
_args = [_this];
};

private _composition = [];
Expand Down Expand Up @@ -83,7 +85,7 @@ private _skippable = false;
} else {
_composition pushBack parseText format ["<t align='center' size='%2' color='%3'>%1</t>", _text, _size, _color];
};
} forEach _this;
} forEach _args;

_composition deleteAt 0;

Expand Down
4 changes: 2 additions & 2 deletions addons/ui/fnc_openItemContextMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ _list setVariable [QFUNC(activate), {

// Call statement and safe check return value.
private _keepOpen = [nil] apply {
private _this = [_this, _statement];
private _args = [_this, _statement];
private ["_list", "_index", "_condition", "_statement", "_consume"];
(_this select 0) call (_this select 1) // return
(_args select 0) call (_args select 1) // return
} param [0, false] isEqualTo true;

// If statement returned true, keep context menu open, otherwise close.
Expand Down