]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/connection.cpp
Write common mapgen params to map_meta.txt on world initialization
[dragonfireclient.git] / src / connection.cpp
index a9f1d5457694cde30ca91f0d3013d0b470aee8ac..2ee6d2c6e8f48cb6b4c43c6a7c4f907a75f9b14d 100644 (file)
@@ -372,7 +372,7 @@ void ReliablePacketBuffer::insert(BufferedPacket &p,u16 next_expected)
                        fprintf(stderr, "Old: seqnum: %05d size: %04d, address: %s\n",
                                        readU16(&(i->data[BASE_HEADER_SIZE+1])),i->data.getSize(),
                                        i->address.serializeString().c_str());
-                       fprintf(stderr, "New: seqnum: %05d size: %04d, address: %s\n",
+                       fprintf(stderr, "New: seqnum: %05d size: %04u, address: %s\n",
                                        readU16(&(p.data[BASE_HEADER_SIZE+1])),p.data.getSize(),
                                        p.address.serializeString().c_str());
                        throw IncomingDataCorruption("duplicated packet isn't same as original one");
@@ -707,14 +707,14 @@ void Channel::UpdateTimers(float dtime,bool legacy_peer)
 
                unsigned int packet_loss = 11; /* use a neutral value for initialization */
                unsigned int packets_successfull = 0;
-               unsigned int packet_too_late = 0;
+               //unsigned int packet_too_late = 0;
 
                bool reasonable_amount_of_data_transmitted = false;
 
                {
                        JMutexAutoLock internal(m_internal_mutex);
                        packet_loss = current_packet_loss;
-                       packet_too_late = current_packet_too_late;
+                       //packet_too_late = current_packet_too_late;
                        packets_successfull = current_packet_successfull;
 
                        if (current_bytes_transfered > (unsigned int) (window_size*512/2))
@@ -2334,6 +2334,11 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
 
        u8 type = readU8(&(packetdata[0]));
 
+       if (MAX_UDP_PEERS <= 65535 && peer_id >= MAX_UDP_PEERS) {
+               errorstream << "Something is wrong with peer_id" << std::endl;
+               assert(0);
+       }
+
        if(type == TYPE_CONTROL)
        {
                if(packetdata.getSize() < 2)
@@ -2341,8 +2346,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
 
                u8 controltype = readU8(&(packetdata[1]));
 
-               if( (controltype == CONTROLTYPE_ACK)
-                               && (peer_id <= MAX_UDP_PEERS))
+               if(controltype == CONTROLTYPE_ACK)
                {
                        assert(channel != 0);
                        if(packetdata.getSize() < 4)
@@ -2399,8 +2403,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
                        }
                        throw ProcessedSilentlyException("Got an ACK");
                }
-               else if((controltype == CONTROLTYPE_SET_PEER_ID)
-                               && (peer_id <= MAX_UDP_PEERS))
+               else if(controltype == CONTROLTYPE_SET_PEER_ID)
                {
                        // Got a packet to set our peer id
                        if(packetdata.getSize() < 4)
@@ -2432,8 +2435,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
 
                        throw ProcessedSilentlyException("Got a SET_PEER_ID");
                }
-               else if((controltype == CONTROLTYPE_PING)
-                               && (peer_id <= MAX_UDP_PEERS))
+               else if(controltype == CONTROLTYPE_PING)
                {
                        // Just ignore it, the incoming data already reset
                        // the timeout counter
@@ -2455,8 +2457,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
 
                        throw ProcessedSilentlyException("Got a DISCO");
                }
-               else if((controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
-                               && (peer_id <= MAX_UDP_PEERS))
+               else if(controltype == CONTROLTYPE_ENABLE_BIG_SEND_WINDOW)
                {
                        dynamic_cast<UDPPeer*>(&peer)->setNonLegacyPeer();
                        throw ProcessedSilentlyException("Got non legacy control");
@@ -2514,7 +2515,7 @@ SharedBuffer<u8> ConnectionReceiveThread::processPacket(Channel *channel,
                        //TODO throw some error
                }
        }
-       else if((peer_id <= MAX_UDP_PEERS) && (type == TYPE_RELIABLE))
+       else if(type == TYPE_RELIABLE)
        {
                assert(channel != 0);
                // Recursive reliable packets not allowed