y0014984 / Advanced-Equipment

Advanced Equipment is a Arma 3 mod, that brings equipment to life, like laptops and lamps.
Other
27 stars 10 forks source link

`ace_interact_menu_consolidateSingleChild` Setting prevents insertion of USB Drives #414

Closed mrschick closed 4 months ago

mrschick commented 7 months ago

When the "ACE Interaction Menu" setting called "Consolidate single child actions" (ace_interact_menu_consolidateSingleChild) is enabled, the following error occurs when trying to plug in a USB Drive. 20240219142407_1 As a result, the USB Drive can not be plugged in unless the setting is disabled. The ACE Interaction interface also somewhat bugs itself and remains in view despite releasing ⊞ Win, requiring going back to a previous node to unstick it, though that is probably just the way Ace reacts to an interaction's exception.

mrschick commented 7 months ago

Maybe #406 could fix this, I'll check it out if I find the time.

y0014984 commented 7 months ago

Interesting. I will have a look into it.

mrschick commented 7 months ago

Issue is also present in #406. It occurs at addons\flashdrive\functions\fnc_initInterface.sqf:57

private _condition = 
{
    params ["_target", "_player", "_params"];
    (_params select 0) params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];
    private _occupiedList = _target getVariable "AE3_USB_Interfaces_occupied";

    isNull (_occupiedList select _index);
};

Apparently when consolidateSingleChild is enabled, _index is filled with the USB Drive's full Config name, i.e: Item_FlashDisk_AE3_ID_1, instead of the index corresponding to the selected (unoccupied) interface.

mrschick commented 5 months ago

Got it.

Basically, when consolidateSingleChild is disabled, the condition is called with the _params parameter just containing data on the respective interface, like so:

[[1,"USB1",[-0.19,-0.028,-0.145],90,0,180]]

However, when consolidateSingleChild is enabled, the Drive's classname is prepended to the parameter, resulting in the following format:

["Item_FlashDisk_AE3_ID_1",[1,"USB1",[-0.19,-0.028,-0.145],90,0,180]]

I guess that's just an ACE quirk, will investigate further.

Because of this, (_params select 0) params in the condition's code will then parse _index = "Item_FlashDisk_AE3_ID_1", leading to the error in _occupiedList select _index.

params ["_target", "_player", "_params"];
(_params select 0) params ["_index", "_name", "_rel_pos", "_rot_yaw", "_rot_pitch", "_rot_roll"];
private _occupiedList = _target getVariable "AE3_USB_Interfaces_occupied";

isNull (_occupiedList select _index);

I found a fix, basically checking if the first element of _params is an Array and parsing either index 0 or 1 as interface data depending on that (detailed here in #406). It should always work, as when carrying more than 1 USB Drive, the action would not be consolidated.

Dystopian commented 5 months ago

I guess that's just an ACE quirk, will investigate further.

Indeed, child params are used with parent condition code. Please check if it's fixed with acemod/ACE3#9946.

mrschick commented 5 months ago

Can confirm that your PR fixes this issue, many thanks 👍🏻

mrschick commented 4 months ago

This has now been fixed publicly by ACE v3.17.1.