From a2befad973fff47e0aab91896f16873a6a0a5c23 Mon Sep 17 00:00:00 2001 From: Vantha Date: Thu, 12 Feb 2026 17:27:00 +0100 Subject: [PATCH] Simplify GuiInterface.prototype.GetTemplateData Some statements could be inlined and only passing relevant aura templates to the TemplateHelper isn't required, so we can simply always pass all of them and save the work. --- .../simulation/components/GuiInterface.js | 27 ++----------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/binaries/data/mods/public/simulation/components/GuiInterface.js b/binaries/data/mods/public/simulation/components/GuiInterface.js index d2fd800d8b..1fa1571ca7 100644 --- a/binaries/data/mods/public/simulation/components/GuiInterface.js +++ b/binaries/data/mods/public/simulation/components/GuiInterface.js @@ -643,31 +643,8 @@ GuiInterface.prototype.GetAverageRangeForBuildings = function(player, cmd) GuiInterface.prototype.GetTemplateData = function(player, data) { - const templateName = data.templateName; - const owner = data.player !== undefined ? data.player : player; - const cmpTemplateManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager); - const template = cmpTemplateManager.GetTemplate(templateName); - - if (!template) - return null; - - const aurasTemplate = {}; - - if (!template.Auras) - return g_TemplateHelper.computeDataFromPlayer(template, aurasTemplate, Resources, owner); - - const auraNames = template.Auras._string.split(/\s+/); - - for (const name of auraNames) - { - const auraTemplate = AuraTemplates.Get(name); - if (!auraTemplate) - error("Template " + templateName + " has undefined aura " + name); - else - aurasTemplate[name] = auraTemplate; - } - - return g_TemplateHelper.computeDataFromPlayer(template, aurasTemplate, Resources, owner); + const template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager)?.GetTemplate(data.templateName); + return template && g_TemplateHelper.computeDataFromPlayer(template, AuraTemplates.GetAll(), Resources, data.player || player); }; GuiInterface.prototype.AreRequirementsMet = function(player, data)