Resend blocks when modified while sending to client
authorJeija <norrepli@gmail.com>
Mon, 15 Feb 2016 15:05:40 +0000 (16:05 +0100)
committerest31 <MTest31@outlook.com>
Sat, 12 Mar 2016 22:59:44 +0000 (23:59 +0100)
src/clientiface.cpp
src/clientiface.h

index 8a1a62694f6aed9e220403d246cbc8a488ef7ee8..a3a17d435f3d77a3067e8a83967fccd06f790c36 100644 (file)
@@ -370,17 +370,21 @@ queue_full_break:
 
 void RemoteClient::GotBlock(v3s16 p)
 {
-       if(m_blocks_sending.find(p) != m_blocks_sending.end())
-               m_blocks_sending.erase(p);
-       else
-       {
-               m_excess_gotblocks++;
+       if (m_blocks_modified.find(p) == m_blocks_modified.end()) {
+               if (m_blocks_sending.find(p) != m_blocks_sending.end())
+                       m_blocks_sending.erase(p);
+               else
+                       m_excess_gotblocks++;
+
+               m_blocks_sent.insert(p);
        }
-       m_blocks_sent.insert(p);
 }
 
 void RemoteClient::SentBlock(v3s16 p)
 {
+       if (m_blocks_modified.find(p) != m_blocks_modified.end())
+               m_blocks_modified.erase(p);
+
        if(m_blocks_sending.find(p) == m_blocks_sending.end())
                m_blocks_sending[p] = 0.0;
        else
@@ -397,6 +401,7 @@ void RemoteClient::SetBlockNotSent(v3s16 p)
                m_blocks_sending.erase(p);
        if(m_blocks_sent.find(p) != m_blocks_sent.end())
                m_blocks_sent.erase(p);
+       m_blocks_modified.insert(p);
 }
 
 void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
@@ -409,6 +414,7 @@ void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
                        i != blocks.end(); ++i)
        {
                v3s16 p = i->first;
+               m_blocks_modified.insert(p);
 
                if(m_blocks_sending.find(p) != m_blocks_sending.end())
                        m_blocks_sending.erase(p);
index d7622cad3e9e53961bab493ae1fcde6fb8bb80b7..c09942909f8136be3dfe14dcc7e7fb050a3315f4 100644 (file)
@@ -394,6 +394,16 @@ private:
        */
        std::map<v3s16, float> m_blocks_sending;
 
+       /*
+               Blocks that have been modified since last sending them.
+               These blocks will not be marked as sent, even if the
+               client reports it has received them to account for blocks
+               that are being modified while on the line.
+
+               List of block positions.
+       */
+       std::set<v3s16> m_blocks_modified;
+
        /*
                Count of excess GotBlocks().
                There is an excess amount because the client sometimes