mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-24 03:05:28 +01:00
fix(chnk visibility) Use long to avoid int overflow
Use long representation of the distance between tested chunk and center of tested limit to avoid int overflow while computing the distance compared to limit radius using square delta value
This commit is contained in:
parent
66fe5d4a8b
commit
61bfe66430
@ -25,7 +25,11 @@ public class RoundVisibilityLimit implements VisibilityLimit {
|
||||
else
|
||||
chunk_corner_z = chunk_z * 16 + 15;
|
||||
|
||||
return (chunk_corner_x - x_center) * (chunk_corner_x - x_center) + (chunk_corner_z - z_center) * (chunk_corner_z - z_center) < radius * radius;
|
||||
// By gmfamily - Use long representation of the distance between tested chunk and center of tested limit
|
||||
// to avoid int overflow while computing the distance compared to limit radius using square delta value
|
||||
long chunk_delta_x = chunk_corner_x - x_center;
|
||||
long chunk_delta_z = chunk_corner_z - z_center;
|
||||
return chunk_delta_x * chunk_delta_x + chunk_delta_z * chunk_delta_z < (long) radius * radius;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user