ACE3/addons/refuel/XEH_preStart.sqf
Dystopian 7c65f8503d
Refuel - Add enable setting (#7613)
* Add enable setting

* Exclude man class init

* Fix multiplayer terrain pump fuel sync

* Add terrain pumps positions

* Add vanilla fuel cargo restoring before destroying

* Add Livonia positions by bux

* Fix terrain pumps destruction

* Improve settings init

* Fix double settings category

* Check enabled var in public functions

* Fix fnc_makeSource

* Handle recent CUP Terrains changes

* Update includes

* Fix issues introduced in #9133

* Change warning

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>

* Optimisations and cleanup

- Use hashmaps wherever possible
- Reduced pump search radius by ~30%
- Sorted pumps alphabetically and sorted positions by "smallest" first, for consistency

* Add init debug trace

* compileScript in dev

* yoda conditions & DFUNC macro

* Wait until CBA settings are ready

* Update Chernarus 2020 and add more maps configs

* Remove vanilla fuel cargo restoring before destroying

---------

Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
2024-05-23 21:47:19 +02:00

48 lines
2.2 KiB
Plaintext

#include "script_component.hpp"
#include "XEH_PREP.hpp"
// cache refuel vehicles, see XEH_postInit.sqf
private _staticClasses = [];
private _baseStaticClasses = [];
private _baseDynamicClasses = [];
private _cacheRefuelCargo = createHashMap;
{
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;
private _noXEH = !isText (_x >> "EventHandlers" >> "CBA_Extended_EventHandlers" >> "init");
private _isPublic = getNumber (_x >> "scope") == 2;
// check if we can use actions with inheritance
if (
_noXEH // addActionToClass relies on XEH init
|| {_sourceClass isKindOf "Static"} // CBA_fnc_addClassEventHandler doesn't support "Static" class
) then {
if (_isPublic) then {
if (_noXEH) then {
WARNING_3("Class %1: %2 [%3] needs XEH",_sourceClass,configName inheritsFrom _x,configSourceMod _x);
};
_staticClasses pushBack _sourceClass;
if (_baseStaticClasses findIf {_sourceClass isKindOf _x} == -1) then {
_baseStaticClasses pushBack _sourceClass;
};
};
} else {
if (_baseDynamicClasses findIf {_sourceClass isKindOf _x} == -1) then {
_baseDynamicClasses pushBack _sourceClass;
};
};
if (_isPublic) then {
_cacheRefuelCargo set [_sourceClass, _fuelCargo];
};
};
} forEach ("true" configClasses (configFile >> "CfgVehicles"));
TRACE_3("found",count _staticClasses,count _baseStaticClasses,count _baseDynamicClasses);
uiNamespace setVariable [QGVAR(cacheRefuelClassesStatic), compileFinal (_staticClasses createHashMapFromArray [])];
uiNamespace setVariable [QGVAR(cacheRefuelClassesBaseStatic), compileFinal (_baseStaticClasses createHashMapFromArray [])];
uiNamespace setVariable [QGVAR(cacheRefuelClassesBaseDynamic), compileFinal (_baseDynamicClasses createHashMapFromArray [])];
uiNamespace setVariable [QGVAR(cacheRefuelCargo), compileFinal _cacheRefuelCargo];