From 03b6a182096070df2ff1cf8618c4d6206b396bd0 Mon Sep 17 00:00:00 2001 From: saurtron Date: Thu, 26 Dec 2024 19:08:12 +0100 Subject: [PATCH] cmd_share_unit: Don't crash when hovering over a unit in front of sky. (#4079) --- luaui/Widgets/cmd_share_unit.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/luaui/Widgets/cmd_share_unit.lua b/luaui/Widgets/cmd_share_unit.lua index afdb4a63f31..38e213585f0 100644 --- a/luaui/Widgets/cmd_share_unit.lua +++ b/luaui/Widgets/cmd_share_unit.lua @@ -130,7 +130,11 @@ local function getMouseTargetPosition() return mouseTarget[1], mouseTarget[2], mouseTarget[3] elseif mouseTargetType == "unit" then local _, coordinates = TraceScreenRay(mx, my, true) - return coordinates[1], coordinates[2], coordinates[3], mouseTarget + if coordinates then + return coordinates[1], coordinates[2], coordinates[3], mouseTarget + else + return nil, nil, nil, mouseTarget + end elseif mouseTargetType == "feature" then local _, coordinates = TraceScreenRay(mx, my, true) if coordinates then @@ -285,7 +289,7 @@ local function getSelectedTeam() local tx, ty, tz, targetUnitID = getMouseTargetPosition() - if (not tx) then + if (not tx and not targetUnitID) then return nil end