diff --git a/src/openrct2/platform/Platform.Common.cpp b/src/openrct2/platform/Platform.Common.cpp index e8744380f8..5f094ac6d8 100644 --- a/src/openrct2/platform/Platform.Common.cpp +++ b/src/openrct2/platform/Platform.Common.cpp @@ -48,7 +48,6 @@ namespace Platform Platform::AndroidInitClassLoader(); #endif // __ANDROID__ - InitTicks(); BitCountInit(); MaskInit(); } @@ -144,4 +143,12 @@ namespace Platform std::this_thread::sleep_for(std::chrono::milliseconds(ms)); } + static const auto _processStartTime = std::chrono::high_resolution_clock::now(); + + uint32_t GetTicks() + { + const auto processTime = std::chrono::high_resolution_clock::now() - _processStartTime; + return static_cast(std::chrono::duration_cast(processTime).count()); + } + } // namespace Platform diff --git a/src/openrct2/platform/Platform.Posix.cpp b/src/openrct2/platform/Platform.Posix.cpp index 18ae7f50c0..381d96100f 100644 --- a/src/openrct2/platform/Platform.Posix.cpp +++ b/src/openrct2/platform/Platform.Posix.cpp @@ -379,20 +379,6 @@ namespace Platform return u8"app_285330" PATH_SEPARATOR u8"depot_285331"; } - void InitTicks() - { - } - - uint32_t GetTicks() - { - struct timespec ts; - if (clock_gettime(CLOCK_MONOTONIC, &ts) != 0) - { - LOG_FATAL("clock_gettime failed"); - exit(-1); - } - return static_cast(ts.tv_sec * 1000 + ts.tv_nsec / 1000000); - } } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform.Win32.cpp b/src/openrct2/platform/Platform.Win32.cpp index 9706056eff..402848f9e9 100644 --- a/src/openrct2/platform/Platform.Win32.cpp +++ b/src/openrct2/platform/Platform.Win32.cpp @@ -41,10 +41,6 @@ # pragma comment( \ linker, \ "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") - -static uint32_t _frequency = 0; -static LARGE_INTEGER _entryTimestamp; - // The name of the mutex used to prevent multiple instances of the game from running static constexpr wchar_t SINGLE_INSTANCE_MUTEX_NAME[] = L"RollerCoaster Tycoon 2_GSKMUTEX"; @@ -901,24 +897,6 @@ namespace Platform return false; } - uint32_t GetTicks() - { - LARGE_INTEGER pfc; - QueryPerformanceCounter(&pfc); - - LARGE_INTEGER runningDelta; - runningDelta.QuadPart = pfc.QuadPart - _entryTimestamp.QuadPart; - - return static_cast(runningDelta.QuadPart / _frequency); - } - - void InitTicks() - { - LARGE_INTEGER freq; - QueryPerformanceFrequency(&freq); - _frequency = static_cast(freq.QuadPart / 1000); - QueryPerformanceCounter(&_entryTimestamp); - } } // namespace Platform #endif diff --git a/src/openrct2/platform/Platform.h b/src/openrct2/platform/Platform.h index 1384fa3661..11f59e4f0f 100644 --- a/src/openrct2/platform/Platform.h +++ b/src/openrct2/platform/Platform.h @@ -125,7 +125,6 @@ namespace Platform uint32_t GetTicks(); void Sleep(uint32_t ms); - void InitTicks(); } // namespace Platform #ifdef __ANDROID__