From 4cd49d7eca5f8fd53eb98577a1f218a5086704bb Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Mon, 5 Apr 2021 01:38:43 +0100 Subject: Fix sending incorrect date values on world change Yak shave: make more things use cTickTime. Fix a couple of incorrect modulo-on-millisecond-value by making them use WorldTickAge. --- src/Protocol/Protocol_1_8.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/Protocol/Protocol_1_8.cpp') diff --git a/src/Protocol/Protocol_1_8.cpp b/src/Protocol/Protocol_1_8.cpp index 7d4dfb85d..3c377ce21 100644 --- a/src/Protocol/Protocol_1_8.cpp +++ b/src/Protocol/Protocol_1_8.cpp @@ -1566,20 +1566,23 @@ void cProtocol_1_8_0::SendTitleTimes(int a_FadeInTicks, int a_DisplayTicks, int -void cProtocol_1_8_0::SendTimeUpdate(Int64 a_WorldAge, Int64 a_WorldDate, bool a_DoDaylightCycle) +void cProtocol_1_8_0::SendTimeUpdate(const cTickTimeLong a_WorldAge, const cTickTimeLong a_WorldDate, const bool a_DoDaylightCycle) { ASSERT(m_State == 3); // In game mode? - if (!a_DoDaylightCycle) + cPacketizer Pkt(*this, pktTimeUpdate); + Pkt.WriteBEInt64(a_WorldAge.count()); + + if (a_DoDaylightCycle) + { + Pkt.WriteBEInt64(a_WorldDate.count()); + } + else { // 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); + Pkt.WriteBEInt64(std::min(-a_WorldDate.count(), -1LL)); } - - cPacketizer Pkt(*this, pktTimeUpdate); - Pkt.WriteBEInt64(a_WorldAge); - Pkt.WriteBEInt64(a_WorldDate); } -- cgit v1.2.3