summaryrefslogtreecommitdiffstats
path: root/src/Globals.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-04-05 02:38:43 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2021-04-12 23:35:07 +0200
commit4cd49d7eca5f8fd53eb98577a1f218a5086704bb (patch)
tree09bf29a1d30a37445796ed70867f934435c4261f /src/Globals.h
parentFixed generator for the Mega Taiga biome (#5129) (diff)
downloadcuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar
cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.gz
cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.bz2
cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.lz
cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.xz
cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.tar.zst
cuberite-4cd49d7eca5f8fd53eb98577a1f218a5086704bb.zip
Diffstat (limited to 'src/Globals.h')
-rw-r--r--src/Globals.h18
1 files changed, 13 insertions, 5 deletions
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 C = int, typename T>
typename std::enable_if<std::is_arithmetic<T>::value, C>::type FloorC(T a_Value)
{
return static_cast<C>(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 C = int, typename T>
typename std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC(T a_Value)
{
@@ -356,9 +356,17 @@ typename std::enable_if<std::is_arithmetic<T>::value, C>::type CeilC(T a_Value)
-// a tick is 50 ms
-using cTickTime = std::chrono::duration<int, std::ratio_multiply<std::chrono::milliseconds::period, std::ratio<50>>>;
-using cTickTimeLong = std::chrono::duration<Int64, cTickTime::period>;
+// A time duration representing a Minecraft tick (50 ms), capable of storing at least 32'767 ticks.
+using cTickTime = std::chrono::duration<signed int, std::ratio_multiply<std::chrono::milliseconds::period, std::ratio<50>>>;
+
+// A time duration representing a Minecraft tick (50 ms), capable of storing at least a 64 bit signed duration.
+using cTickTimeLong = std::chrono::duration<signed long long int, cTickTime::period>;
+
+/** 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<std::byte>;
using ContiguousByteBufferView = std::basic_string_view<std::byte>;