CalcBarFilledPixels Safe Div (#7979)

This commit is contained in:
DizzyEggg 2025-10-19 22:37:23 +02:00 committed by GitHub
parent c16e2ded60
commit 1dd7a5731c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2258,10 +2258,11 @@ static u8 CalcBarFilledPixels(s32 maxValue, s32 oldValue, s32 receivedValue, s32
for (i = 0; i < scale; i++)
pixelsArray[i] = 0;
// Safe Div, because 2vs1 battles can have maxValue 0.
if (maxValue < totalPixels)
pixels = (*currValue * totalPixels / maxValue) >> 8;
pixels = SAFE_DIV(*currValue * totalPixels, maxValue) >> 8;
else
pixels = *currValue * totalPixels / maxValue;
pixels = SAFE_DIV(*currValue * totalPixels, maxValue);
filledPixels = pixels;