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

Hoe usage count is off #2929

Closed
Wuzzy2 opened this issue Feb 3, 2022 · 2 comments · Fixed by #2959
Closed

Hoe usage count is off #2929

Wuzzy2 opened this issue Feb 3, 2022 · 2 comments · Fixed by #2959
Labels

Comments

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Feb 3, 2022

The hoe usage count is off.

  • Steel Hoe: Expected: 500 uses. Actual: 501 uses
  • (legacy) Mese Hoe: Expected: 350 uses. Actual: 351 uses
  • (legacy) Diamond Hoe: Expected: 500 uses. Actual: 501 uses
  • Wood/Stone Hoe: Are fine (due to coincidence)
  • All custom hoes (those registered with the game API) with a high uses count are also affected

The error increases the higher the number of uses (up to tens of thausands).

Reason for this bug

This is basically minetest/minetest#4900, but in Minetest Game. The same mistake is done as was done in the engine: The naive calculation add_wear(65535/(uses-1)) that is currently used won't always get in the number of uses you want due to rounding errors. The larger the number of desired uses, the larger the rounding error is (see #11110 for an in-depth analysis).

Possible fix

Merge minetest/minetest#12047 into Minetest, then replace the naive wear calculation with item:add_wear_by_uses(number_of_uses_that_you_want_the_tool_to_have_before_it_breaks). ;-)

This is a helper function made specifically for this use case.

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented May 24, 2022

If minetest/minetest#12047 gets merged, this issue is fixable for MTG.

@Wuzzy2
Copy link
Contributor Author

Wuzzy2 commented Jun 3, 2022

The required engine change was made.
PR: #2959

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

Successfully merging a pull request may close this issue.

2 participants