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 called mod, stands for "modifications".
(New in ca43590) A new empty table called mod (stands for "modifications") is created. As we iterate through all the elements of the original d table, all the latter's key will be recreated with the new contents. In compare to the table.copy(d) approach in my previous commits, this can speed up the process of barrier removal.
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.