From e7b7219bd9dc25bc7ccbf45e5c984b8ed94318de Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Thu, 12 Apr 2018 09:15:57 -0500 Subject: [PATCH] Repair - Handle changes to getAllHitPointsDamage (#6250) Since 1.82 `getAllHitPointsDamage` returns lower case Fix track repair and hit point groups being case sensitive Part of #6248 --- addons/repair/dev/draw_showRepairInfo.sqf | 2 +- addons/repair/functions/fnc_addRepairActions.sqf | 6 +++--- addons/repair/functions/fnc_canMiscRepair.sqf | 5 +++-- addons/repair/functions/fnc_doRepair.sqf | 5 +++-- addons/repair/script_component.hpp | 2 +- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/addons/repair/dev/draw_showRepairInfo.sqf b/addons/repair/dev/draw_showRepairInfo.sqf index 5701c172ea..3a1f0c8d0f 100644 --- a/addons/repair/dev/draw_showRepairInfo.sqf +++ b/addons/repair/dev/draw_showRepairInfo.sqf @@ -64,6 +64,6 @@ addMissionEventHandler ["Draw3D", { _output pushBack format ["%1: %2[%3] = %4", _forEachIndex, _hitPoint, _selection, cursorObject getHitIndex _forEachIndex]; _output pushBack format ["- %1 -",_info]; }; - } forEach _hitPoints; + } forEach _hitSelections; hintSilent (_output joinString "\n"); }]; diff --git a/addons/repair/functions/fnc_addRepairActions.sqf b/addons/repair/functions/fnc_addRepairActions.sqf index 8a1e068379..3f4842c3c0 100644 --- a/addons/repair/functions/fnc_addRepairActions.sqf +++ b/addons/repair/functions/fnc_addRepairActions.sqf @@ -28,7 +28,7 @@ private _initializedClasses = GETMVAR(GVAR(initializedClasses),[]); if (_type in _initializedClasses) exitWith {}; // get all hitpoints and selections -(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]]; +(getAllHitPointsDamage _vehicle) params [["_hitPoints", []], ["_hitSelections", []]]; // Since 1.82 these are all lower case // get hitpoints of wheels with their selections ([_vehicle] call FUNC(getWheelHitPointsWithSelections)) params ["_wheelHitPoints", "_wheelHitSelections"]; @@ -41,7 +41,7 @@ private _icon = QPATHTOF(ui\repair_0_ca.paa); { private _selection = _x; - private _hitpoint = _hitPoints select _forEachIndex; + private _hitpoint = toLower (_hitPoints select _forEachIndex); if (_selection in _wheelHitSelections) then { // Wheels should always be unique @@ -68,7 +68,7 @@ private _icon = QPATHTOF(ui\repair_0_ca.paa); [_type, 0, [], _action] call EFUNC(interact_menu,addActionToClass); } else { //Skip glass hitpoints - if (((toLower _hitPoint) find "glass") != -1) exitWith { + if ((_hitPoint find "glass") != -1) exitWith { TRACE_3("Skipping Glass",_hitpoint,_forEachIndex,_selection); }; // Empty selections don't exist diff --git a/addons/repair/functions/fnc_canMiscRepair.sqf b/addons/repair/functions/fnc_canMiscRepair.sqf index 9d9fc29478..c26cfdb42a 100644 --- a/addons/repair/functions/fnc_canMiscRepair.sqf +++ b/addons/repair/functions/fnc_canMiscRepair.sqf @@ -36,9 +36,10 @@ if (isArray _hitpointGroupConfig) then { // Exit using found hitpoint group if this hitpoint is leader of any if (_masterHitpoint == _hitPointClassname) exitWith { { - private _subHitIndex = _allHitPoints find _x; + private _subHitpoint = _x; + private _subHitIndex = _allHitPoints findIf {_x == _subHitpoint}; if (_subHitIndex == -1) then { - ERROR("Hitpoint Not Found"); + ERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_subHitpoint,_target); } else { _hitpointGroup pushBack _subHitIndex; }; diff --git a/addons/repair/functions/fnc_doRepair.sqf b/addons/repair/functions/fnc_doRepair.sqf index ad944518f4..64056fb999 100644 --- a/addons/repair/functions/fnc_doRepair.sqf +++ b/addons/repair/functions/fnc_doRepair.sqf @@ -47,9 +47,10 @@ if (isArray _hitpointGroupConfig) then { // Exit using found hitpoint group if this hitpoint is leader of any if (_masterHitpoint == _hitPointClassname) exitWith { { - private _subHitIndex = _allHitPoints find _x; //convert hitpoint classname to index + private _subHitpoint = _x; + private _subHitIndex = _allHitPoints findIf {_x == _subHitpoint}; //convert hitpoint classname to index if (_subHitIndex == -1) then { - ERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_x,_vehicle); + ERROR_2("Invalid hitpoint %1 in hitpointGroups of %2",_subHitpoint,_vehicle); } else { private _subPointCurDamage = _vehicle getHitIndex _hitPointIndex; private _subPointNewDamage = (_subPointCurDamage - 0.5) max _postRepairDamageMin; diff --git a/addons/repair/script_component.hpp b/addons/repair/script_component.hpp index 879d6930e0..678f8fe04e 100644 --- a/addons/repair/script_component.hpp +++ b/addons/repair/script_component.hpp @@ -16,4 +16,4 @@ #include "\z\ace\addons\main\script_macros.hpp" -#define TRACK_HITPOINTS ["HitLTrack", "HitRTrack"] +#define TRACK_HITPOINTS ["hitltrack", "hitrtrack"]