mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use chrono for GetTicks and move into Platform.Common.cpp
This commit is contained in:
parent
e19738b5d3
commit
a83337b2da
|
@ -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<uint32_t>(std::chrono::duration_cast<std::chrono::milliseconds>(processTime).count());
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
|
|
@ -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<uint32_t>(ts.tv_sec * 1000 + ts.tv_nsec / 1000000);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
|
|
@ -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<uint32_t>(runningDelta.QuadPart / _frequency);
|
||||
}
|
||||
|
||||
void InitTicks()
|
||||
{
|
||||
LARGE_INTEGER freq;
|
||||
QueryPerformanceFrequency(&freq);
|
||||
_frequency = static_cast<uint32_t>(freq.QuadPart / 1000);
|
||||
QueryPerformanceCounter(&_entryTimestamp);
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
|
|
@ -125,7 +125,6 @@ namespace Platform
|
|||
uint32_t GetTicks();
|
||||
|
||||
void Sleep(uint32_t ms);
|
||||
void InitTicks();
|
||||
} // namespace Platform
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
|
Loading…
Reference in New Issue