]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/connection.cpp
Fix active_object_count and active_object_count_wider not getting updated between...
[dragonfireclient.git] / src / connection.cpp
index 1c424839f96c739ff1676b8d661eec4c133f6031..b9c5d2ac8bac413c1264ac6746e873fca0c471e7 100644 (file)
@@ -469,8 +469,9 @@ void Peer::reportRTT(float rtt)
                        if(m_max_packets_per_second < 100)
                                m_max_packets_per_second += 2;
                } else {
-                       if(m_max_packets_per_second > 5)
-                               m_max_packets_per_second *= 0.5;
+                       m_max_packets_per_second *= 0.8;
+                       if(m_max_packets_per_second < 10)
+                               m_max_packets_per_second = 10;
                }
        }
 
@@ -669,7 +670,7 @@ void Connection::receive()
        // TODO: We can not know how many layers of header there are.
        // For now, just assume there are no other than the base headers.
        u32 packet_maxsize = datasize + BASE_HEADER_SIZE;
-       Buffer<u8> packetdata(packet_maxsize);
+       SharedBuffer<u8> packetdata(packet_maxsize);
 
        bool single_wait_done = false;
        
@@ -1526,7 +1527,7 @@ ConnectionEvent Connection::waitEvent(u32 timeout_ms)
 {
        try{
                return m_event_queue.pop_front(timeout_ms);
-       } catch(ItemNotFoundException &e){
+       } catch(ItemNotFoundException &ex){
                ConnectionEvent e;
                e.type = CONNEVENT_NONE;
                return e;
@@ -1576,7 +1577,7 @@ void Connection::Disconnect()
        putCommand(c);
 }
 
-u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize)
+u32 Connection::Receive(u16 &peer_id, SharedBuffer<u8> &data)
 {
        for(;;){
                ConnectionEvent e = waitEvent(m_bc_receive_timeout);
@@ -1588,7 +1589,7 @@ u32 Connection::Receive(u16 &peer_id, u8 *data, u32 datasize)
                        throw NoIncomingDataException("No incoming data");
                case CONNEVENT_DATA_RECEIVED:
                        peer_id = e.peer_id;
-                       memcpy(data, *e.data, e.data.getSize());
+                       data = SharedBuffer<u8>(e.data);
                        return e.data.getSize();
                case CONNEVENT_PEER_ADDED: {
                        Peer tmp(e.peer_id, e.address);