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 unwanted detaching when damage = 0 #8999

Merged
merged 1 commit into from
Oct 5, 2019

Conversation

programmerjake
Copy link
Contributor

Add compact, short information about your PR for easier understanding:

  • Goal of the PR
    don't detach player on set_hp with new hp equal to old hp
  • How does the PR work?
    skips detaching when the hp is positive
  • Does it resolve any reported issue?
    not that I could find

To do

This PR is Ready for Review.

How to test

play hamlet's quest as of sep 28, 2019
ride boat in water and observe not detaching after a second or so

backporting to stable

Not sure if the bug is in stable (didn't test), if so, this pull request should be backported to stable as well.

@SmallJoker SmallJoker changed the title workaround for detaching on set_hp with new hp equal to old hp Fix unwanted detaching when damage = 0 Sep 29, 2019
@sfan5
Copy link
Member

sfan5 commented Sep 29, 2019

What is the point of the else clause anyway? Why are players supposed to detach when they receive zero damage?

@SmallJoker SmallJoker added Bugfix 🐛 PRs that fix a bug and removed One approval ✅ ◻️ labels Sep 29, 2019
@SmallJoker
Copy link
Member

The idea is to detach GenericCAOs when they die.
For objects other than the current player this happens when they're removed from the environment (handleCommand_ActiveObjectRemoveAdd). For the current players this has to be handled in a different way - where they take damage or where the HP updates.
if (m_hp == 0) would be the correct check there.

@ghost
Copy link

ghost commented Sep 29, 2019 via email

@programmerjake
Copy link
Contributor Author

should I change the commit message to match?

m_hp <= 0 also triggers in the case that m_hp goes negative for some reason and is generally not any more expensive, hence why I used it.

@SmallJoker
Copy link
Member

@programmerjake No, the commit subject and body can be adjusted on merge.
However it would be better if the detach code (clear parent/child) is run every time when m_hp is zero, not just when there was no damage at all.

@SmallJoker SmallJoker self-requested a review September 29, 2019 17:47
@ClobberXD
Copy link
Contributor

m_hp <= 0 also triggers in the case that m_hp goes negative for some reason and is generally not any more expensive, hence why I used it.

m_hp can't go below 0, as it's of type u16 (unsigned short on most systems, IIRC).

@programmerjake
Copy link
Contributor Author

m_hp <= 0 also triggers in the case that m_hp goes negative for some reason and is generally not any more expensive, hence why I used it.

m_hp can't go below 0, as it's of type u16 (unsigned short on most systems, IIRC).

ah, ok. didn't check the type.

@programmerjake
Copy link
Contributor Author

Changed the detach condition to whenever m_hp == 0 even if damage is non-zero

@programmerjake
Copy link
Contributor Author

spurious build failure due to ubuntu package checksums not matching

@sfan5 sfan5 merged commit 7603215 into minetest:master Oct 5, 2019
@ghost
Copy link

ghost commented Feb 13, 2020

This broke old mount code, I believe. I.e. mobs_redo.
It detached when minetest.register_on_dieplayer to set some code, as visual_size, but now not.
:-(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants