Skip to content

Commit 089f9bb

Browse files
Jeijaest31
authored andcommitted
Resend blocks when modified while sending to client
1 parent 2c72f6d commit 089f9bb

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/clientiface.cpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -370,17 +370,21 @@ void RemoteClient::GetNextBlocks (
370370

371371
void RemoteClient::GotBlock(v3s16 p)
372372
{
373-
if(m_blocks_sending.find(p) != m_blocks_sending.end())
374-
m_blocks_sending.erase(p);
375-
else
376-
{
377-
m_excess_gotblocks++;
373+
if (m_blocks_modified.find(p) == m_blocks_modified.end()) {
374+
if (m_blocks_sending.find(p) != m_blocks_sending.end())
375+
m_blocks_sending.erase(p);
376+
else
377+
m_excess_gotblocks++;
378+
379+
m_blocks_sent.insert(p);
378380
}
379-
m_blocks_sent.insert(p);
380381
}
381382

382383
void RemoteClient::SentBlock(v3s16 p)
383384
{
385+
if (m_blocks_modified.find(p) != m_blocks_modified.end())
386+
m_blocks_modified.erase(p);
387+
384388
if(m_blocks_sending.find(p) == m_blocks_sending.end())
385389
m_blocks_sending[p] = 0.0;
386390
else
@@ -397,6 +401,7 @@ void RemoteClient::SetBlockNotSent(v3s16 p)
397401
m_blocks_sending.erase(p);
398402
if(m_blocks_sent.find(p) != m_blocks_sent.end())
399403
m_blocks_sent.erase(p);
404+
m_blocks_modified.insert(p);
400405
}
401406

402407
void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
@@ -409,6 +414,7 @@ void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
409414
i != blocks.end(); ++i)
410415
{
411416
v3s16 p = i->first;
417+
m_blocks_modified.insert(p);
412418

413419
if(m_blocks_sending.find(p) != m_blocks_sending.end())
414420
m_blocks_sending.erase(p);

src/clientiface.h

+10
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,16 @@ class RemoteClient
394394
*/
395395
std::map<v3s16, float> m_blocks_sending;
396396

397+
/*
398+
Blocks that have been modified since last sending them.
399+
These blocks will not be marked as sent, even if the
400+
client reports it has received them to account for blocks
401+
that are being modified while on the line.
402+
403+
List of block positions.
404+
*/
405+
std::set<v3s16> m_blocks_modified;
406+
397407
/*
398408
Count of excess GotBlocks().
399409
There is an excess amount because the client sometimes

0 commit comments

Comments
 (0)