# HG changeset patch # User Loïc Guilloux # Date 2021-02-09 20:21:57 # Node ID ed9f9bbb6692ce44c7a69afee66f119070f19a01 # Parent fcbbb366d0743a8343dab4dec7797b3c5f6d5fef Fix: [Win32] Set minimum resolution for timers to 1ms. (#8660) diff --git a/src/os/windows/crashlog_win.cpp b/src/os/windows/crashlog_win.cpp --- a/src/os/windows/crashlog_win.cpp +++ b/src/os/windows/crashlog_win.cpp @@ -21,6 +21,7 @@ #include #include +#include #include "../../safeguards.h" @@ -540,6 +541,9 @@ void *_safe_esp = nullptr; static LONG WINAPI ExceptionHandler(EXCEPTION_POINTERS *ep) { + /* Restore system timer resolution. */ + timeEndPeriod(1); + /* Disable our event loop. */ SetWindowLongPtr(GetActiveWindow(), GWLP_WNDPROC, (LONG_PTR)&DefWindowProc); diff --git a/src/os/windows/win32.cpp b/src/os/windows/win32.cpp --- a/src/os/windows/win32.cpp +++ b/src/os/windows/win32.cpp @@ -18,6 +18,7 @@ #define NO_SHOBJIDL_SORTDIRECTION // Avoid multiple definition of SORT_ASCENDING #include /* SHGetFolderPath */ #include +#include #include "win32.h" #include "../../fios.h" #include "../../core/alloc_func.hpp" @@ -413,6 +414,9 @@ int APIENTRY WinMain(HINSTANCE hInstance int argc; char *argv[64]; // max 64 command line arguments + /* Set system timer resolution to 1ms. */ + timeBeginPeriod(1); + CrashLog::InitialiseCrashLog(); #if defined(UNICODE) @@ -440,6 +444,10 @@ int APIENTRY WinMain(HINSTANCE hInstance for (int i = 0; i < argc; i++) ValidateString(argv[i]); openttd_main(argc, argv); + + /* Restore system timer resolution. */ + timeEndPeriod(1); + free(cmdline); return 0; }