Nametags - Fix ACE nametag drawIcon3D parameter error when player controlled unit dies (#8764)

* FIX: `_icon` can be `nil`

* Migrate from `if` to `switch`

* Missing ()
This commit is contained in:
Vdauphin
2022-03-07 19:26:22 +01:00
committed by GitHub
parent 3b62af6131
commit 282dd33d59

View File

@ -29,19 +29,26 @@ _fnc_parameters = {
params ["_player", "_target", "_alpha", "_heightOffset", "_drawName", "_drawRank", "_drawSoundwave"]; params ["_player", "_target", "_alpha", "_heightOffset", "_drawName", "_drawRank", "_drawSoundwave"];
//Set Icon: //Set Icon:
private _icon = ""; private _targetIcon = _target getVariable QGVAR(rankIcon);
if (_drawSoundwave) then {
_icon = format [QPATHTOF(UI\soundwave%1.paa), floor random 10]; private _icon = switch true do {
} else { case _drawSoundwave: {
if (_drawRank) then { format [QPATHTOF(UI\soundwave%1.paa), floor random 10]
_icon = _target getVariable "ace_nametags_rankIcon"; };
if (isNil "_icon" && {rank _target != ""}) then {
_icon = GVAR(factionRanks) getVariable (_target getVariable [QGVAR(faction), faction _target]); case !_drawRank: {""};
if (!isNil "_icon") then { case !isNil "_targetIcon": {_targetIcon};
_icon = _icon param [ALL_RANKS find rank _target, ""]; case (rank _target == ""): {""};
} else {
_icon = format ["\A3\Ui_f\data\GUI\Cfg\Ranks\%1_gs.paa", rank _target]; default {
}; private _targetFaction = _target getVariable [QGVAR(faction), faction _target];
private _customRankIcons = GVAR(factionRanks) getVariable _targetFaction;
if (!isNil "_customRankIcons") then {
_customRankIcons param [ALL_RANKS find rank _target, ""] // return
} else {
// default rank icons
format ["\A3\Ui_f\data\GUI\Cfg\Ranks\%1_gs.paa", rank _target] // return
}; };
}; };
}; };