aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Time/GameTime.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-04-20 10:26:04 +0200
committerShauren <shauren.trinity@gmail.com>2021-04-20 10:26:04 +0200
commit7e78e25e34c5725a2c1ed870000a935573dd814c (patch)
treefccdca5787f3135cf62fe9d117075f18bce2d10b /src/server/game/Time/GameTime.cpp
parent81eac826562f8e75de1842c59c8d35cf050b0f21 (diff)
Core/Misc: New function in GameTime allowing selecting std::chrono clock type by template argument
Diffstat (limited to 'src/server/game/Time/GameTime.cpp')
-rw-r--r--src/server/game/Time/GameTime.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/server/game/Time/GameTime.cpp b/src/server/game/Time/GameTime.cpp
index b1a3d269cd9..097ed8c4789 100644
--- a/src/server/game/Time/GameTime.cpp
+++ b/src/server/game/Time/GameTime.cpp
@@ -56,6 +56,24 @@ namespace GameTime
return GameTimeSteadyPoint;
}
+ template<typename Clock>
+ typename Clock::time_point GetGameTimePoint()
+ {
+ static_assert(!std::is_same<Clock, Clock>::value, "Missing specialization for GetGameTimePoint");
+ }
+
+ template<>
+ TC_GAME_API std::chrono::system_clock::time_point GetGameTimePoint<std::chrono::system_clock>()
+ {
+ return GetGameTimeSystemPoint();
+ }
+
+ template<>
+ TC_GAME_API std::chrono::steady_clock::time_point GetGameTimePoint<std::chrono::steady_clock>()
+ {
+ return GetGameTimeSteadyPoint();
+ }
+
uint32 GetUptime()
{
return uint32(GameTime - StartTime);