Fix Travis/unittest broken since b662a45
[oweals/minetest.git] / src / network / connection.h
index fe2c9819d3e82c8b82c4947ce7141c6202567225..3a8388522b83852c5a1e98ed13272a74de34fb64 100644 (file)
@@ -175,7 +175,7 @@ struct BufferedPacket
        Buffer<u8> data; // Data of the packet, including headers
        float time; // Seconds from buffering the packet or re-sending
        float totaltime; // Seconds from buffering the packet
-       unsigned int absolute_send_time;
+       u64 absolute_send_time;
        Address address; // Sender or destination
        unsigned int resend_count;
 };
@@ -383,7 +383,7 @@ struct OutgoingPacket
        bool reliable;
        bool ack;
 
-       OutgoingPacket(u16 peer_id_, u8 channelnum_, SharedBuffer<u8> data_,
+       OutgoingPacket(u16 peer_id_, u8 channelnum_, const SharedBuffer<u8> &data_,
                        bool reliable_,bool ack_=false):
                peer_id(peer_id_),
                channelnum(channelnum_),
@@ -448,7 +448,7 @@ struct ConnectionCommand
                reliable = reliable_;
        }
 
-       void ack(u16 peer_id_, u8 channelnum_, SharedBuffer<u8> data_)
+       void ack(u16 peer_id_, u8 channelnum_, const SharedBuffer<u8> &data_)
        {
                type = CONCMD_ACK;
                peer_id = peer_id_;
@@ -457,7 +457,7 @@ struct ConnectionCommand
                reliable = false;
        }
 
-       void createPeer(u16 peer_id_, SharedBuffer<u8> data_)
+       void createPeer(u16 peer_id_, const SharedBuffer<u8> &data_)
        {
                type = CONCMD_CREATE_PEER;
                peer_id = peer_id_;
@@ -467,7 +467,7 @@ struct ConnectionCommand
                raw = true;
        }
 
-       void disableLegacy(u16 peer_id_, SharedBuffer<u8> data_)
+       void disableLegacy(u16 peer_id_, const SharedBuffer<u8> &data_)
        {
                type = CONCMD_DISABLE_LEGACY;
                peer_id = peer_id_;
@@ -663,8 +663,7 @@ class Peer {
                        m_last_rtt(-1.0),
                        m_usage(0),
                        m_timeout_counter(0.0),
-                       m_last_timeout_check(porting::getTimeMs()),
-                       m_has_sent_with_id(false)
+                       m_last_timeout_check(porting::getTimeMs())
                {
                        m_rtt.avg_rtt = -1.0;
                        m_rtt.jitter_avg = -1.0;
@@ -687,21 +686,16 @@ class Peer {
                virtual void PutReliableSendCommand(ConnectionCommand &c,
                                                unsigned int max_packet_size) {};
 
-               virtual bool isActive() { return false; };
-
                virtual bool getAddress(MTProtocols type, Address& toset) = 0;
 
+               bool isPendingDeletion()
+               { MutexAutoLock lock(m_exclusive_access_mutex); return m_pending_deletion; };
+
                void ResetTimeout()
                        {MutexAutoLock lock(m_exclusive_access_mutex); m_timeout_counter=0.0; };
 
                bool isTimedOut(float timeout);
 
-               void setSentWithID()
-               { MutexAutoLock lock(m_exclusive_access_mutex); m_has_sent_with_id = true; };
-
-               bool hasSentWithID()
-               { MutexAutoLock lock(m_exclusive_access_mutex); return m_has_sent_with_id; };
-
                unsigned int m_increment_packets_remaining;
                unsigned int m_increment_bytes_remaining;
 
@@ -738,8 +732,8 @@ class Peer {
                virtual void reportRTT(float rtt) {};
 
                void RTTStatistics(float rtt,
-                                                       std::string profiler_id="",
-                                                       unsigned int num_samples=1000);
+                                                       const std::string &profiler_id = "",
+                                                       unsigned int num_samples = 1000);
 
                bool IncUseCount();
                void DecUseCount();
@@ -776,8 +770,6 @@ class Peer {
                float m_timeout_counter;
 
                u32 m_last_timeout_check;
-
-               bool m_has_sent_with_id;
 };
 
 class UDPPeer : public Peer
@@ -795,9 +787,6 @@ public:
        void PutReliableSendCommand(ConnectionCommand &c,
                                                        unsigned int max_packet_size);
 
-       bool isActive()
-       { return ((hasSentWithID()) && (!m_pending_deletion)); };
-
        bool getAddress(MTProtocols type, Address& toset);
 
        void setNonLegacyPeer();
@@ -885,7 +874,7 @@ struct ConnectionEvent
                return "Invalid ConnectionEvent";
        }
 
-       void dataReceived(u16 peer_id_, SharedBuffer<u8> data_)
+       void dataReceived(u16 peer_id_, const SharedBuffer<u8> &data_)
        {
                type = CONNEVENT_DATA_RECEIVED;
                peer_id = peer_id_;