Skip to content

Commit a1868e8

Browse files
committed
Use server's zoom fov for distant world loading.
1 parent 935f11a commit a1868e8

File tree

2 files changed

+6
-17
lines changed

2 files changed

+6
-17
lines changed

src/clientiface.cpp

+5-16
Original file line numberDiff line numberDiff line change
@@ -196,30 +196,19 @@ void RemoteClient::GetNextBlocks (
196196
s16 wanted_range = sao->getWantedRange() + 1;
197197
float camera_fov = sao->getFov();
198198

199-
// If below the heuristic zoom threshold (see adjustDist() in numeric.cpp)
200-
// distrust client-sent FOV and get server-set player object property
199+
// Distrust client-sent FOV and get server-set player object property
201200
// zoom FOV (degrees) as a check to avoid hacked clients using FOV to load
202201
// distant world.
203-
// 0.888 radians is slightly larger than the zoom threshold of 1.775 / 2
204-
// radians.
205-
if (camera_fov < 0.888f) {
206-
float prop_zoom_fov = sao->getZoomFOV();
207-
// If zoom is disabled by value 0
208-
if (prop_zoom_fov < 0.001f)
209-
camera_fov = 0.888f;
210-
else
211-
// Degrees -> radians
212-
camera_fov = prop_zoom_fov * core::DEGTORAD;
213-
}
202+
float prop_zoom_fov = sao->getZoomFOV() * core::DEGTORAD;
214203

215-
const s16 full_d_max = std::min(adjustDist(m_max_send_distance, camera_fov),
204+
const s16 full_d_max = std::min(adjustDist(m_max_send_distance, prop_zoom_fov),
216205
wanted_range);
217-
const s16 d_opt = std::min(adjustDist(m_block_optimize_distance, camera_fov),
206+
const s16 d_opt = std::min(adjustDist(m_block_optimize_distance, prop_zoom_fov),
218207
wanted_range);
219208
const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE;
220209

221210
s16 d_max = full_d_max;
222-
s16 d_max_gen = std::min(adjustDist(m_max_gen_distance, camera_fov),
211+
s16 d_max_gen = std::min(adjustDist(m_max_gen_distance, prop_zoom_fov),
223212
wanted_range);
224213

225214
// Don't loop very much at a time, adjust with distance,

src/util/numeric.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ s16 adjustDist(s16 dist, float zoom_fov)
168168
// 1.775 ~= 72 * PI / 180 * 1.4, the default FOV on the client.
169169
// The heuristic threshold for zooming is half of that.
170170
static constexpr const float threshold_fov = 1.775f / 2.0f;
171-
if (zoom_fov > threshold_fov)
171+
if (zoom_fov < 0.001f || zoom_fov > threshold_fov)
172172
return dist;
173173

174174
return std::round(dist * std::cbrt((1.0f - std::cos(threshold_fov)) /

0 commit comments

Comments
 (0)