MT-CTF / capturetheflag

Capture the Flag game using the Minetest Voxel Engine
https://ctf.rubenwardy.com
81 stars 88 forks source link

Fix non-diagonal borders water detect #1202

Closed Emojigit closed 1 year ago

Emojigit commented 1 year ago

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.

This PR is ready for review.

farooqkz commented 1 year ago

Can't comment on code but it works on Water academy and many maps with normal barriers where there is water.