mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
DAGR / Interaction Menu / Repair - Fix overwriting globals (#7990)
* Remove global DAGR_NEXT variable * Remove global ERR variable * Fix overwriting global this variable * Fix overwriting global total and hitpoint variables * fix condition Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
parent
5d1aa28419
commit
119450f4e9
@ -201,7 +201,6 @@ class DAGR_Menu {
|
|||||||
|
|
||||||
class DAGR_NEXT_Button : DAGR_Button {
|
class DAGR_NEXT_Button : DAGR_Button {
|
||||||
idc = 266868;
|
idc = 266868;
|
||||||
action = QUOTE(DAGR_NEXT = true);
|
|
||||||
x = 0.60;
|
x = 0.60;
|
||||||
y = 0.65;
|
y = 0.65;
|
||||||
};
|
};
|
||||||
|
@ -596,7 +596,6 @@ GVAR(menuRun) = true;
|
|||||||
GVAR(F1) = false;
|
GVAR(F1) = false;
|
||||||
GVAR(MENU_B) = false;
|
GVAR(MENU_B) = false;
|
||||||
GVAR(SEL) = false;
|
GVAR(SEL) = false;
|
||||||
DAGR_NEXT = false;
|
|
||||||
GVAR(RIGHT) = false;
|
GVAR(RIGHT) = false;
|
||||||
GVAR(LEFT) = false;
|
GVAR(LEFT) = false;
|
||||||
GVAR(UP) = false;
|
GVAR(UP) = false;
|
||||||
|
@ -92,7 +92,6 @@ if (({((_x select 0) in _listOfItemsToRemove) && {(getNumber (configFile >> "Cfg
|
|||||||
};
|
};
|
||||||
//Verify holder has mags unit had
|
//Verify holder has mags unit had
|
||||||
if (!([_targetMagazinesStart, _targetMagazinesEnd, _holderMagazinesStart, _holderMagazinesEnd] call FUNC(verifyMagazinesMoved))) then {
|
if (!([_targetMagazinesStart, _targetMagazinesEnd, _holderMagazinesStart, _holderMagazinesEnd] call FUNC(verifyMagazinesMoved))) then {
|
||||||
ERR = [_targetMagazinesStart, _targetMagazinesEnd, _holderMagazinesStart, _holderMagazinesEnd];
|
|
||||||
_holder setVariable [QGVAR(holderInUse), false];
|
_holder setVariable [QGVAR(holderInUse), false];
|
||||||
[_caller, _target, "Debug: Crate Magazines not in holder"] call FUNC(eventTargetFinish);
|
[_caller, _target, "Debug: Crate Magazines not in holder"] call FUNC(eventTargetFinish);
|
||||||
};
|
};
|
||||||
|
@ -25,8 +25,6 @@ if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (GVAR(actionSelected)) then {
|
if (GVAR(actionSelected)) then {
|
||||||
this = GVAR(selectedTarget);
|
|
||||||
|
|
||||||
private _player = ACE_Player;
|
private _player = ACE_Player;
|
||||||
private _target = GVAR(selectedTarget);
|
private _target = GVAR(selectedTarget);
|
||||||
|
|
||||||
@ -38,6 +36,11 @@ if (GVAR(actionSelected)) then {
|
|||||||
|
|
||||||
// Check the action conditions
|
// Check the action conditions
|
||||||
private _actionData = GVAR(selectedAction) select 0;
|
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 {
|
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
|
||||||
// Call the statement
|
// Call the statement
|
||||||
[_target, _player, _actionData select 6] call (_actionData select 3);
|
[_target, _player, _actionData select 6] call (_actionData select 3);
|
||||||
@ -45,6 +48,9 @@ if (GVAR(actionSelected)) then {
|
|||||||
// Clear the conditions caches again if the action was performed
|
// Clear the conditions caches again if the action was performed
|
||||||
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
|
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Restore this variable
|
||||||
|
this = _savedThis;
|
||||||
};
|
};
|
||||||
|
|
||||||
["ace_interactMenuClosed", [GVAR(openedMenuType)]] call CBA_fnc_localEvent;
|
["ace_interactMenuClosed", [GVAR(openedMenuType)]] call CBA_fnc_localEvent;
|
||||||
|
@ -91,13 +91,16 @@ if (GVAR(openedMenuType) >= 0) then {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
if (_runOnHover) then {
|
if (_runOnHover) then {
|
||||||
this = GVAR(selectedTarget);
|
|
||||||
private _player = ACE_Player;
|
private _player = ACE_Player;
|
||||||
private _target = GVAR(selectedTarget);
|
private _target = GVAR(selectedTarget);
|
||||||
|
|
||||||
// Clear the conditions caches
|
// Clear the conditions caches
|
||||||
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
|
[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
|
// Check the action conditions
|
||||||
private _actionData = GVAR(selectedAction) select 0;
|
private _actionData = GVAR(selectedAction) select 0;
|
||||||
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
|
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
|
||||||
@ -107,6 +110,9 @@ if (GVAR(openedMenuType) >= 0) then {
|
|||||||
// Clear the conditions caches again if the action was performed
|
// Clear the conditions caches again if the action was performed
|
||||||
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
|
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Restore this variable
|
||||||
|
this = _savedThis;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -41,15 +41,34 @@ private _fnc_getMemPointOffset = {
|
|||||||
private _fnc_userAction_Statement = {
|
private _fnc_userAction_Statement = {
|
||||||
params ["_target", "_player", "_variable"];
|
params ["_target", "_player", "_variable"];
|
||||||
_variable params ["_actionStatement", "_actionCondition"];
|
_variable params ["_actionStatement", "_actionCondition"];
|
||||||
|
|
||||||
|
// Use global variable this for action condition and action code
|
||||||
|
private _savedThis = this;
|
||||||
this = _target getVariable [QGVAR(building), objNull];
|
this = _target getVariable [QGVAR(building), objNull];
|
||||||
|
|
||||||
call _actionStatement;
|
call _actionStatement;
|
||||||
|
|
||||||
|
// Restore this variable
|
||||||
|
this = _savedThis;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _fnc_userAction_Condition = {
|
private _fnc_userAction_Condition = {
|
||||||
params ["_target", "_player", "_variable"];
|
params ["_target", "_player", "_variable"];
|
||||||
_variable params ["_actionStatement", "_actionCondition"];
|
_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];
|
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";
|
private _configPath = configFile >> "CfgVehicles" >> _typeOfBuilding >> "UserActions";
|
||||||
|
@ -46,9 +46,11 @@ TRACE_2("",_realHitPoints,_dependentHitPoints);
|
|||||||
if (_dependentHitPoints isEqualTo []) exitWith {};
|
if (_dependentHitPoints isEqualTo []) exitWith {};
|
||||||
|
|
||||||
|
|
||||||
// Define global variables
|
// Define global variables and save original values
|
||||||
Total = damage _vehicle;
|
private _savedGlobals = [["total", total]];
|
||||||
|
total = damage _vehicle;
|
||||||
{
|
{
|
||||||
|
_savedGlobals pushBack [_x, missionNamespace getVariable _x];
|
||||||
missionNamespace setVariable [_x, _vehicle getHitPointDamage _x];
|
missionNamespace setVariable [_x, _vehicle getHitPointDamage _x];
|
||||||
} forEach _realHitPoints;
|
} forEach _realHitPoints;
|
||||||
|
|
||||||
@ -58,3 +60,8 @@ Total = damage _vehicle;
|
|||||||
TRACE_2("setting depend hitpoint", _x, _damage);
|
TRACE_2("setting depend hitpoint", _x, _damage);
|
||||||
_vehicle setHitPointDamage [_x, _damage];
|
_vehicle setHitPointDamage [_x, _damage];
|
||||||
} forEach _dependentHitPoints;
|
} forEach _dependentHitPoints;
|
||||||
|
|
||||||
|
// Restore global variables
|
||||||
|
{
|
||||||
|
missionNamespace setVariable _x;
|
||||||
|
} forEach _savedGlobals;
|
||||||
|
Loading…
Reference in New Issue
Block a user