Skip to content
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

Fix non-diagonal borders water detect #1202

Merged
merged 3 commits into from
Aug 12, 2023

Conversation

Emojigit
Copy link
Contributor

@Emojigit Emojigit commented Aug 11, 2023

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
Copy link
Contributor

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

@Emojigit Emojigit marked this pull request as draft August 12, 2023 00:00
@Emojigit Emojigit marked this pull request as ready for review August 12, 2023 00:02
@LoneWolfHT LoneWolfHT merged commit 9da013e into MT-CTF:master Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants