Skip to content

Commit

Permalink
params
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Oct 19, 2024
1 parent fc0ea37 commit 3d27aad
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions addons/common/fnc_directCall.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Author:
commy2
---------------------------------------------------------------------------- */

params [["_CBA_code", {}, [{}]], ["_this", []]];
params [["_CBA_code", {}, [{}]], ["_args", []]];

private "_CBA_return";

isNil {
// Wrap the _CBA_code in an extra call block to prevent problems with exitWith and apply
//IGNORE_PRIVATE_WARNING ["_x"];
_CBA_return = ([_x] apply {call _CBA_code}) select 0;
_CBA_return = ([_x] apply {_args call _CBA_code}) select 0;
};

if (!isNil "_CBA_return") then {_CBA_return};
10 changes: 5 additions & 5 deletions addons/ui/fnc_openItemContextMenu.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ private _unit = call CBA_fnc_currentUnit;
// Execute context menu option statement on selection.
_list setVariable [QFUNC(activate), {
params ["_list", "_index"];
_list getVariable (_list lbData _index) params ["_condition", "_statement", "_consume", "_this"];
_list getVariable (_list lbData _index) params ["_condition", "_statement", "_consume", "_args"];

if (_this call _condition) then {
if (_args call _condition) then {
if (_consume) then {
params ["_unit", "_container", "_item", "_slot"];
_args params ["_unit", "_container", "_item", "_slot"];

if !([_unit, _item, _slot, _container] call CBA_fnc_consumeItem) then {
ERROR_2("Cannot consume item %1 from %2.",_item,_slot);
Expand All @@ -125,7 +125,7 @@ _list setVariable [QFUNC(activate), {

// Call statement and safe check return value.
private _keepOpen = [nil] apply {
private _args = [_this, _statement];
private _args = [_args, _statement];
private ["_list", "_index", "_condition", "_statement", "_consume"];
(_args select 0) call (_args select 1) // return
} param [0, false] isEqualTo true;
Expand All @@ -135,7 +135,7 @@ _list setVariable [QFUNC(activate), {
// Keep focus to prevent auto closing.
ctrlSetFocus _list;
} else {
[{ctrlDelete _this}, _list] call CBA_fnc_execNextFrame;
[{ctrlDelete _args}, _list] call CBA_fnc_execNextFrame;
};
};
}];
Expand Down
24 changes: 12 additions & 12 deletions addons/xeh/fnc_init.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,33 @@ Author:
commy2
---------------------------------------------------------------------------- */

params ["_this"];
params ["_object"];

if (_this call CBA_fnc_isTerrainObject) exitWith {
INFO_2("Abort init event for terrain object %1. Class: %2.",_this,typeOf _this);
if (_object call CBA_fnc_isTerrainObject) exitWith {
INFO_2("Abort init event for terrain object %1. Class: %2.",_object,typeOf _object);
};

if !(ISINITIALIZED(_this)) then {
SETINITIALIZED(_this);
if !(ISINITIALIZED(_object)) then {
SETINITIALIZED(_object);

// run Init
{
[_this] call _x;
} forEach (_this getVariable QGVAR(init));
[_object] call _x;
} forEach (_object getVariable QGVAR(init));

// run InitPost or put on stack
if (SLX_XEH_MACHINE select 8) then {
[{
{
[_this] call _x;
} forEach (_this getVariable QGVAR(initPost));
}, _this] call CBA_fnc_execNextFrame;
[_object] call _x;
} forEach (_object getVariable QGVAR(initPost));
}, _object] call CBA_fnc_execNextFrame;
} else {
GVAR(initPostStack) pushBack _this;
GVAR(initPostStack) pushBack _object;
};

// fix for respawnVehicle clearing the object namespace
_this addEventHandler ["Respawn", {
_object addEventHandler ["Respawn", {
params ["_vehicle", "_wreck"];

if (ISINITIALIZED(_vehicle)) exitWith {}; // Exit if unit respawned normaly with copied variables (e.g. humans)
Expand Down
6 changes: 3 additions & 3 deletions addons/xeh/fnc_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ isNil {

// do InitPost
{
_x params ["_this"];
_x params ["_object"];

{
[_this] call _x;
} forEach (_this getVariable QGVAR(initPost));
[_object] call _x;
} forEach (_object getVariable QGVAR(initPost));
} forEach GVAR(initPostStack);

GVAR(initPostStack) = nil;
Expand Down

0 comments on commit 3d27aad

Please sign in to comment.