-
Notifications
You must be signed in to change notification settings - Fork 38
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
Implement batched messages for Digiline Chests #87
Open
andriyndev
wants to merge
17
commits into
minetest-mods:master
Choose a base branch
from
andriyndev:implement-batched-signals
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 13 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5457e76
Implement batched signals for Digiline Chests
andriyndev faba1d8
Fix crash because of prev_time == nil
andriyndev 385f41d
Restrict the maximum size of batch, finally fix the bug with prev_tim…
andriyndev 9acd806
Fix linter warning
andriyndev 6ed20ff
Merge branch 'master' into implement-batched-signals
andriyndev eb891e1
Fix according to comments
andriyndev 97f66f4
Rename signal -> message
andriyndev ee37090
Add information about batch signal into documentation
andriyndev 4278dc5
Return back getting "channel" in one line
andriyndev 785050d
Fix on_destruct() and missing 'channel'
andriyndev 25d67ce
Add a comment
andriyndev cdb3fe0
Fix for batches with single element
andriyndev 22b20b8
Fix typo "amound" -> "amount"
andriyndev 59d56a7
Allow to batch only messages of specific types, send the batch even i…
andriyndev ec3448e
Check if the area is loaded when trying to send batched message on ti…
andriyndev 2ef5fe8
Don't reset timer when adding messages to batch
andriyndev bcb4a97
Update inventory.lua
andriyndev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This and
last_message_time_for_chest
needs periodic cleanups (e.g. every 30 seconds) in cases where mapblocks are unloaded from memory without sending the message(s).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.
Sorry for late response. I'm not sure that it's the best solution because this means that the message will be lost that might be crucial in some cases and disrupt the logic of the factory. Also, I don't know how likely the situation is when the map region with a digiline chest is unloaded within 0.1 seconds after placing something to there in a batch (it might happen in case of delivering items to there by tubes in large amounts though). But even when it happens, I'm not sure how crucial is that we'll have some extra records in the structure for a while (maybe even until the server is shutting down). Another option would be to create such a timer, and if it detects such a situation, load the area and flush the signal. But in this case, as far as I understand, it'll activate the factory again that might send more items to the chest and trigger another batched message, and we're stuck in a vicious circle. Some players could theoretically even use it to keep their factories running when offline. I currently haven't come up with a solution of this dilemma.
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.
Mapblocks can be unloaded from one server step to the next. This case won't occur often, but it can accumulate over time (unless the same mapblocks are loaded again).
Option 1: Clearing old entries periodically
Option 2: node name validity check
batched_messages
periodically (minetest.register_globalstep
)minetest.get_node(pos)
returns the digiline node name.Also: might there be nodes that switch between two states (e.g. active/inactive) ? AFAIK when usingJudging from the C++ code, node timers appear to be untouched by swap node.minetest.swap_node
or equivalent, the node timer is removed but noon _destruct
called.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.
It seems I've come up with the perfect solution: use batched messages only for inventory actions triggered by a user. In this case it will be very unlikely that the chest is unloaded after 0.1 seconds after interaction with a user. But even if it happens, it shouldn't be a problem to load the map region again, and flush the batched messages. Regarding actions triggered by tubes, it will be the chest's owner's responsibility to ensure that the incoming (or outcoming) items won't burn the controller.
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.
And yes, use
minetest.after()
instead of node timers to trigger it, so that it'll be triggered even if the node is unloadedThere 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.
Done