diff options
author | SatoMew <SatoMew@users.noreply.github.com> | 2021-09-13 21:51:56 +0100 |
---|---|---|
committer | SatoMew <SatoMew@users.noreply.github.com> | 2021-09-13 21:51:56 +0100 |
commit | e13a99717b44f361f3937bcd997fd6cfc102c5a5 (patch) | |
tree | 8b73dbd97bdac924392ecb792ac77b691a0b8a63 | |
parent | 6de0d61daf33cbd713586fd2827e4326c4f0d587 (diff) |
Add fix to disallow negative current HP values
-rw-r--r-- | src/pokemon.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/pokemon.c b/src/pokemon.c index 39cc2f636..6e43aff85 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -2112,8 +2112,14 @@ void CalculateMonStats(struct Pokemon *mon) { if (currentHP == 0 && oldMaxHP == 0) currentHP = newMaxHP; - else if (currentHP != 0) + else if (currentHP != 0) { + // BUG: currentHP is unintentionally able to become <= 0 after the instruction below. currentHP += newMaxHP - oldMaxHP; + #ifdef BUGFIX + if (currentHP <= 0) + currentHP = 1; + #endif + } else return; } |