Possible* bug with regions overlapping.
apengstrom opened this issue ยท 18 comments
This is a bit complicated, I'll try to quickly describe how to replicate this.
- Created a town. Set the mayor to player 1.
- Added player 2 to town. Set player 2 as assistant.
- Added territory for town. Shown by red polygon in screenshot.
- Player 2 (assistant) creates a plot (cuboid) with points at the top left and bottom right of the white box in the screenshot below. Both of those points are within the polygon territory, so it creates it. However, that cuboid plot has a corner (bottom left) that goes outside the actual territory.
Is there a way we can check all points of a cuboid or poly selection for border violations? I'm pretty positive you already do this for polygons, as they have multiple points and are designed to be checked as such. But cuboids only have 2 recorded points that we select and I believe this is causing some sort of limitation.
If the opposite corners are not recorded somewhere you can get them, maybe create a small function that calculates what the other two corners' X and Z coords would be? The first two points the user selects creates the height limitation so it shouldn't need to check the height at all.
Thanks in advance for looking into this
Huh. I'm not handling the details of the boundary-checking myself, I'm using WorldGuard methods for it. I'll take a look and see if either WG or I are doing something wrong.
I was incorrect- I am doing the overlapping checks myself, and for polygons I'm using a naive approximation. I can use a slower (but speed isn't important for this) but accurate algorithm for it.
Fixed in e332155
(I hope)
I've added better bounds-checking, though it's inadvertently added a limitation that I can't easily work around: inner regions now have to be at least one block smaller on all sides than their parent region.
I can make this work like it used to, technically, but I'd have to re-implement a lot of work that's currently being done by Java2D. So if this works for you, then I'll leave this as-is.
This won't affect existing regions though, only new ones.
And, you should check to see if I'm right on this or not, because it's only a strong suspicion right now.
This isn't working as it should.. I am trying to wrap a poly region around the existing territory and then use /territory redefine. It's saying that my new selection is not surrounding my existing territory, but clearly it is, according to screenshots. The small screenshot of the map shows the new region I created with world guard, showing all the points I selected, and the red region (territory) within it.
Both are poly regions.
Ah curses, I'll take another look at it. Downgrade off of this build if it's giving you trouble.
Also found that when using this bug fix build, players can't create plots in their territories.
Yeah, this was an issue with the function that checks if a region is completely within another region, which gets used in a few places.
When do you think we'll have another test build to look at? If its going to be a while I will backdate my build to the previous one.
You should downgrade, I'm not sure how long it will take me to figure out what's not working.
Just an update:
I've been writing unit tests for this feature and, unfortunately, all are passing. I'm going to have to try poking around and seeing what order the points for each polygon are in that WG is giving me. I would hope/assume they'd be in the correct order such that they form the polygon, but at this point I'm fairly sure my algorithms are correct, so I have to consider that maybe WG isn't giving me the input I'm expecting.
The new jenkins builds are only from the unit tests being added, so there's no functional difference between those builds and the one that was giving you trouble.
Really strange- I don't know if it makes any difference, but the territories involved are expanded 100% vertically. The plot I was attempting to make was also expanded 100% vertically, I believe. And the territory I was redefining, was previously expanded 100%. I was redefining it with a 100% expanded vertically region.
Could it be an issue with having to be expanded 1 block further than the previous region? Because a fully vertical expanded region can't be expanded anymore.
That's good thinking, and I'll actually double-check to make sure that isn't the issue, but I'm pretty sure the Y gets ignored, since WG itself only uses 2D (x & z) vectors for its polygon regions.
Apparently WorldGuard's ProtectedRegion::getPoints() returns the points in no particular order, which was causing even creating plots to fail. Working on a fix right now. I just pushed something that might fix it, but I'm not hopeful without more testing.
Awesome! Let me know when I should test, and I'll get right to it. I'm excited for this as we will be able to finally start expanding and managing towns fully.
Once Jenkins updates (~hour or so, the usual) that build should contain a fix for this.
The issue ended up being a WorldGuard bug. I've submitted a pull request to get it fixed upstream, but I also have a workaround that's in the latest commit to MCTowns.