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

Refuel - Add enable setting #7613

Merged
merged 30 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
bc1429d
Add enable setting
Dystopian Mar 25, 2020
48473e1
Exclude man class init
Dystopian Apr 6, 2020
5192098
Fix multiplayer terrain pump fuel sync
Dystopian Apr 8, 2020
5a9518c
Merge remote-tracking branch 'upstream/master' into refuel-no-compat
Dystopian Apr 9, 2020
8b386c3
Add terrain pumps positions
Dystopian Apr 11, 2020
980fb37
Add vanilla fuel cargo restoring before destroying
Dystopian Apr 12, 2020
9c231a3
Merge remote-tracking branch 'upstream/master' into refuel-no-compat
Dystopian Apr 22, 2020
3887085
Add Livonia positions by bux
Dystopian Apr 22, 2020
3057229
Fix terrain pumps destruction
Dystopian Apr 23, 2020
8bbdf6a
Improve settings init
Dystopian Apr 25, 2020
f842d22
Fix double settings category
Dystopian Apr 25, 2020
a3c0667
Check enabled var in public functions
Dystopian Apr 26, 2020
3875034
Fix fnc_makeSource
Dystopian Apr 26, 2020
37b9144
Handle recent CUP Terrains changes
Dystopian Oct 3, 2020
49d3fe7
Merge remote-tracking branch 'upstream/master' into refuel-no-compat
Dystopian Jan 13, 2021
c906559
Merge remote-tracking branch 'upstream/master' into refuel-no-compat
Dystopian Mar 6, 2021
0684072
Merge branch 'master' into pr/7613
johnb432 Nov 21, 2023
d8c2929
Update includes
johnb432 Nov 21, 2023
213c733
Fix issues introduced in #9133
johnb432 Nov 21, 2023
c15483c
Change warning
Dystopian Nov 21, 2023
636118e
Merge branch 'master' into pr/7613
johnb432 Mar 25, 2024
be6a7a3
Optimisations and cleanup
johnb432 Mar 25, 2024
a4cb5ba
Add init debug trace
Dystopian Mar 25, 2024
f3f8dac
compileScript in dev
LinkIsGrim Mar 26, 2024
02a186e
yoda conditions & DFUNC macro
LinkIsGrim Mar 26, 2024
bf0e594
Wait until CBA settings are ready
johnb432 Mar 26, 2024
7fbd41a
Update Chernarus 2020 and add more maps configs
Dystopian Mar 27, 2024
4992453
Remove vanilla fuel cargo restoring before destroying
Dystopian Apr 3, 2024
bf89609
Merge branch 'master' into pr/7613
johnb432 Apr 4, 2024
c040fe4
Merge branch 'master' into pr/7613
johnb432 Apr 28, 2024
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
7 changes: 6 additions & 1 deletion addons/refuel/Cfg3DEN.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#define GET_NUMBER(config,default) (if (isNumber (config)) then {getNumber (config)} else {default})
#define GET_NUMBER_GREATER_ZERO(config,default) (if (0 < getNumber (config)) then {getNumber (config)} else {default})
#define GET_1ST_ARRAY(config) (if (isArray (config)) then {getArray (config) select 0} else {[ARR_3(0,0,0)]})

#define DEFAULT_FUELCARGO GET_NUMBER(configFile >> 'CfgVehicles' >> typeOf _this >> QQGVAR(fuelCargo),REFUEL_DISABLED_FUEL)
#define DEFAULT_FUELCARGO \
GET_NUMBER(\
configFile >> 'CfgVehicles' >> typeOf _this >> QQGVAR(fuelCargo),\
GET_NUMBER_GREATER_ZERO(configFile >> 'CfgVehicles' >> typeOf _this >> 'transportFuel',REFUEL_DISABLED_FUEL)\
)
#define DEFAULT_HOOKS GET_1ST_ARRAY(configFile >> 'CfgVehicles' >> typeOf _this >> QQGVAR(hooks))

