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.
This commit is contained in:
Vantha 2026-02-12 17:27:00 +01:00 committed by Vantha
parent a89ce596a4
commit a2befad973
No known key found for this signature in database
GPG key ID: 3F5D02FA4D3E8E74

View file

@ -643,31 +643,8 @@ GuiInterface.prototype.GetAverageRangeForBuildings = function(player, cmd)
GuiInterface.prototype.GetTemplateData = function(player, data) GuiInterface.prototype.GetTemplateData = function(player, data)
{ {
const templateName = data.templateName; const template = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager)?.GetTemplate(data.templateName);
const owner = data.player !== undefined ? data.player : player; return template && g_TemplateHelper.computeDataFromPlayer(template, AuraTemplates.GetAll(), Resources, 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);
}; };
GuiInterface.prototype.AreRequirementsMet = function(player, data) GuiInterface.prototype.AreRequirementsMet = function(player, data)