]> git.lizzy.rs Git - minetest.git/blobdiff - src/clientiface.cpp
Log deprecated Lua function calls (#7491)
[minetest.git] / src / clientiface.cpp
index 8e469cafbb7aad97e0eedc080f357a8e0f17ea99..cc52d1fbc57e61d82f96caeb44083c76a83ccfdc 100644 (file)
@@ -192,17 +192,24 @@ void RemoteClient::GetNextBlocks (
        */
        s32 new_nearest_unsent_d = -1;
 
-       // get view range and camera fov from the client
+       // Get view range and camera fov (radians) from the client
        s16 wanted_range = sao->getWantedRange() + 1;
        float camera_fov = sao->getFov();
 
-       const s16 full_d_max = std::min(adjustDist(m_max_send_distance, camera_fov), wanted_range);
-       const s16 d_opt = std::min(adjustDist(m_block_optimize_distance, camera_fov), wanted_range);
+       // Distrust client-sent FOV and get server-set player object property
+       // zoom FOV (degrees) as a check to avoid hacked clients using FOV to load
+       // distant world.
+       float prop_zoom_fov = sao->getZoomFOV() * core::DEGTORAD;
+
+       const s16 full_d_max = std::min(adjustDist(m_max_send_distance, prop_zoom_fov),
+               wanted_range);
+       const s16 d_opt = std::min(adjustDist(m_block_optimize_distance, prop_zoom_fov),
+               wanted_range);
        const s16 d_blocks_in_sight = full_d_max * BS * MAP_BLOCKSIZE;
-       infostream << "Fov from client " << camera_fov << " full_d_max " << full_d_max << std::endl;
 
        s16 d_max = full_d_max;
-       s16 d_max_gen = std::min(adjustDist(m_max_gen_distance, camera_fov), wanted_range);
+       s16 d_max_gen = std::min(adjustDist(m_max_gen_distance, prop_zoom_fov),
+               wanted_range);
 
        // Don't loop very much at a time, adjust with distance,
        // do more work per RTT with greater distances.
@@ -648,6 +655,15 @@ std::vector<session_t> ClientInterface::getClientIDs(ClientState min_state)
        return reply;
 }
 
+void ClientInterface::markBlockposAsNotSent(const v3s16 &pos)
+{
+       MutexAutoLock clientslock(m_clients_mutex);
+       for (const auto &client : m_clients) {
+               if (client.second->getState() >= CS_Active)
+                       client.second->SetBlockNotSent(pos);
+       }
+}
+
 /**
  * Verify if user limit was reached.
  * User limit count all clients from HelloSent state (MT protocol user) to Active state