Skip to content

Commit

Permalink
Resend blocks when modified while sending to client
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeija authored and est31 committed Mar 12, 2016
1 parent 2c72f6d commit 089f9bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/clientiface.cpp
Expand Up @@ -370,17 +370,21 @@ void RemoteClient::GetNextBlocks (

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
Expand All @@ -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)
Expand All @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions src/clientiface.h
Expand Up @@ -394,6 +394,16 @@ class RemoteClient
*/
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
Expand Down

0 comments on commit 089f9bb

Please sign in to comment.