-
Notifications
You must be signed in to change notification settings - Fork 737
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refuel - Cache refuel classes (#6807)
* Cache refuel classes * Apply suggestions from code review Co-Authored-By: dedmen <dedmen@users.noreply.github.com> * Fix script errors from inner _x
- Loading branch information
1 parent
42c2c53
commit 45fe16d
Showing
2 changed files
with
45 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
#include "script_component.hpp" | ||
|
||
#include "XEH_PREP.hpp" | ||
|
||
// cache refuel vehicles, see XEH_postInit.sqf | ||
private _staticClasses = []; | ||
private _dynamicClasses = []; | ||
|
||
{ | ||
private _fuelCargo = getNumber (_x >> QGVAR(fuelCargo)); | ||
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 | ||
) then { | ||
if (2 == getNumber (_x >> "scope")) then { | ||
_staticClasses pushBackUnique _sourceClass; | ||
}; | ||
} else { | ||
if (-1 == _dynamicClasses findIf {_sourceClass isKindOf _x}) then { | ||
_dynamicClasses pushBackUnique _sourceClass; | ||
}; | ||
}; | ||
}; | ||
} forEach ('true' configClasses (configFile >> "CfgVehicles")); | ||
|
||
TRACE_2("compiled",count _staticClasses,count _dynamicClasses); | ||
uiNamespace setVariable [QGVAR(cacheRefuelClasses), compileFinal str [_staticClasses, _dynamicClasses]]; |