-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
edit regen in darkness code for readability and correctness #70799
Merged
Maleclypse
merged 2 commits into
CleverRaven:master
from
db48x:regenerate-in-darkness-2
Jan 21, 2024
Merged
edit regen in darkness code for readability and correctness #70799
Maleclypse
merged 2 commits into
CleverRaven:master
from
db48x:regenerate-in-darkness-2
Jan 21, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The boolean > 0 check was inside the call to heal(), so it ended up passing either 1 or 0 rather than the calculated amount of healing. The clear intent of the check, however, is to only print the message if the monster actually needed to be healed. I also gave the calculated amount of healing a name (dHP), so that it is clear to future readers what the calculation is for; see the discussion in CleverRaven#67027 for an example of one of the easy ways to misread the old code. This patch does not change when or by how much the monster regenerates.
github-actions
bot
added
[C++]
Changes (can be) made in C++. Previously named `Code`
Monsters
Monsters both friendly and unfriendly.
<Bugfix>
This is a fix for a bug (or closes open issue)
labels
Jan 9, 2024
github-actions
bot
added
the
json-styled
JSON lint passed, label assigned by github actions
label
Jan 9, 2024
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This is a little bug that I noticed during my analysis for #67027, but didn’t bother to mention because it was less interesting than the light levels. |
github-actions
bot
added
astyled
astyled PR, label is assigned by github actions
BasicBuildPassed
This PR builds correctly, label assigned by github actions
labels
Jan 9, 2024
Procyonae
added
the
0.H Backport
PR to backport to the 0.H stable release canddiate
label
May 20, 2024
Procyonae
pushed a commit
to Procyonae/Cataclysm-DDA
that referenced
this pull request
May 24, 2024
…ven#70799) * edit regen in darkness code for readability and correctness The boolean > 0 check was inside the call to heal(), so it ended up passing either 1 or 0 rather than the calculated amount of healing. The clear intent of the check, however, is to only print the message if the monster actually needed to be healed. I also gave the calculated amount of healing a name (dHP), so that it is clear to future readers what the calculation is for; see the discussion in CleverRaven#67027 for an example of one of the easy ways to misread the old code. This patch does not change when or by how much the monster regenerates. * fix parenthesis style in monster.cpp Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kevingranade
added a commit
that referenced
this pull request
May 26, 2024
Procyonae
added
0.H Backported
and removed
0.H Backport
PR to backport to the 0.H stable release canddiate
labels
May 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
0.H Backported
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`
json-styled
JSON lint passed, label assigned by github actions
Monsters
Monsters both friendly and unfriendly.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "monsters that regenerate in darkness would only regenerate by a single HP per turn"
Describe the solution
The boolean > 0 check was inside the call to heal(), so it ended up passing either 1 or 0 rather than the calculated amount of healing. The clear intent of the check, however, is to only print the message if the monster actually needed to be healed.
I also gave the calculated amount of healing a name (dHP), so that it is clear to future readers what the calculation is for; see the discussion in #67027 for an example of one of the easy ways to misread the old code.
This patch does not change when or by how much the monster regenerates.
Describe alternatives you've considered
See also #70774.
Testing
I used a debugger to step through the code, observing that the
heal
method was only passed a 1 or a 0 before the patch, and that afterwards it was passed integers between 0 and 50.