Fix freezard graphics crash with enemy health scaling (#5232)

This commit is contained in:
Archez 2025-03-28 04:30:56 -04:00 committed by GitHub
parent 32923d83f2
commit b66623c152
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -720,6 +720,15 @@ void EnFz_Draw(Actor* thisx, PlayState* play) {
index = (6 - this->actor.colChkInfo.health) >> 1; index = (6 - this->actor.colChkInfo.health) >> 1;
// SOH [Enhancement] - With enemy health scaling, the Freezards health could cause an index out of bounds for the
// displayLists, so we need to recompute the index based on the scaled health (using the maximum health value) and
// clamp the final result for safety.
if (CVarGetInteger(CVAR_ENHANCEMENT("EnemySizeScalesHealth"), 0)) {
u8 scaledHealth = (u8)(((f32)this->actor.colChkInfo.health / this->actor.maximumHealth) * 6);
index = (6 - scaledHealth) >> 1;
index = CLAMP(index, 0, 2);
}
OPEN_DISPS(play->state.gfxCtx); OPEN_DISPS(play->state.gfxCtx);
if (this->actor.colChkInfo.health == 0) { if (this->actor.colChkInfo.health == 0) {