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

Feature/reset food saturation #903

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

aabstractt
Copy link
Contributor

Add reset the exhaustion and saturation when the Food Loss handler is cancelled. This help to prevent loss very fast the food after no longer cancelling that handler.

Example

2024-07-22.17-40-15.mp4

didntpot

This comment was marked as resolved.

@didntpot
Copy link
Contributor

race condition plz add mutex

Copy link
Contributor

@CJMustard1452 CJMustard1452 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix race conditions

@@ -65,6 +65,14 @@ func (m *hungerManager) Reset() {
m.mu.Unlock()
}

// ResetExhaustion resets the exhaustion level of the player to 0.
// Prevents the player food level decrease after non cancelling the food loss
func (m *hungerManager) resetExhaustion() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function cause race condition plz fix

Copy link
Contributor

@didntpot didntpot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plz

server/player/hunger.go Outdated Show resolved Hide resolved
server/player/hunger.go Outdated Show resolved Hide resolved
Copy link
Contributor

@CJMustard1452 CJMustard1452 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@TwistedAsylumMC
Copy link
Member

Should it reset it to 0 or what it was before the last event was cancelled?

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

Successfully merging this pull request may close these issues.

4 participants