Open turtledude01 opened 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.
@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.
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
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.
Using the abs() won't help:
Only fix would be to find out why and how the min and max values were badly stored
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.
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.