1
0
forked from 0ad/0ad

Prevent division by 0 for experience bar

Required experience can be set to 0 initially and because entity is
upgrated after simulation starts, there was division by 0 in atlas for
such entities causing experience bar going to infinity.

Differential revision: D4317
Fixes: #6362
Patch by: @Langbart
Reviewed by: @Angen
This was SVN commit r25974.
This commit is contained in:
Angen 2021-10-27 19:00:35 +00:00
parent f543574d61
commit 3adac574b7

View File

@ -194,7 +194,7 @@ function displaySingle(entState)
{
let experienceBar = Engine.GetGUIObjectByName("experienceBar");
let experienceSize = experienceBar.size;
experienceSize.rtop = 100 - (100 * Math.max(0, Math.min(1, 1.0 * +entState.promotion.curr / +entState.promotion.req)));
experienceSize.rtop = 100 - (100 * Math.max(0, Math.min(1, 1.0 * +entState.promotion.curr / (+entState.promotion.req || 1))));
experienceBar.size = experienceSize;
if (entState.promotion.curr < entState.promotion.req)