From c3e3fda94add6ac82f9c73dd875c997d8d2acd92 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 9 Aug 2019 09:58:40 +0200 Subject: [PATCH] - fixed handling of the "ouch" face. This depended on order of execution, taking the health values to compare from variables which were not synchronized properly. Now both the last and current health being used here are being retrieved in the same place so that further changes cannot break this again. --- src/g_statusbar/sbar.h | 3 ++- src/g_statusbar/sbar_mugshot.cpp | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/g_statusbar/sbar.h b/src/g_statusbar/sbar.h index 1b89190ca..f7faee70b 100644 --- a/src/g_statusbar/sbar.h +++ b/src/g_statusbar/sbar.h @@ -293,7 +293,8 @@ class FMugShot FMugShotState *CurrentState; int RampageTimer; int LastDamageAngle; - int FaceHealth; + int FaceHealthNow; + int FaceHealthLast; bool bEvilGrin; bool bDamageFaceActive; bool bNormal; diff --git a/src/g_statusbar/sbar_mugshot.cpp b/src/g_statusbar/sbar_mugshot.cpp index 0da401a0f..d494efbe8 100644 --- a/src/g_statusbar/sbar_mugshot.cpp +++ b/src/g_statusbar/sbar_mugshot.cpp @@ -221,7 +221,7 @@ FMugShot::FMugShot() void FMugShot::Reset() { - FaceHealth = -1; + FaceHealthNow = FaceHealthLast = -1; bEvilGrin = false; bNormal = true; bDamageFaceActive = false; @@ -262,7 +262,8 @@ void FMugShot::Tick(player_t *player) { RampageTimer = 0; } - FaceHealth = player->health; + FaceHealthLast = FaceHealthNow; + FaceHealthNow = player->health; } //=========================================================================== @@ -328,7 +329,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags) { FString full_state_name; - if (player->health > 0) + if (FaceHealthNow > 0) { if (bEvilGrin && !(stateflags & DISABLEGRIN)) { @@ -340,10 +341,10 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags) } bEvilGrin = false; - bool ouch = (!st_oldouch && FaceHealth - player->health > ST_MUCHPAIN) || (st_oldouch && player->health - FaceHealth > ST_MUCHPAIN); + bool ouch = (!st_oldouch && FaceHealthLast - FaceHealthNow > ST_MUCHPAIN) || (st_oldouch && FaceHealthNow - FaceHealthLast > ST_MUCHPAIN); if (player->damagecount && // Now go in if pain is disabled but we think ouch will be shown (and ouch is not disabled!) - (!(stateflags & DISABLEPAIN) || (((FaceHealth != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH)))) + (!(stateflags & DISABLEPAIN) || (((FaceHealthLast != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH)))) { int damage_angle = 1; if (player->attacker && player->attacker != player->mo) @@ -364,7 +365,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags) } } bool use_ouch = false; - if (((FaceHealth != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH)) + if (((FaceHealthLast != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH)) { use_ouch = true; full_state_name = "ouch."; @@ -391,7 +392,7 @@ int FMugShot::UpdateState(player_t *player, StateFlags stateflags) else { bool use_ouch = false; - if (((FaceHealth != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH)) + if (((FaceHealthLast != -1 && ouch) || bOuchActive) && !(stateflags & DISABLEOUCH)) { use_ouch = true; full_state_name = "ouch.";