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

DAGR / Interaction Menu / Repair - Fix overwriting globals #7990

Merged
merged 5 commits into from
Nov 8, 2020
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
1 change: 0 additions & 1 deletion addons/dagr/Dialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ class DAGR_Menu {

class DAGR_NEXT_Button : DAGR_Button {
idc = 266868;
action = QUOTE(DAGR_NEXT = true);
x = 0.60;
y = 0.65;
};
Expand Down
1 change: 0 additions & 1 deletion addons/dagr/functions/fnc_menuInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ GVAR(menuRun) = true;
GVAR(F1) = false;
GVAR(MENU_B) = false;
GVAR(SEL) = false;
DAGR_NEXT = false;
GVAR(RIGHT) = false;
GVAR(LEFT) = false;
GVAR(UP) = false;
Expand Down
1 change: 0 additions & 1 deletion addons/disarming/functions/fnc_disarmDropItems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ if (({((_x select 0) in _listOfItemsToRemove) && {(getNumber (configFile >> "Cfg
};
//Verify holder has mags unit had
if (!([_targetMagazinesStart, _targetMagazinesEnd, _holderMagazinesStart, _holderMagazinesEnd] call FUNC(verifyMagazinesMoved))) then {
ERR = [_targetMagazinesStart, _targetMagazinesEnd, _holderMagazinesStart, _holderMagazinesEnd];
_holder setVariable [QGVAR(holderInUse), false];
[_caller, _target, "Debug: Crate Magazines not in holder"] call FUNC(eventTargetFinish);
};
Expand Down
10 changes: 8 additions & 2 deletions addons/interact_menu/functions/fnc_keyUp.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
};

if (GVAR(actionSelected)) then {
this = GVAR(selectedTarget);

private _player = ACE_Player;
private _target = GVAR(selectedTarget);

Expand All @@ -38,13 +36,21 @@ if (GVAR(actionSelected)) then {

// Check the action conditions
private _actionData = GVAR(selectedAction) select 0;

// Use global variable this for action condition and action code
private _savedThis = this;
this = GVAR(selectedTarget);

if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
// Call the statement
[_target, _player, _actionData select 6] call (_actionData select 3);

// Clear the conditions caches again if the action was performed
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
};

// Restore this variable
this = _savedThis;
};

["ace_interactMenuClosed", [GVAR(openedMenuType)]] call CBA_fnc_localEvent;
Expand Down
8 changes: 7 additions & 1 deletion addons/interact_menu/functions/fnc_render.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ if (GVAR(openedMenuType) >= 0) then {
};
};
if (_runOnHover) then {
this = GVAR(selectedTarget);
private _player = ACE_Player;
private _target = GVAR(selectedTarget);

// Clear the conditions caches
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;

// Use global variable this for action condition and action code
private _savedThis = this;
this = GVAR(selectedTarget);

// Check the action conditions
private _actionData = GVAR(selectedAction) select 0;
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
Expand All @@ -107,6 +110,9 @@ if (GVAR(openedMenuType) >= 0) then {
// Clear the conditions caches again if the action was performed
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
};

// Restore this variable
this = _savedThis;
};
};
};
Expand Down
23 changes: 21 additions & 2 deletions addons/interact_menu/functions/fnc_userActions_getHouseActions.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,34 @@ private _fnc_getMemPointOffset = {
private _fnc_userAction_Statement = {
params ["_target", "_player", "_variable"];
_variable params ["_actionStatement", "_actionCondition"];

// Use global variable this for action condition and action code
private _savedThis = this;
this = _target getVariable [QGVAR(building), objNull];

call _actionStatement;

// Restore this variable
this = _savedThis;
};

private _fnc_userAction_Condition = {
params ["_target", "_player", "_variable"];
_variable params ["_actionStatement", "_actionCondition"];

private _building = _target getVariable [QGVAR(building), objNull];
if (isNull _building) exitWith {false};

// Use global variable this for action condition and action code
private _savedThis = this;
this = _target getVariable [QGVAR(building), objNull];
if (isNull this) exitWith {false};
call _actionCondition;

private _result = call _actionCondition;

// Restore this variable
this = _savedThis;

_result
};

private _configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions";
Expand Down
11 changes: 9 additions & 2 deletions addons/repair/functions/fnc_normalizeHitPoints.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ TRACE_2("",_realHitPoints,_dependentHitPoints);
if (_dependentHitPoints isEqualTo []) exitWith {};


// Define global variables
Total = damage _vehicle;
// Define global variables and save original values
private _savedGlobals = [["total", total]];
total = damage _vehicle;
{
_savedGlobals pushBack [_x, missionNamespace getVariable _x];
missionNamespace setVariable [_x, _vehicle getHitPointDamage _x];
} forEach _realHitPoints;

Expand All @@ -58,3 +60,8 @@ Total = damage _vehicle;
TRACE_2("setting depend hitpoint", _x, _damage);
_vehicle setHitPointDamage [_x, _damage];
} forEach _dependentHitPoints;

// Restore global variables
{
missionNamespace setVariable _x;
} forEach _savedGlobals;