mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch '4ydx/overflow-fix' into 'master'
Fix int overflows causing crash when using /goto See merge request veloren/veloren!3656
This commit is contained in:
commit
0c05fe54d3
@ -1858,8 +1858,11 @@ impl Client {
|
||||
// 1 for the chunks needed bordering other chunks for meshing
|
||||
// 1 as a buffer so that if the player moves back in that direction the chunks
|
||||
// don't need to be reloaded
|
||||
// Take the minimum of the adjusted difference vs the view_distance + 1 to
|
||||
// prevent magnitude_squared from overflowing
|
||||
|
||||
if (chunk_pos - key)
|
||||
.map(|e: i32| (e.unsigned_abs()).saturating_sub(2))
|
||||
.map(|e: i32| (e.unsigned_abs()).saturating_sub(2).min(view_distance + 1))
|
||||
.magnitude_squared()
|
||||
> view_distance.pow(2)
|
||||
{
|
||||
|
@ -276,7 +276,7 @@ impl VoxelMinimap {
|
||||
)
|
||||
.unwrap_or(0)
|
||||
};
|
||||
if cpos.distance_squared(self.last_pos.xy()) >= 1
|
||||
if self.last_pos.xy() != cpos
|
||||
|| self.last_pos.z != pos.z as i32
|
||||
|| self.last_ceiling != ceiling_offset
|
||||
|| new_chunks
|
||||
|
Loading…
Reference in New Issue
Block a user