system.GetTime(): Use SDL_GetTicks() instead of clock_gettime()

Some games (e.g. Toushin Toshi 3) malfunction when system.GetTime()
returns a negative number.

On many systems clock_gettime(CLOCK_MONOTONIC) returns the time since
OS startup, but this wraps to a negative number after about 24.8 days.

As a mitigation, use SDL_GetTicks() instead, which returns the elapsed
time since game startup.
This commit is contained in:
kichikuou
2024-04-02 13:26:53 +09:00
parent a92e26c49c
commit 7e54e159df
+1 -3
View File
@@ -2383,9 +2383,7 @@ _Noreturn void _vm_error(const char *fmt, ...)
int vm_time(void)
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return (ts.tv_sec * 1000) + (ts.tv_nsec / 1000000);
return SDL_GetTicks();
}
void vm_sleep(int ms)