Fix potential TOC/TOU issues caused by dealing damage between can_move_to and actually moving - #135
Merged
Merged
Conversation
Dealing damage involves a lot of callbacks that may modify the map enough to invalidate the validation done before moving (e.g. killing a player may place a bones block in the digtrons way). Moving first minimizes the chance of the map changing between validation and movement.
Member
|
What if the creature spawns a node? In that case we'd have to check twice and move in the end. However, I'm afraid there's no perfect solution. |
Contributor
Author
EDIT: I think I understand your concern now. If the creature now places some blocks into the digtron after the digtron moved, I think that's fine, because the creature's code does it after checking the map, therefore intentionally. |
Member
|
Okay. Seems fine then. Will merge in a few days unless there are objections. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Damaging creatures can invoke a lot of code that may change the world, e.g. killing a player may place a bone block that is then potentially overwritten by the digtron nodes themselves.
This PR moves the creature damage to after moving the digtron to minimize the potential for TOC/TOU issues.
It also includes a separate commit with a small not directly related change to annotate node class in the message warning about missing
damage_creaturescallback.