Fix non-diagonal borders water detect #1202
Merged
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.
Sorry for not testing the previous PR #1199 on a variety of maps. This PR fixes the behavior of water checking on non-diagonal maps (i.e. only either +/- X or +/- Z touches water).
In the original code, unmodified nodes are changed into ignore (i.e. do not modify them on map). However, because we were iterating the contents one by one, this lead to failed water detection as at least one of the border's neighbor would be converted into ignore before the detection occurs. In Water Academy, this bug wasn't found because all borders have four neighbors and can tolerate this kind of bug.
This PR fixes this bug by copying the table of content IDs and work on the copy instead. The new copy is calledmod
, stands for "modifications".(New in
ca43590
) A new empty table calledmod
(stands for "modifications") is created. As we iterate through all the elements of the originald
table, all the latter's key will be recreated with the new contents. In compare to thetable.copy(d)
approach in my previous commits, this can speed up the process of barrier removal.This PR is ready for review.