mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-07-17 00:33:53 +00:00
Fix cc1ea7cca0 error in Promotion when promoting an entity that died on the same turn.
Add a regression test for this case. Reported By: elexis Differential Revision: https://code.wildfiregames.com/D2227 This was SVN commit r22808.
This commit is contained in:
@@ -33,7 +33,10 @@ Promotion.prototype.Promote = function(promotedTemplateName)
|
||||
// If the unit is dead, don't promote it
|
||||
let cmpHealth = Engine.QueryInterface(this.entity, IID_Health);
|
||||
if (cmpHealth && cmpHealth.GetHitpoints() == 0)
|
||||
{
|
||||
this.promotedUnitEntity = INVALID_ENTITY;
|
||||
return;
|
||||
}
|
||||
|
||||
// Save the entity id.
|
||||
this.promotedUnitEntity = ChangeEntityTemplate(this.entity, promotedTemplateName);
|
||||
|
||||
@@ -63,4 +63,15 @@ cmpPromotion.IncreaseXp(4200);
|
||||
TS_ASSERT_EQUALS(cmpPromotion.entity, 62);
|
||||
TS_ASSERT_EQUALS(cmpPromotion.template.Entity, "end");
|
||||
TS_ASSERT_EQUALS(cmpPromotion.GetCurrentXp(), 200);
|
||||
|
||||
cmpPromotion = ConstructComponent(ENT_ID, "Promotion", {
|
||||
"Entity": "template_b",
|
||||
"RequiredXp": 1000
|
||||
});
|
||||
|
||||
let cmpHealth = AddMock(ENT_ID, IID_Health, {
|
||||
"GetHitpoints": () => 0,
|
||||
});
|
||||
|
||||
cmpPromotion.IncreaseXp(1000);
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user