diff --git a/src/clientiface.cpp b/src/clientiface.cpp index c2d245f67..f76ef0a88 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -480,12 +480,11 @@ void RemoteClient::SetBlockNotSent(v3s16 p) m_blocks_modified.insert(p); } -void RemoteClient::SetBlocksNotSent(std::map &blocks) +void RemoteClient::SetBlocksNotSent(const std::vector &blocks) { m_nothing_to_send_pause_timer = 0; - for (auto &block : blocks) { - v3s16 p = block.first; + for (v3s16 p : blocks) { // remove the block from sending and sent sets, // and mark as modified if found if (m_blocks_sending.erase(p) + m_blocks_sent.erase(p) > 0) @@ -707,12 +706,12 @@ std::vector ClientInterface::getClientIDs(ClientState min_state) return reply; } -void ClientInterface::markBlockposAsNotSent(const v3s16 &pos) +void ClientInterface::markBlocksNotSent(const std::vector &positions) { RecursiveMutexAutoLock clientslock(m_clients_mutex); for (const auto &client : m_clients) { if (client.second->getState() >= CS_Active) - client.second->SetBlockNotSent(pos); + client.second->SetBlocksNotSent(positions); } } diff --git a/src/clientiface.h b/src/clientiface.h index 1df67b568..c5a93576c 100644 --- a/src/clientiface.h +++ b/src/clientiface.h @@ -267,7 +267,7 @@ public: void SentBlock(v3s16 p); void SetBlockNotSent(v3s16 p); - void SetBlocksNotSent(std::map &blocks); + void SetBlocksNotSent(const std::vector &blocks); /** * tell client about this block being modified right now. @@ -473,8 +473,8 @@ public: /* get list of active client id's */ std::vector getClientIDs(ClientState min_state=CS_Active); - /* mark block as not sent to active client sessions */ - void markBlockposAsNotSent(const v3s16 &pos); + /* mark blocks as not sent on all active clients */ + void markBlocksNotSent(const std::vector &positions); /* verify is server user limit was reached */ bool isUserLimitReached(); diff --git a/src/server.cpp b/src/server.cpp index 3437d17f0..26b58245b 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -950,9 +950,7 @@ void Server::AsyncRunStep(float dtime, bool initial_step) } case MEET_OTHER: prof.add("MEET_OTHER", 1); - for (const v3s16 &modified_block : event->modified_blocks) { - m_clients.markBlockposAsNotSent(modified_block); - } + m_clients.markBlocksNotSent(event->modified_blocks); break; default: prof.add("unknown", 1); @@ -964,19 +962,9 @@ void Server::AsyncRunStep(float dtime, bool initial_step) /* Set blocks not sent to far players */ - if (!far_players.empty()) { - // Convert list format to that wanted by SetBlocksNotSent - std::map modified_blocks2; - for (const v3s16 &modified_block : event->modified_blocks) { - modified_blocks2[modified_block] = - m_env->getMap().getBlockNoCreateNoEx(modified_block); - } - - // Set blocks not sent - for (const u16 far_player : far_players) { - if (RemoteClient *client = getClient(far_player)) - client->SetBlocksNotSent(modified_blocks2); - } + for (const u16 far_player : far_players) { + if (RemoteClient *client = getClient(far_player)) + client->SetBlocksNotSent(event->modified_blocks); } delete event;