A mindistance of 40000 works and a mindistnace of 60000 seems to work but might not if my assumption is correct.
a mindistance of 50000 or 49000 results in having structure spawn very close to each other
Integer Overflow:
If mingroupDistance is very large, mingroupDistance mingroupDistance could result in an integer overflow, causing unexpected behavior. The maximum value for a 32-bit signed integer is 2,147,483,647. For mingroupDistance = 50000, mingroupDistance mingroupDistance equals 2,500,000,000, which exceeds this limit. This would result in a negative value for minDistSq, leading to incorrect distance checks.
If 60000 works but 50000 and 49000 do not, this indicates a more nuanced issue. Given that an integer overflow is occurring for values around 50000, it's possible that 60000 might be causing a different behavior due to how overflows work in practice, but we need to ensure the underlying logic can handle large distances correctly.
First, I'll explain why 60000 might seem to work:
An integer overflow with 50000 and 49000 results in negative values, causing incorrect logic flow and failures.
With 60000, it's possible that despite the overflow, the resulting calculations fall into a valid range or the overflow might result in values that incidentally do not cause the method to fail outright.
To handle this correctly, we should update the code to use long for calculations involving large distances to prevent overflow issues entirely.
How to reproduce
testmod.zip
this mod has a structure that has a 49000 mindistance
Game Version
v1.19.7
Platform
Windows
Modded
Modded
SP/MP
Singleplayer
Description
A mindistance of 40000 works and a mindistnace of 60000 seems to work but might not if my assumption is correct. a mindistance of 50000 or 49000 results in having structure spawn very close to each other
Thats what I think could be the problem
https://github.com/anegostudios/vssurvivalmod/blob/085907b5635e634fdf4b3624883c17bb14a734e5/Systems/WorldGen/Standard/ChunkGen/6.GenStructures/WorldGenStructure.cs#L884
Integer Overflow: If mingroupDistance is very large, mingroupDistance mingroupDistance could result in an integer overflow, causing unexpected behavior. The maximum value for a 32-bit signed integer is 2,147,483,647. For mingroupDistance = 50000, mingroupDistance mingroupDistance equals 2,500,000,000, which exceeds this limit. This would result in a negative value for minDistSq, leading to incorrect distance checks.
If 60000 works but 50000 and 49000 do not, this indicates a more nuanced issue. Given that an integer overflow is occurring for values around 50000, it's possible that 60000 might be causing a different behavior due to how overflows work in practice, but we need to ensure the underlying logic can handle large distances correctly.
First, I'll explain why 60000 might seem to work:
An integer overflow with 50000 and 49000 results in negative values, causing incorrect logic flow and failures. With 60000, it's possible that despite the overflow, the resulting calculations fall into a valid range or the overflow might result in values that incidentally do not cause the method to fail outright. To handle this correctly, we should update the code to use long for calculations involving large distances to prevent overflow issues entirely.
How to reproduce
testmod.zip this mod has a structure that has a 49000 mindistance
Screenshots
No response
Logs
None