Prevent light scale overflow (#1605)

This commit is contained in:
ceski 2024-03-19 23:29:14 -07:00 committed by GitHub
parent 57c2b98999
commit 2cf75df1f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -480,7 +480,7 @@ void R_SmoothLight(void)
int R_GetLightIndex(fixed_t scale)
{
const int index = FixedDiv(scale * 160, lightfocallength) >> LIGHTSCALESHIFT;
const int index = ((int64_t)scale * (160 << FRACBITS) / lightfocallength) >> LIGHTSCALESHIFT;
return BETWEEN(0, MAXLIGHTSCALE - 1, index);
}