From 1d6f7f38372a76c2b6c36aa3528fcbc0db0629f8 Mon Sep 17 00:00:00 2001 From: freagarach Date: Thu, 9 Jan 2025 20:35:20 +0100 Subject: [PATCH] Always mark 'PromotedEntity' on transform If the new entity did not have Promotion, we would fail to do so. Not doing this caused ghost units to appear when promoting inside a GarrisonHolder. Fixes #7472, reported by Langbart. --- .../data/mods/public/simulation/helpers/Transform.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/public/simulation/helpers/Transform.js b/binaries/data/mods/public/simulation/helpers/Transform.js index d37252aa31..c7e18a8a3f 100644 --- a/binaries/data/mods/public/simulation/helpers/Transform.js +++ b/binaries/data/mods/public/simulation/helpers/Transform.js @@ -85,12 +85,13 @@ function ChangeEntityTemplate(oldEnt, newTemplate) cmpNewHealth.SetHitpoints(cmpNewHealth.GetMaxHitpoints() * healthLevel); } - let cmpPromotion = Engine.QueryInterface(oldEnt, IID_Promotion); - let cmpNewPromotion = Engine.QueryInterface(newEnt, IID_Promotion); - if (cmpPromotion && cmpNewPromotion) + const cmpPromotion = Engine.QueryInterface(oldEnt, IID_Promotion); + if (cmpPromotion) { cmpPromotion.SetPromotedEntity(newEnt); - cmpNewPromotion.IncreaseXp(cmpPromotion.GetCurrentXp()); + const cmpNewPromotion = Engine.QueryInterface(newEnt, IID_Promotion); + if (cmpNewPromotion) + cmpNewPromotion.IncreaseXp(cmpPromotion.GetCurrentXp()); } let cmpResGatherer = Engine.QueryInterface(oldEnt, IID_ResourceGatherer);