Repair - Fix bug in detection for ignoring hitpoints (#9261)

* Fix bug in detection for ignoring repair hitpoints

* Use define for array any

* Add warning if hitpoint group would be ignored

* Apply suggestions from code review

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

* Change ANY to ANY_OF

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
This commit is contained in:
Tim Beswick 2023-07-28 04:32:30 +01:00 committed by GitHub
parent 18551144bd
commit cd36871f90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View File

@ -38,6 +38,7 @@
#define GETEGVAR(var1,var2,var3) GETMVAR(EGVAR(var1,var2),var3)
#define ARR_SELECT(ARRAY,INDEX,DEFAULT) (if (count ARRAY > INDEX) then {ARRAY select INDEX} else {DEFAULT})
#define ANY_OF(ARRAY,CONDITION) (ARRAY findIf {CONDITION} != -1)
// ACEX Merge
#define ACEX_PREFIX acex

View File

@ -437,10 +437,7 @@ class CfgVehicles {
transportRepair = 0;
};
class Helicopter_Base_H;
class Heli_Transport_04_base_F: Helicopter_Base_H {
GVAR(hitpointGroups)[] = { {"HitEngine", {"HitEngine1", "HitEngine2"}} };
};
class Heli_Transport_04_base_F;
class O_Heli_Transport_04_repair_F: Heli_Transport_04_base_F {
GVAR(canRepair) = 1;
transportRepair = 0;

View File

@ -18,7 +18,7 @@
params ["_vehicle"];
private _type = typeOf _vehicle;
TRACE_2("getHitPointsToIgnore", _vehicle,_type);
TRACE_2("getHitPointsToIgnore",_vehicle,_type);
private _initializedClasses = missionNamespace getVariable [QGVAR(hitPointsToIgnoreInitializedClasses), createHashMap];
if (_type in _initializedClasses) exitWith {_initializedClasses get _type};
@ -118,12 +118,19 @@ private _processedSelections = [];
/*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping depends hitpoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];
#endif*/
private _groupIndex = _hitpointGroups findIf {_x # 0 == _hitpoint};
if (_groupIndex != -1) then {
ERROR_2("[%1] hitpoint [%2] is both a group-parent and a depends and will be unrepairable",_type,_hitpoint);
ERROR_1("group: %1",_hitpointGroups # _groupIndex);
};
_hitPointsToIgnore pushBackUnique _hitpoint;
_processedSelections pushBack _selection;
continue
};
if ((_hitpointGroups findIf {(_x select 1) == _hitpoint}) != -1) then { // skip child hitpoints
if (ANY_OF(_hitpointGroups, ANY_OF(_x select 1, _x == _hitpoint))) then { // skip child hitpoints
TRACE_3("Skipping child hitpoint",_hitpoint,_forEachIndex,_selection);
/*#ifdef DEBUG_MODE_FULL
systemChat format ["Skipping child hitpoint, hitpoint %1, index %2, selection %3", _hitpoint, _forEachIndex, _selection];