Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix METABOLISM enchantment multiply: -1 causing the game to hang #72255

Merged
merged 4 commits into from
Mar 9, 2024

Conversation

GuardianDll
Copy link
Member

Summary

None

Purpose of change

Fix #72242
weariness_level uses weary_threshold, which uses base_bmr, which uses metabolic_rate_base, which uses hunger_rate, and this one may be make zero using METABOLISM enchantment; since all of stuff that happens between these two are multiplicative only, it can carry zero value all way back to weariness_level calculations, which then stuck in the loop infinitely, trying to subtract zero threshold from whatever weariness is

Describe the solution

Put failsafe code, that checks if weary_threshold is zero, and if true, simply return zero, bypassing entire loop
Added test, that checks the trait, that turns off METABOLIC, to prevent regressions of this type in the future

Describe alternatives you've considered

Return some another value
Make BMI not being able to be zero

Testing

Compiled, casted Stones' Fortitude lvl 20, the game do not stop responding

Additional context

I have no clue how the entire chain works ngl, not even sure BMI = 0 makes any sense

@github-actions github-actions bot added [JSON] Changes (can be) made in JSON Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies Code: Tests Measurement, self-control, statistics, balancing. [C++] Changes (can be) made in C++. Previously named `Code` <Bugfix> This is a fix for a bug (or closes open issue) astyled astyled PR, label is assigned by github actions json-styled JSON lint passed, label assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Mar 8, 2024
@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [Markdown] Markdown issues and PRs labels Mar 9, 2024
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 9, 2024
src/character.cpp Outdated Show resolved Hide resolved
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Mar 9, 2024
@Maleclypse Maleclypse merged commit 56f8838 into CleverRaven:master Mar 9, 2024
25 of 27 checks passed
@GuardianDll GuardianDll deleted the METABOLISM_ench_fix branch March 9, 2024 23:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Code: Tests Measurement, self-control, statistics, balancing. <Documentation> Design documents, internal info, guides and help. [JSON] Changes (can be) made in JSON json-styled JSON lint passed, label assigned by github actions [Markdown] Markdown issues and PRs Mutations / Traits / Professions/ Hobbies Mutations / Traits / Professions/ Hobbies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression--METABOLISM of 0 causes the game to hang.
3 participants