Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
overlay: fix regressions in Overlay_Draw*Bar
Browse files Browse the repository at this point in the history
Fixes #82
  • Loading branch information
rr- committed May 2, 2024
1 parent f2fd952 commit 6e41202
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- `/hp [num]`
- `/heal`
- changed the music backend to SDL + libav
- fixed healthbar and airbar flashing the wrong way when at low values (#82)

## [0.1.1](https://github.com/LostArtefacts/TR2X/compare/0.1...0.1.1) - 2024-04-27
- fixed Lara's shadow with z-buffer option on (#64, regression from 0.1)
Expand Down
27 changes: 10 additions & 17 deletions src/game/overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,14 @@ void __cdecl Overlay_DrawHealthBar(const bool flash_state)
m_OldHitPoints = hit_points;
g_HealthBarTimer = 40;
}
CLAMPL(g_HealthBarTimer, 0);

int32_t timer = g_HealthBarTimer;
if (timer < 0) {
timer = 0;
g_HealthBarTimer = 0;
const int32_t percent = hit_points * 100 / LARA_MAX_HITPOINTS;
if (hit_points <= LARA_MAX_HITPOINTS / 4) {
S_DrawHealthBar(flash_state ? percent : 0);
} else if (g_HealthBarTimer > 0 || g_Lara.gun_status == LGS_READY) {
S_DrawHealthBar(percent);
}

if (hit_points <= LARA_MAX_HITPOINTS / 4 && !flash_state) {
S_DrawHealthBar(0);
return;
}

if (timer <= 0 && g_Lara.gun_status != LGS_READY) {
return;
}
S_DrawHealthBar(hit_points * 100 / LARA_MAX_HITPOINTS);
}

void __cdecl Overlay_DrawAirBar(const bool flash_state)
Expand All @@ -132,10 +124,11 @@ void __cdecl Overlay_DrawAirBar(const bool flash_state)

int32_t air = g_Lara.air;
CLAMP(air, 0, LARA_MAX_AIR);
if (air <= 450 && !flash_state) {
S_DrawAirBar(0);
const int32_t percent = air * 100 / LARA_MAX_AIR;
if (air <= 450) {
S_DrawAirBar(flash_state ? percent : 0);
} else {
S_DrawAirBar(air * 100 / LARA_MAX_AIR);
S_DrawAirBar(percent);
}
}

Expand Down

0 comments on commit 6e41202

Please # to comment.