summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorBartłomiej T. Listwon <blistwon@gmail.com>2022-01-08 13:10:27 +0100
committerBartłomiej T. Listwon <blistwon@gmail.com>2022-01-08 13:10:27 +0100
commit24fe82da633a847c4ff294fe55acabacfa3fbb2a (patch)
tree2b28d59cb0a9255f474bd1d6c578005b706c9d8d /platform
parent13d25f99805c7c970708277ceae6ae3b84893642 (diff)
UWP: Simplify QueryPerformanceCounter usage
Diffstat (limited to 'platform')
-rw-r--r--platform/uwp/os_uwp.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp
index 57603c6655..ca486633bf 100644
--- a/platform/uwp/os_uwp.cpp
+++ b/platform/uwp/os_uwp.cpp
@@ -136,12 +136,8 @@ void OS_UWP::initialize_core() {
NetSocketPosix::make_default();
// We need to know how often the clock is updated
- if (!QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second))
- ticks_per_second = 1000;
- // If timeAtGameStart is 0 then we get the time since
- // the start of the computer when we call GetGameTime()
- ticks_start = 0;
- ticks_start = get_ticks_usec();
+ QueryPerformanceFrequency((LARGE_INTEGER *)&ticks_per_second);
+ QueryPerformanceCounter((LARGE_INTEGER *)&ticks_start);
IPUnix::make_default();
@@ -525,6 +521,9 @@ uint64_t OS_UWP::get_ticks_usec() const {
// This is the number of clock ticks since start
QueryPerformanceCounter((LARGE_INTEGER *)&ticks);
+ // Subtract the ticks at game start to get
+ // the ticks since the game started
+ ticks -= ticks_start;
// Divide by frequency to get the time in seconds
// original calculation shown below is subject to overflow
@@ -544,9 +543,6 @@ uint64_t OS_UWP::get_ticks_usec() const {
// seconds
time += seconds * 1000000L;
- // Subtract the time at game start to get
- // the time since the game started
- time -= ticks_start;
return time;
}