-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implemented new method of defining valid faces through the secondary node registration #8
Conversation
Update cache on node removal
Refuse to connect with faces of a node which are not marked valid
…node registration
Might also want to change |
@joe7575 I'm pretty confident in this one now, most of the code I originally added has actually been removed, this is looking a lot more like a new feature should. |
👍 I will look into this later today, I am still busy... |
I think I found the bug #6. Line https://github.com/joe7575/tubelib2/blob/master/tube_api.lua#L372 is wrong. It has to be: self:after_dig_node(tele_pos, {peer_meta:get_int("tube_dir")}) This will remove all cached data and terminate the connection between both ends. |
4096a11
to
1a441d0
Compare
Okay let me pull master and test it out, I still think "valid_faces" would be a nice new feature, but yeah let's talk about it |
@joe7575 I'm not seeing spooky connections fixed at all on master... What's your testing scenario? |
@joe7575 Actually in combination with the valid faces fix that is doing the trick, this is updating the cache as expected, can still do nasty things without valid faces though |
internal2.lua
Outdated
param2 = param2_data[idx] | ||
} | ||
end | ||
return {name="ignore", param2=0} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure where this change came from, leaving a note so when I undo it (to keep this PR clean) it doesn't vanish into the aether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A similar function was modified in tube_api in the same way
@joe7575 after a little testing I'm pretty sure all of these changes, and the ones in this PR joe7575/techpack#74 are still required. I can still cause the spooky connection bug without these changes. |
As I was testing things previously I came up with a few more scenarios that produce the bug, basically you need to try every combination you can think of tubes, wrong sides and destination or not: [ source > teleporter facing sideways (air gap) teleporter > chest ] [ source > teleporter (air gap) teleporter > air ] (need to test these in your testing scenario though) |
Please keep in mind: |
I'm pretty sure the changes here will not change behavior if valid_sides is never set |
… added more checks to is_valid_dir in favor of using get_secondary_node
When I use internal2.lua and tube_api.lua from this PR, the server immediately crashes:
|
Right, it does not work as expected. I will try something else... |
This should not be possible unless Actually I'm looking at the |
Perhaps it was no good idea to store the |
Ahh wish I'd seen that before I made the change! I don;t think that's a bad idea, take a look at how I've fixed it and let me know if you still want me to separate them. What I've done is make sure we pass that table through Where "tubelib:node_name1" will get all set to the default values, and "tubelib:node_name2" will get them set to custom values |
I would prefer if we could separate the new features as much as possible from the existing code. A third new function like: Tube:set_valid_sides({ ["tubelib:node_name2"]={U=true, L=true} }) would be the best. |
Okay, I'm working on that now. Would you prefer
I really feel like I could always do both? Perhaps a |
I implemented a teleporter node completely inside tube_test.lua. It is a real secondary node (like the TechPack detector) and does not use tubelib2 pairing functionality: It has a callback function: on_push_item = function(pos, dir, item)
local tube_dir = M(pos):get_int("tube_dir")
if dir == tubelib2.Turn180Deg[tube_dir] then
local s = M(pos):get_string("peer_pos")
if s and s ~= "" then
push_item(S2P(s))
return true
end
end
end, Objectives:
|
Its up to you, both is ok. Two function for valid/invalid would be perfect :) |
Shorter is better, I will go with I will write both a
If you think that's a better way to fix teleporters that's great, but I think this valid_sides feature has grown a little beyond that. We could start to implement that in this PR if you think it's needed joe7575/techpack#74 The only piece of code that new teleporter method would invalidate is the tube_walk changes - now in get_teleporter - even then I think we would have to put in some condition to stop people making another secondary node that's like a tube, or we would need that code again. |
In the case of the teleporter, which has one valid side (lets say left), it see the following possibilities: set_valid_sides({ ['node_name'] = {L=true} })
set_valid_sides({ ['node_name'] = {"L"} })
set_valid_sides('node_name', {"L"})
set_invalid_sides({ ['node_name'] = {B=true, R=true, F=true, D=true, U=true} })
set_invalid_sides({ ['node_name'] = {"B", "R", "F", "D", "U"})
set_invalid_sides('node_name', {"B", "R", "F", "D", "U"}) I would prefer:
The valid_sides feature is great for all types of secondary nodes, also for the teleporters. Removing the teleporter code from tubelib2 would simplify and cleanup the code, unfortunately this can't be done. But it can be ignored for future implementations.
This can't be done without changing tubelib2. And even if somebody tries this. If you implement a node wrong, you can do anything... Edit: Of course, it always has to be |
Ahh of course, consider it done. I already made it
I'm unsure what the conclusion is here, do I need to make any further changes? |
…ions for valid sides
I don't see the need, but I'm kind of overwhelmed with all of these changes right now |
One remark, but this is more a personal style: if self:is_valid_dir_pos(pos, dir) == false then return end I prefer: if not self:is_valid_dir_pos(pos, dir) then return end The second has the benefit, that is is always true, if it is not |
Actually, this is intentional, the return values are: In all cases I've used it in, |
Ah, I understand. |
Alright I think this is the one, I've checked this over a few times and updated the related PRs too. I like how this is looking Can't believe we made it past 40 comments xD |
Yep, I got (felt) 100 emails from you :) |
Fixes #4 again, but better this time
dir_to_side
andside_to_dir
into tubelib base moduleadd_secondary_node_names
functionget_secondary_node
to use the new systemget_secondary_node
is_valid_dir
andis_valid_side
functions for easy & fast valid side checkingThis should be tested thoroughly, but should probably not be merged until we're sure it provides a good method for disallowing connections
This should be tested along side joe7575/techpack#74