diff options
Diffstat (limited to 'src/server.cpp')
-rw-r--r-- | src/server.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/server.cpp b/src/server.cpp index 869498965..496170da3 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2312,6 +2312,28 @@ void Server::SendBlocks(float dtime) m_clients.unlock(); } +bool Server::SendBlock(session_t peer_id, const v3s16 &blockpos) +{ + MapBlock *block = nullptr; + try { + block = m_env->getMap().getBlockNoCreate(blockpos); + } catch (InvalidPositionException &e) {}; + if (!block) + return false; + + m_clients.lock(); + RemoteClient *client = m_clients.lockedGetClientNoEx(peer_id, CS_Active); + if (!client || client->isBlockSent(blockpos)) { + m_clients.unlock(); + return false; + } + SendBlockNoLock(peer_id, block, client->serialization_version, + client->net_proto_version); + m_clients.unlock(); + + return true; +} + void Server::fillMediaCache() { infostream<<"Server: Calculating media file checksums"<<std::endl; |