From e17fbb31d6db3e6d2d9b68f5793ad8b2146f7bcc Mon Sep 17 00:00:00 2001
From: orwell96 <mono96.mml@gmail.com>
Date: Mon, 1 Feb 2016 19:29:53 +0100
Subject: [PATCH] Reset block send timer when invoking setBlock(s)NotSent()

As stated in this forum thread [1], I noticed that there is a
2 second interval in which inventory changes are shown on the
client. @yyt16384 found the source of these 2 seconds:
m_nothing_to_send_pause_timer is set to 2.0 every time there
are no changes to make, but this timer is not reset when
SetBlockNotSent or setBlocksNotSent are invoked. So in worst
case, the changed block will be sent over 2 seconds too late.

With this change, changed inventories are updated almost
immediately, but it causes additional connection load.
---
 src/clientiface.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/clientiface.cpp b/src/clientiface.cpp
index e7f127b84..8a1a62694 100644
--- a/src/clientiface.cpp
+++ b/src/clientiface.cpp
@@ -391,6 +391,7 @@ void RemoteClient::SentBlock(v3s16 p)
 void RemoteClient::SetBlockNotSent(v3s16 p)
 {
 	m_nearest_unsent_d = 0;
+	m_nothing_to_send_pause_timer = 0;
 
 	if(m_blocks_sending.find(p) != m_blocks_sending.end())
 		m_blocks_sending.erase(p);
@@ -401,6 +402,7 @@ void RemoteClient::SetBlockNotSent(v3s16 p)
 void RemoteClient::SetBlocksNotSent(std::map<v3s16, MapBlock*> &blocks)
 {
 	m_nearest_unsent_d = 0;
+	m_nothing_to_send_pause_timer = 0;
 
 	for(std::map<v3s16, MapBlock*>::iterator
 			i = blocks.begin();
-- 
GitLab