Arckenver / Nations

UNMAINTAINED - Minecraft Sponge Plugin - Towny-like Worldguard-like protection plugin
MIT License
15 stars 34 forks source link

Seemingly random issue - Nation block count drops into negatives and allows the nation to claim infinite land #95

Open turtledude01 opened 7 years ago

turtledude01 commented 7 years ago

At random, a nation might claim a few blocks, and suddenly have their nations block count drop to a negative number. This is quite strange and I have no way of fixing it other than removing all rects from their config file and reloading the server. I have taken a look through the code and have no clue as to where this is originating but I believe it is somewhere in the /objects/Rect file. There is also no errors or anything happening at all. Note: though I am running my own dev version of Nations, this has happened twice now, once on the current release and once on my dev version.

turtledude01 commented 7 years ago

86 SHOULD fix this by forcing all rect.size to be positive (tested this on a server that had the previous version and it wrapped the numbers around to soemthing insanely high

turtledude01 commented 7 years ago

There is still some underlying issue that is causing the maxX and minX to get flipped like so: { "world": "79188d5e-46b2-47c5-94c6-e99474a2a1c3", "minX": 394, "maxX": 352, "minY": -1115, "maxY": -1064 } This caused the calculation of size to become negative, to fix the problem, I added a Math.abs to the size function.

turtledude01 commented 7 years ago

@TheoKah I feel this should be addressed at some point soon.
Also, something noted by one of my friends was that the nation serializer/deserializer shouldnt use gson, but at least use configurate's typeserializer. This might also fix this problem the right way.

TheoKah commented 7 years ago

I tried to reproduce with no success... You have a list of steps to reproduce this?

I'll let @Arckenver decide if we should change the way we serialize/deserialize nations

turtledude01 commented 7 years ago

I cant reproduce this either, like stated in the title, it is seemingly random. But i DO believe having at least protection against a negative size should be a thing. This fix can be achieved with a single line change, only adding Math.abs().
I have two nation configs with this error right now and I'm using the Math.abs() function to 'fix' it.

TheoKah commented 7 years ago

Using the abs() won't help:

Only fix would be to find out why and how the min and max values were badly stored

turtledude01 commented 7 years ago

See, your wrong there... I'm not using the abs() on a part that will do that... In the rect object I am setting size to return the abs of height x width. I even went through my affected files and did the math manually. And guess what? It came out correctly. The problem is that when you multiply the difference between min and max X we are getting a negative number. Multiply that by the positive Y difference and we get a large negative number for size, which should always be positive anyways.