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 get_tool_wear_after_use for one use (insta-break) #12945

Merged
merged 1 commit into from Nov 9, 2022

Conversation

grorp
Copy link
Member

@grorp grorp commented Nov 8, 2022

minetest/doc/lua_api.txt

Lines 3683 to 3688 in 6191baf

* `minetest.get_tool_wear_after_use(uses [, initial_wear])`
* Simulates a tool being used once and returns the added wear,
such that, if only this function is used to calculate wear,
the tool will break exactly after `uses` times of uses
* `uses`: Number of times the tool can be used
* `initial_wear`: The initial wear the tool starts with (default: 0)

Currently minetest.get_tool_wear_after_use(1, 0) (tool should break after 1 use and doesn't have any wear yet) returns 0. Actually it should return 65536 in order to instantly break the tool. The wrong return value is caused by ModApiUtil::l_get_tool_wear_after_use incorrectly casting the return value of calculateResultWear from u32 to u16. This PR fixes that.

  • Does it resolve any reported issue?
    No, I thought it was small enough not to open an issue.

  • If not a bug fix, why is this PR needed? What usecases does it solve?
    It's a bug fix.

To do

This PR is Ready for Review.

How to test

Try minetest.get_tool_wear_after_use(1, 0). It should return 65536.

@sfan5 sfan5 added the Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines label Nov 8, 2022
@TurkeyMcMac TurkeyMcMac merged commit 88b04ea into minetest:master Nov 9, 2022
appgurueu pushed a commit to appgurueu/minetest that referenced this pull request May 2, 2023
@grorp grorp deleted the fix branch December 18, 2023 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bugfix 🐛 PRs that fix a bug One approval ✅ ◻️ @ Script API Trivial The change is a trivial bug fix, documentation or maintenance change, as per the Git Guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants