From bc336480e6317fec4eea03b055bcf9602ff633d7 Mon Sep 17 00:00:00 2001 From: lhofhansl Date: Thu, 28 Dec 2023 09:10:11 -0800 Subject: [PATCH] Avoid short overflow with large viewing ranges (#14175) --- src/clientiface.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/clientiface.cpp b/src/clientiface.cpp index c7166ce51..6171e2116 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -228,7 +228,8 @@ void RemoteClient::GetNextBlocks ( wanted_range); const s16 d_cull_opt = std::min(adjustDist(m_block_cull_optimize_distance, prop_zoom_fov), wanted_range); - const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE; + // f32 to prevent overflow, it is also what isBlockInSight(...) expects + const f32 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE; s16 d_max_gen = std::min(adjustDist(m_max_gen_distance, prop_zoom_fov), wanted_range);