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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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