summaryrefslogtreecommitdiffstats
path: root/src/Protocol
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-03-20 21:58:19 +0100
committerGitHub <noreply@github.com>2021-03-20 21:58:19 +0100
commit90369deb5a870674ab02a26a93a71f06eafe9293 (patch)
treee37bb9272ea0265db7dce611120ed63381ca2626 /src/Protocol
parentDon't send ping updates one packet at a time (diff)
downloadcuberite-90369deb5a870674ab02a26a93a71f06eafe9293.tar
cuberite-90369deb5a870674ab02a26a93a71f06eafe9293.tar.gz
cuberite-90369deb5a870674ab02a26a93a71f06eafe9293.tar.bz2
cuberite-90369deb5a870674ab02a26a93a71f06eafe9293.tar.lz
cuberite-90369deb5a870674ab02a26a93a71f06eafe9293.tar.xz
cuberite-90369deb5a870674ab02a26a93a71f06eafe9293.tar.zst
cuberite-90369deb5a870674ab02a26a93a71f06eafe9293.zip
Diffstat (limited to '')
-rw-r--r--src/Protocol/Protocol.h2
-rw-r--r--src/Protocol/Protocol_1_8.cpp10
-rw-r--r--src/Protocol/Protocol_1_8.h2
3 files changed, 8 insertions, 6 deletions
diff --git a/src/Protocol/Protocol.h b/src/Protocol/Protocol.h
index 3c70cdb55..71fc37d04 100644
--- a/src/Protocol/Protocol.h
+++ b/src/Protocol/Protocol.h
@@ -438,7 +438,7 @@ public:
virtual void SendTabCompletionResults (const AStringVector & a_Results) = 0;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) = 0;
virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) = 0;
- virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle) = 0;
+ virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_WorldDate, bool a_DoDaylightCycle) = 0;
virtual void SendUnleashEntity (const cEntity & a_Entity) = 0;
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) = 0;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) = 0;
diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp
index 79f75fcc5..fe99ab91a 100644
--- a/src/Protocol/Protocol_1_8.cpp
+++ b/src/Protocol/Protocol_1_8.cpp
@@ -1566,18 +1566,20 @@ void cProtocol_1_8_0::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int
-void cProtocol_1_8_0::SendTimeUpdate(Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle)
+void cProtocol_1_8_0::SendTimeUpdate(Int64 a_WorldAge, Int64 a_WorldDate, bool a_DoDaylightCycle)
{
ASSERT(m_State == 3); // In game mode?
+
if (!a_DoDaylightCycle)
{
- // When writing a "-" before the number the client ignores it but it will stop the client-side time expiration.
- a_TimeOfDay = std::min(-a_TimeOfDay, -1LL);
+ // Negating the date stops time from advancing on the client
+ // (the std::min construction is to handle the case where the date is exactly zero):
+ a_WorldDate = std::min(-a_WorldDate, -1LL);
}
cPacketizer Pkt(*this, pktTimeUpdate);
Pkt.WriteBEInt64(a_WorldAge);
- Pkt.WriteBEInt64(a_TimeOfDay);
+ Pkt.WriteBEInt64(a_WorldDate);
}
diff --git a/src/Protocol/Protocol_1_8.h b/src/Protocol/Protocol_1_8.h
index ae6d09417..d899dc067 100644
--- a/src/Protocol/Protocol_1_8.h
+++ b/src/Protocol/Protocol_1_8.h
@@ -119,7 +119,7 @@ public:
virtual void SendTabCompletionResults (const AStringVector & a_Results) override;
virtual void SendThunderbolt (int a_BlockX, int a_BlockY, int a_BlockZ) override;
virtual void SendTitleTimes (int a_FadeInTicks, int a_DisplayTicks, int a_FadeOutTicks) override;
- virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_TimeOfDay, bool a_DoDaylightCycle) override;
+ virtual void SendTimeUpdate (Int64 a_WorldAge, Int64 a_WorldDate, bool a_DoDaylightCycle) override;
virtual void SendUnleashEntity (const cEntity & a_Entity) override;
virtual void SendUnloadChunk (int a_ChunkX, int a_ChunkZ) override;
virtual void SendUpdateBlockEntity (cBlockEntity & a_BlockEntity) override;