From 8ca602150d4fdce6dcc63fa13e22aeaac5b927cc Mon Sep 17 00:00:00 2001 From: sfan5 Date: Thu, 23 Jul 2020 19:47:58 +0200 Subject: Replace std::list in networking code (#10215) --- src/network/connectionthreads.cpp | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src/network/connectionthreads.cpp') diff --git a/src/network/connectionthreads.cpp b/src/network/connectionthreads.cpp index 9a6617a1c..28ed798d9 100644 --- a/src/network/connectionthreads.cpp +++ b/src/network/connectionthreads.cpp @@ -144,7 +144,7 @@ void ConnectionSendThread::Trigger() bool ConnectionSendThread::packetsQueued() { - std::list peerIds = m_connection->getPeerIDs(); + std::vector peerIds = m_connection->getPeerIDs(); if (!m_outgoing_queue.empty() && !peerIds.empty()) return true; @@ -171,8 +171,8 @@ bool ConnectionSendThread::packetsQueued() void ConnectionSendThread::runTimeouts(float dtime) { - std::list timeouted_peers; - std::list peerIds = m_connection->getPeerIDs(); + std::vector timeouted_peers; + std::vector peerIds = m_connection->getPeerIDs(); for (session_t &peerId : peerIds) { PeerHelper peer = m_connection->getPeerNoEx(peerId); @@ -548,7 +548,7 @@ void ConnectionSendThread::disconnect() // Send to all - std::list peerids = m_connection->getPeerIDs(); + std::vector peerids = m_connection->getPeerIDs(); for (session_t peerid : peerids) { sendAsPacket(peerid, 0, data, false); @@ -620,7 +620,7 @@ void ConnectionSendThread::sendReliable(ConnectionCommand &c) void ConnectionSendThread::sendToAll(u8 channelnum, const SharedBuffer &data) { - std::list peerids = m_connection->getPeerIDs(); + std::vector peerids = m_connection->getPeerIDs(); for (session_t peerid : peerids) { send(peerid, channelnum, data); @@ -629,7 +629,7 @@ void ConnectionSendThread::sendToAll(u8 channelnum, const SharedBuffer &data void ConnectionSendThread::sendToAllReliable(ConnectionCommand &c) { - std::list peerids = m_connection->getPeerIDs(); + std::vector peerids = m_connection->getPeerIDs(); for (session_t peerid : peerids) { PeerHelper peer = m_connection->getPeerNoEx(peerid); @@ -643,8 +643,8 @@ void ConnectionSendThread::sendToAllReliable(ConnectionCommand &c) void ConnectionSendThread::sendPackets(float dtime) { - std::list peerIds = m_connection->getPeerIDs(); - std::list pendingDisconnect; + std::vector peerIds = m_connection->getPeerIDs(); + std::vector pendingDisconnect; std::map pending_unreliable; const unsigned int peer_packet_quota = m_iteration_packets_avaialble @@ -843,13 +843,11 @@ void *ConnectionReceiveThread::run() if (debug_print_timer > 20.0) { debug_print_timer -= 20.0; - std::list peerids = m_connection->getPeerIDs(); + std::vector peerids = m_connection->getPeerIDs(); - for (std::list::iterator i = peerids.begin(); - i != peerids.end(); - i++) + for (auto id : peerids) { - PeerHelper peer = m_connection->getPeerNoEx(*i); + PeerHelper peer = m_connection->getPeerNoEx(id); if (!peer) continue; @@ -1039,7 +1037,7 @@ void ConnectionReceiveThread::receive(SharedBuffer &packetdata, bool ConnectionReceiveThread::getFromBuffers(session_t &peer_id, SharedBuffer &dst) { - std::list peerids = m_connection->getPeerIDs(); + std::vector peerids = m_connection->getPeerIDs(); for (session_t peerid : peerids) { PeerHelper peer = m_connection->getPeerNoEx(peerid); -- cgit v1.2.3