]> git.lizzy.rs Git - minetest.git/blobdiff - src/connection.h
Fix a crash (assert) when client set serial version < 24 in INIT
[minetest.git] / src / connection.h
index 338ee964ce36378ff4aff16579ef4255aa6befe2..be1627dfa079b6484018d6b187b9309177665b9f 100644 (file)
@@ -120,9 +120,9 @@ class IncomingDataCorruption : public BaseException
 };
 
 typedef enum MTProtocols {
-       PRIMARY,
-       UDP,
-       MINETEST_RELIABLE_UDP
+       MTP_PRIMARY,
+       MTP_UDP,
+       MTP_MINETEST_RELIABLE_UDP
 } MTProtocols;
 
 #define SEQNUM_MAX 65535
@@ -162,16 +162,19 @@ inline bool seqnum_in_window(u16 seqnum, u16 next,u16 window_size)
 struct BufferedPacket
 {
        BufferedPacket(u8 *a_data, u32 a_size):
-               data(a_data, a_size), time(0.0), totaltime(0.0), absolute_send_time(-1)
+               data(a_data, a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
+               resend_count(0)
        {}
        BufferedPacket(u32 a_size):
-               data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1)
+               data(a_size), time(0.0), totaltime(0.0), absolute_send_time(-1),
+               resend_count(0)
        {}
        SharedBuffer<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;
        Address address; // Sender or destination
+       unsigned int resend_count;
 };
 
 // This adds the base headers to the data and makes a packet out of it
@@ -915,13 +918,17 @@ class ConnectionSendThread : public JThread {
 public:
        friend class UDPPeer;
 
-       ConnectionSendThread(Connection* parent,
-                                                       unsigned int max_packet_size, float timeout);
+       ConnectionSendThread(unsigned int max_packet_size, float timeout);
 
        void * Thread       ();
 
        void Trigger();
 
+       void setParent(Connection* parent) {
+               assert(parent != NULL);
+               m_connection = parent;
+       }
+
        void setPeerTimeout(float peer_timeout)
                { m_timeout = peer_timeout; }
 
@@ -967,11 +974,15 @@ class ConnectionSendThread : public JThread {
 
 class ConnectionReceiveThread : public JThread {
 public:
-       ConnectionReceiveThread(Connection* parent,
-                                                       unsigned int max_packet_size);
+       ConnectionReceiveThread(unsigned int max_packet_size);
 
        void * Thread       ();
 
+       void setParent(Connection* parent) {
+               assert(parent != NULL);
+               m_connection = parent;
+       }
+
 private:
        void receive        ();