From 0a7a6aac87d75f13abf7a6d5266b497b66ee105e Mon Sep 17 00:00:00 2001 From: Vantha Date: Fri, 27 Feb 2026 21:26:51 +0100 Subject: [PATCH] Deduplicate `GetEntityState(clickedEntity)` calls --- binaries/data/mods/public/gui/session/input.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index a1e785d62b..c3a85dc0c6 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -1130,8 +1130,9 @@ function handleInputAfterGui(ev) { if (clickedEntity == INVALID_ENTITY) clickedEntity = Engine.PickEntityAtPoint(ev.x, ev.y); + const clickedEntityState = GetEntityState(clickedEntity); // Abort if we didn't click on an entity or if the entity was removed before the mousebuttonup event. - if (clickedEntity == INVALID_ENTITY || !GetEntityState(clickedEntity)) + if (clickedEntity == INVALID_ENTITY || !clickedEntityState) { clickedEntity = INVALID_ENTITY; if (!Engine.HotkeyIsPressed("selection.add") && !Engine.HotkeyIsPressed("selection.remove")) @@ -1157,18 +1158,18 @@ function handleInputAfterGui(ev) if (ev.clicks == 2) { - templateToMatch = GetEntityState(clickedEntity).selectionGroupName; + templateToMatch = clickedEntityState.selectionGroupName; if (templateToMatch) matchRank = false; else // No selection group name defined, so fall back to exact match. - templateToMatch = GetEntityState(clickedEntity).templateName; + templateToMatch = clickedEntityState.templateName; } else // Triple click // Select units matching exact template name (same rank). - templateToMatch = GetEntityState(clickedEntity).templateName; + templateToMatch = clickedEntityState.templateName; // TODO: Should we handle "control all units" here as well? ents = Engine.PickSimilarPlayerEntities(templateToMatch, showOffscreen, matchRank, false);