From 42bad0edec58f42e4072360c52870d3be9ced3c5 Mon Sep 17 00:00:00 2001 From: Howaner Date: Sun, 10 Aug 2014 20:06:03 +0200 Subject: Added a comment and simplified code. --- src/ClientHandle.cpp | 9 +++------ src/World.cpp | 7 ++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp index 286c17513..37d7edbc1 100644 --- a/src/ClientHandle.cpp +++ b/src/ClientHandle.cpp @@ -341,15 +341,12 @@ void cClientHandle::Authenticate(const AString & a_Name, const AString & a_UUID, m_Protocol->SendWeather(World->GetWeather()); } - // Send time + // Send time: Int64 TimeOfDay = World->GetTimeOfDay(); if (!World->IsDaylightCycleEnabled()) { - TimeOfDay *= -1; - if (TimeOfDay == 0) - { - TimeOfDay = -1; - } + // When writing a "-" before the number the client ignores it but it will stop the client-side time expiration. + TimeOfDay = std::min(-TimeOfDay, -1); } m_Protocol->SendTimeUpdate(World->GetWorldAge(), TimeOfDay); diff --git a/src/World.cpp b/src/World.cpp index 0ae7f80a6..dcca0519e 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -2253,11 +2253,8 @@ void cWorld::BroadcastTimeUpdate(const cClientHandle * a_Exclude) int TimeOfDay = m_TimeOfDay; if (!m_IsDaylightCycleEnabled) { - TimeOfDay *= -1; - if (TimeOfDay == 0) - { - TimeOfDay = -1; - } + // When writing a "-" before the number the client ignores it but it will stop the client-side time expiration. + TimeOfDay = std::min(-TimeOfDay, -1); } cCSLock Lock(m_CSPlayers); -- cgit v1.2.3