CORE/_mcl_autogroup: Prevent server crash on digging unknown #85
No reviewers
Labels
No Label
blocker
bug
code quality
confirmed
critical
discussion
high priority
incompatibility
incomplete feature
invalid
low priority
missing feauture
needs testing
packet spam
performance
project
regression
translations
unconfirmed
in review
ready for review
No Milestone
No project
No Assignees
3 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Mineclonia/Mineclonia#85
Loading…
Reference in New Issue
No description provided.
Delete Branch "fix-dig-unknown-crash"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
TRACKING ISSUE: #84
Solution
The can_harvest function of autogroup gets the node defintion from mt api (as i understand it) and in some conditions that can return nil.
The pr makes the can_harvest function return false (node is dug, nothing is dropped) in those cases.
Testing Steps
3ee2ef0618
Please replace the commit with one that does not change unrelated stuff to reduce future merge conflicts, then add an explanatory comment.
@ -207,6 +207,10 @@ end
function mcl_autogroup.can_harvest(nodename, toolname)
local ndef = minetest.registered_nodes[nodename]
if not ndef then
Please add a comment here for context:
The comment should specify:
I disagree with these requested changes.
not ndef
is a very common way to check for unknown nodes and does not require a comment.false
means is documented in a few lines above in the function comment.The most I think should be commented is something like
-- Unknown nodes are not harvestable
but I do not think a comment is necessary at all.I think context and motivation about why a certain change was made should be explained in the commit message and not in the committed code. The only exception is if the code is hard to understand by itself so information about why it does things a certain way is necessary. I do not consider this to be one of those cases.
I think it would be better if @cora would do
git commit --amend
and add this type of context information to the commit message (while fixing the other things you pointed out).In this case the crash happened because clamity runs a different version of minetest.
Without that knowledge it is impossible to reproduce the crash locally (@cora tried).
I agree, you changed my mind about it.
Yes, I see your point and agree that it is worth mentioning for future reference. Just disagreed about where we should put that information. :)
@ -272,3 +276,3 @@
-- efficiency - The efficiency level the tool is enchanted with (default 0)
--
-- NOTE:
-- NOTE:
This has nothing do do with the bugfix. Please do not change unrelated stuff.
I think you could use “git commit --amend” and force push to replace the commit.
@ -289,3 +293,3 @@
-- diggroup - The name of the diggroup the tool is used on
--
-- NOTE:
-- NOTE:
This has nothing do do with the bugfix. Please do not change unrelated stuff.
I think you could use “git commit --amend” and force push to replace the commit.
Btw, “add nil check in can_harvest” is not a very good commit message in my opinion, as it states what changed on a purely mechanical level. Something like “Do not crash when players dig unknown nodes on Clamity minetest” would help someone wanting to understand why this was done a lot more.
Well I thought that was a bit redundant since the PR is named that but yeah maybe you have a point
651a477113
to4c9de30545
If I understand the code correctly, the intent is to make unknown blocks drop nothing.
Which sounds good anyway, even without a crash.
Testing this now.
I can confirm the crash happens as expected.
I can confirm that the bugfix does prevent the crash.
Code looks okay. From where can_harvest() is used it seems to me that it is safe to assume that this does not prevent any legitimate tool use.
What I did
3ee2ef0618
I approve this, let's see what @ryvnf has to say about it.
Hey @ryvnf do you think this is okay now?
The code changes look good to me. I haven't tested them but I trust that both of you have.
The commit message is better but I would still change it slightly. This is because it breaks the "50 column" rule for the commit summary. I would have written it something like this:
We have, but the relevant information here is "I haven't tested" – regardless of reason.
IMO reviewers should never assume that anything works as advertised unless they tested it.
I think cleaning up the commit message before merging would be better, but is not necessary.
@cora @ryvnf anyone of you wants to amend the commit message before the merge?
You asked for my opinion. I see no point in repeating the same tests that both you and @cora have already done. The PR does not need another approval to be merged. I think it must be fine to point out things which can be improved without doing a full review of the PR.
I would prefer if @cora would amend the commit message and then merge it.
Again ? To what exactly should I change it now!?
Also I agree that 2 people having done the tests should be enough at least for trivial (and kinda critical) things like this
yes, true
@ryvnf @cora orry if I might appear rude today, I am just very tired right now
I think code review and playtesting being separate steps might motivate people to help more and also frustrate others way less. I will ask aroud, maybe we can get one or two playtesters to confirm bugs and fixes (basically QA). With the amoutn of people doing speedruns I am totally sure those people exist.
Please tell me hte exact wording you want it to be
I posted my suggested wording here.
b7cfb3185c
to79766bff23