Fix possible integer-overflow when radius-rendering on big worlds

This commit is contained in:
Blue (Lukas Rieger) 2020-10-23 18:15:26 +02:00
parent d509c48025
commit 6b2e845654
No known key found for this signature in database
GPG Key ID: 904C4995F9E1F800

View File

@ -30,6 +30,7 @@
import java.util.StringJoiner; import java.util.StringJoiner;
import java.util.function.Predicate; import java.util.function.Predicate;
import com.flowpowered.math.vector.Vector2l;
import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.commons.lang3.time.DurationFormatUtils;
import com.flowpowered.math.GenericMath; import com.flowpowered.math.GenericMath;
@ -147,7 +148,8 @@ public void createMapRenderTask(CommandSource source, MapType map, Vector2i cent
if (center == null || blockRadius < 0) { if (center == null || blockRadius < 0) {
filter = c -> true; filter = c -> true;
} else { } else {
filter = c -> c.mul(16).distanceSquared(center) <= blockRadius * blockRadius; Vector2l centerL = center.toLong(); //use longs to avoid int-overflow
filter = c -> c.toLong().mul(16).distanceSquared(centerL) <= blockRadius * blockRadius;
taskName = "radius-render"; taskName = "radius-render";
renderCenter = center; renderCenter = center;
} }