mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-07-01 08:54:52 +02:00
Fix possible int-overflow on radius-update
This commit is contained in:
parent
2033d91497
commit
ef5e2c08aa
|
@ -100,13 +100,13 @@ private static List<Vector2i> getRegions(World world, Vector2i center, int radiu
|
||||||
|
|
||||||
Grid regionGrid = world.getRegionGrid();
|
Grid regionGrid = world.getRegionGrid();
|
||||||
Vector2i halfCell = regionGrid.getGridSize().div(2);
|
Vector2i halfCell = regionGrid.getGridSize().div(2);
|
||||||
int increasedRadiusSquared = (int) Math.pow(radius + Math.ceil(halfCell.length()), 2);
|
long increasedRadiusSquared = (long) Math.pow(radius + Math.ceil(halfCell.length()), 2);
|
||||||
|
|
||||||
for (Vector2i region : world.listRegions()) {
|
for (Vector2i region : world.listRegions()) {
|
||||||
Vector2i min = regionGrid.getCellMin(region);
|
Vector2i min = regionGrid.getCellMin(region);
|
||||||
Vector2i regionCenter = min.add(halfCell);
|
Vector2i regionCenter = min.add(halfCell);
|
||||||
|
|
||||||
if (regionCenter.distanceSquared(center) <= increasedRadiusSquared)
|
if (regionCenter.toLong().distanceSquared(center.toLong()) <= increasedRadiusSquared)
|
||||||
regions.add(region);
|
regions.add(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user