Skip to content

Commit

Permalink
Cleaner implementation && more coherent with analog rearm event
Browse files Browse the repository at this point in the history
  • Loading branch information
TACHarsis committed Feb 17, 2023
1 parent de82b06 commit 9e32300
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
14 changes: 6 additions & 8 deletions addons/refuel/functions/fnc_initSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@
* Public: No
*/

if (!hasInterface) exitWith {};

params ["_source"];
TRACE_2("init",_source,typeOf _source);

if (hasInterface) then {
[_source, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject);
{
[_source, 0, ["ACE_MainActions", QGVAR(Refuel)], _x] call EFUNC(interact_menu,addActionToObject);
} forEach GVAR(actions);
};

[QGVAR(fuelSourceInitialized), [_source]] call CBA_fnc_localEvent;
[_source, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToObject);
{
[_source, 0, ["ACE_MainActions", QGVAR(Refuel)], _x] call EFUNC(interact_menu,addActionToObject);
} forEach GVAR(actions);
2 changes: 1 addition & 1 deletion addons/refuel/functions/fnc_makeJerryCan.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ _target setVariable [QGVAR(source), _target];
_target setVariable [QGVAR(capacity), _fuelAmount];

if (isServer) then {
[_target, _fuelAmount] call FUNC(setFuel); // has global effects
[_target, _fuelAmount] call FUNC(setFuel); // has global effects
[QVAR(jerryCanInitalized), [_target]] call CBA_fnc_globalevent;
};

Expand Down
12 changes: 7 additions & 5 deletions addons/refuel/functions/fnc_makeSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ if (
_source setVariable [QGVAR(hooks), _hooks, true];
};

// check if menu already exists
if (_fuelCargoConfig != 0 || {!isNil {_source getVariable QGVAR(initSource_jipID)}}) exitWith {};
// only add if menu doesn't already exist
if (!(_fuelCargoConfig != 0 && {!isNil {_source getVariable QGVAR(initSource_jipID)}})) then {
private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP;
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
_source setVariable [QGVAR(initSource_jipID), _jipID];
};

private _jipID = [QGVAR(initSource), [_source]] call CBA_fnc_globalEventJIP;
[_jipID, _source] call CBA_fnc_removeGlobalEventJIP;
_source setVariable [QGVAR(initSource_jipID), _jipID];
[QGVAR(sourceInitialized), [_source]] call CBA_fnc_globalEvent;
2 changes: 1 addition & 1 deletion docs/wiki/framework/refuel-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,5 @@ The jerry can will now have a volume of 200 liters.
| Name | Arguments | Global? | Added in |
| ------------- | ------------- | ------------- |
| ace_refuel_fuelSourceInitialized | Fuel source (OBJECT), items (BOOL or ARRAY) | No | 3.16.0 |
| ace_refuel_sourceInitialized | Fuel source (OBJECT), items (BOOL or ARRAY) | Yes | 3.16.0 |
| ace_refuel_jerryCanInitalized | Jerry can (OBJECT) | Yes | 3.16.0 |

0 comments on commit 9e32300

Please sign in to comment.