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/Globals.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/Globals.h') diff --git a/src/Globals.h b/src/Globals.h index d5af4fa11..dc0bdc3ae 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -338,14 +338,14 @@ T Clamp(T a_Value, T a_Min, T a_Max) -/** Floors a value, then casts it to C (an int by default) */ +/** Floors a value, then casts it to C (an int by default). */ template typename std::enable_if::value, C>::type FloorC(T a_Value) { return static_cast(std::floor(a_Value)); } -/** Ceils a value, then casts it to C (an int by default) */ +/** Ceils a value, then casts it to C (an int by default). */ template typename std::enable_if::value, C>::type CeilC(T a_Value) { @@ -356,9 +356,17 @@ typename std::enable_if::value, C>::type CeilC(T a_Value) -// a tick is 50 ms -using cTickTime = std::chrono::duration>>; -using cTickTimeLong = std::chrono::duration; +// A time duration representing a Minecraft tick (50 ms), capable of storing at least 32'767 ticks. +using cTickTime = std::chrono::duration>>; + +// A time duration representing a Minecraft tick (50 ms), capable of storing at least a 64 bit signed duration. +using cTickTimeLong = std::chrono::duration; + +/** Converts a literal to a tick time. */ +constexpr cTickTimeLong operator ""_tick(const unsigned long long a_Ticks) +{ + return cTickTimeLong(a_Ticks); +} using ContiguousByteBuffer = std::basic_string; using ContiguousByteBufferView = std::basic_string_view; -- cgit v1.2.3