class Cfg3DEN {
Expand Down
40 changes: 13 additions & 27 deletions addons/refuel/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define XEH_INHERITED class EventHandlers {class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};}
johnb432 marked this conversation as resolved.
Show resolved Hide resolved

#define MACRO_NOZZLE_ACTIONS \
class ACE_Actions { \
class ACE_MainActions { \
Expand Down Expand Up @@ -71,10 +73,7 @@ class CfgVehicles {

class ThingX;
class GVAR(fuelNozzle): ThingX {
class EventHandlers {
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
};

XEH_INHERITED;
MACRO_NOZZLE_ACTIONS
displayName = QGVAR(fuelNozzle);
scope = 1;
Expand Down Expand Up @@ -245,12 +244,6 @@ class CfgVehicles {
GVAR(hooks)[] = {{0.38,-3.17,-.7},{-0.41,-3.17,-.7}};
GVAR(fuelCargo) = 2000;
};
class C_Van_01_fuel_F: Van_01_fuel_base_F {
transportFuel = 0; //1k
};
class I_G_Van_01_fuel_F: Van_01_fuel_base_F {
transportFuel = 0; //1k
};

class Tank_F: Tank {
GVAR(fuelCapacity) = 1200;
Expand All @@ -265,7 +258,6 @@ class CfgVehicles {
class B_APC_Tracked_01_base_F: APC_Tracked_01_base_F {};

class B_APC_Tracked_01_CRV_F: B_APC_Tracked_01_base_F {
transportFuel = 0; //3k
GVAR(hooks)[] = {{-1.08,-4.81,-.8}};
GVAR(fuelCargo) = 1000;
};
Expand Down Expand Up @@ -372,7 +364,6 @@ class CfgVehicles {

// Vanilla fuel vehicles
class Truck_02_fuel_base_F: Truck_02_base_F {
transportFuel = 0; //3k
GVAR(hooks)[] = {{0.99,-3.47,-0.67},{-1.04,-3.47,-0.67}};
GVAR(fuelCargo) = 10000;
};
Expand All @@ -381,13 +372,11 @@ class CfgVehicles {
};

class B_Truck_01_fuel_F: B_Truck_01_mover_F {
transportFuel = 0; //3k
GVAR(hooks)[] = {{.28,-4.99,-.3},{-.25,-4.99,-.3}};
GVAR(fuelCargo) = 10000;
};

class O_Truck_03_fuel_F: Truck_03_base_F {
transportFuel = 0; //3k
GVAR(hooks)[] = {{1.3,-1.59,-.62},{-1.16,-1.59,-.62}};
GVAR(fuelCargo) = 10000;
};
Expand All @@ -401,20 +390,17 @@ class CfgVehicles {

class Pod_Heli_Transport_04_base_F: Slingload_base_F {};
class Land_Pod_Heli_Transport_04_fuel_F: Pod_Heli_Transport_04_base_F {
transportFuel = 0; //3k
GVAR(hooks)[] = {{-1.49,1.41,-.3}};
GVAR(fuelCargo) = 10000;
};

class Slingload_01_Base_F: Slingload_base_F {};
class B_Slingload_01_Fuel_F: Slingload_01_Base_F {
transportFuel = 0; //3k
GVAR(hooks)[] = {{0.55,3.02,-0.5},{-0.52,3.02,-0.5}};
GVAR(fuelCargo) = 10000;
};

class O_Heli_Transport_04_fuel_F: Heli_Transport_04_base_F {
transportFuel = 0; //3k
GVAR(hooks)[] = {{-1.52,1.14,-1.18}};
GVAR(fuelCargo) = 10000;
};
Expand All @@ -431,11 +417,7 @@ class CfgVehicles {
};
};
class Land_StorageBladder_01_F: StorageBladder_base_F {
class EventHandlers {
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {};
};

transportFuel = 0; //60k
XEH_INHERITED;
GVAR(hooks)[] = {{-3.35,2.45,0.17}};
GVAR(fuelCargo) = 60000;
};
Expand All @@ -451,34 +433,38 @@ class CfgVehicles {
};
};
class Land_FlexibleTank_01_F: FlexibleTank_base_F {
transportFuel = 0; //300
GVAR(hooks)[] = {{0, 0, 0.5}};
GVAR(fuelCargo) = 300;
};

// Vanilla buildings
class Land_Fuelstation_Feed_F: House_Small_F {
transportFuel = 0; //50k
XEH_INHERITED;
GVAR(hooks)[] = {{0,0,-0.5}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
};

class Land_fs_feed_F: House_Small_F {
transportFuel = 0; //50k
XEH_INHERITED;
GVAR(hooks)[] = {{-0.4,0.022,-.23}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
};

class Land_FuelStation_01_pump_F: House_F {
transportFuel = 0; //50k
XEH_INHERITED;
GVAR(hooks)[] = {{0, 0.4, -0.5}, {0, -0.4, -0.5}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
};
class Land_FuelStation_01_pump_malevil_F: House_F {
transportFuel = 0; //50k
XEH_INHERITED;
GVAR(hooks)[] = {{0, 0.4, -0.5}, {0, -0.4, -0.5}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
};
class Land_FuelStation_03_pump_F: House_F {
XEH_INHERITED;
GVAR(hooks)[] = {{0,0,-0.5}};
GVAR(fuelCargo) = REFUEL_INFINITE_FUEL;
};

// Helper object for non-AllVehicles objects
class GVAR(helper): Helicopter_Base_F {
Expand Down
28 changes: 23 additions & 5 deletions addons/refuel/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
#include "script_component.hpp"
if (!GVAR(enabled)) exitWith {};
johnb432 marked this conversation as resolved.
Show resolved Hide resolved

["All", "InitPost", {
Dystopian marked this conversation as resolved.
Show resolved Hide resolved
params ["_vehicle"];
if (!local _vehicle) exitWith {};

if (getNumber (configFile >> "CfgVehicles" >> typeOf _vehicle >> "transportFuel") != 0) then {
_vehicle setFuelCargo 0;
};
}, true, [], true] call CBA_fnc_addClassEventHandler;

private _cacheRefuelClasses = call (uiNamespace getVariable [QGVAR(cacheRefuelClasses), {[[],[]]}]);
_cacheRefuelClasses params [["_staticClasses", [], [[]]], ["_dynamicClasses", [], [[]]]];

if (isServer) then {
addMissionEventHandler ["HandleDisconnect", {call FUNC(handleDisconnect)}];

private _worldSize = worldSize;
private _worldCenter = [_worldSize / 2, _worldSize / 2];
{
{
_x setFuelCargo 0;
} forEach (_worldCenter nearObjects [_x, _worldSize]);
} forEach _staticClasses;
};

[QGVAR(initSource), LINKFUNC(initSource)] call CBA_fnc_addEventHandler;
Expand Down Expand Up @@ -62,9 +83,6 @@ GVAR(actions) = [
];

// init menu for config refuel vehicles
private _cacheRefuelClasses = call (uiNamespace getVariable [QGVAR(cacheRefuelClasses), {[[],[]]}]);
_cacheRefuelClasses params [["_staticClasses", [], [[]]], ["_dynamicClasses", [], [[]]]];

{
private _className = _x;
[_className, 0, ["ACE_MainActions"], GVAR(mainAction)] call EFUNC(interact_menu,addActionToClass);
Expand All @@ -87,9 +105,9 @@ _cacheRefuelClasses params [["_staticClasses", [], [[]]], ["_dynamicClasses", []
addMissionEventHandler ["Draw3D", {
private _source = cursorObject;
private _cfgPos = getArray (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(hooks));
private _dynPos = _source getVariable [QGVAR(hooks), []];
private _dynPos = _source getVariable [QGVAR(hooks), _cfgPos];
{
drawIcon3D ["\a3\ui_f\data\gui\cfg\hints\icon_text\group_1_ca.paa", [1,1,1,1], _source modelToWorldVisual _x, 1, 1, 0, format ["Hook %1", _forEachIndex]];
} forEach ([_dynPos, _cfgPos] select (_dynPos isEqualTo []));
} forEach _dynPos;
}];
#endif
5 changes: 3 additions & 2 deletions addons/refuel/XEH_preStart.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ private _staticClasses = [];
private _dynamicClasses = [];

{
private _fuelCargo = getNumber (_x >> QGVAR(fuelCargo));
private _transportFuel = getNumber (_x >> "transportFuel");
private _fuelCargo = [_x >> QGVAR(fuelCargo), "NUMBER", _transportFuel] call CBA_fnc_getConfigEntry;
if (_fuelCargo > 0 || {_fuelCargo == REFUEL_INFINITE_FUEL}) then {
private _sourceClass = configName _x;
// check if we can use actions with inheritance
if (
!isText (_x >> "EventHandlers" >> "CBA_Extended_EventHandlers" >> "init") // addActionToClass relies on XEH init
|| {configName _x isKindOf "Static"} // CBA_fnc_addClassEventHandler doesn't support "Static" class
|| {_sourceClass isKindOf "Static"} // CBA_fnc_addClassEventHandler doesn't support "Static" class
) then {
if (2 == getNumber (_x >> "scope")) then {
_staticClasses pushBackUnique _sourceClass;
Expand Down
4 changes: 3 additions & 1 deletion addons/refuel/functions/fnc_getFuel.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ if (isNull _source) exitWith {0};
private _fuel = _source getVariable QGVAR(currentFuelCargo);

if (isNil "_fuel") then {
_fuel = getNumber (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(fuelCargo));
private _cfg = configFile >> "CfgVehicles" >> typeOf _source;
private _transportFuel = getNumber (_cfg >> "transportFuel");
_fuel = [_cfg >> QGVAR(fuelCargo), "NUMBER", _transportFuel] call CBA_fnc_getConfigEntry;
_source setVariable [QGVAR(currentFuelCargo), _fuel, true];
};

Expand Down
4 changes: 3 additions & 1 deletion addons/refuel/functions/fnc_makeSource.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ params [
];
TRACE_3("makeSource",_source,_fuelCargo,_hooks);

private _fuelCargoConfig = getNumber (configFile >> "CfgVehicles" >> typeOf _source >> QGVAR(fuelCargo));
private _cfg = configFile >> "CfgVehicles" >> typeOf _source;
private _transportFuel = getNumber (_cfg >> "transportFuel");
private _fuelCargoConfig = [_cfg >> QGVAR(fuelCargo), "NUMBER", _transportFuel] call CBA_fnc_getConfigEntry;

if (
isNull _source
Expand Down
13 changes: 11 additions & 2 deletions addons/refuel/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
// CBA Settings [ADDON: ace_refuel]:
[
QGVAR(enabled),
"CHECKBOX",
ELSTRING(common,Enabled),
[LELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_refuel"],
true,
true,
{[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)},
true // Needs mission restart
] call CBA_Settings_fnc_init;
Dystopian marked this conversation as resolved.
Show resolved Hide resolved

[
QGVAR(rate), "SLIDER",
[LSTRING(RefuelSettings_speed_DisplayName), LSTRING(RefuelSettings_speed_Description)],
[localize ELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_refuel"],
[LELSTRING(OptionsMenu,CategoryLogistics), localize "str_state_refuel"],
[0,25,1,1], // [min, max, default value, trailing decimals (-1 for whole numbers only)]
true, // isGlobal
{[QGVAR(rate), _this] call EFUNC(common,cbaSettings_settingChanged)}
Expand Down