From 515d7eeb9ea6cd84afffc6e0b93e63bbf3d7635f Mon Sep 17 00:00:00 2001
From: James R <justsomejames2@gmail.com>
Date: Sat, 7 Nov 2020 01:54:54 -0800
Subject: [PATCH] Let's try an experiment: move the epoch forward as I_GetTime
 is called

This will make it even longer until time wraps around. Have you ever run a
srb2 server for 4 years straight?
---
 src/sdl/i_system.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c
index 8a70847e1e..d4ef86c5a4 100644
--- a/src/sdl/i_system.c
+++ b/src/sdl/i_system.c
@@ -2044,12 +2044,20 @@ ticcmd_t *I_BaseTiccmd2(void)
 //
 
 static Uint64 timer_frequency;
+
+static double tic_frequency;
 static Uint64 tic_epoch;
 
 tic_t I_GetTime(void)
 {
+	static double elapsed;
+
 	const Uint64 now = SDL_GetPerformanceCounter();
-	return (now - tic_epoch) * NEWTICRATE / timer_frequency;
+
+	elapsed += (now - tic_epoch) / tic_frequency;
+	tic_epoch = now; // moving epoch
+
+	return (tic_t)elapsed;
 }
 
 precise_t I_GetPreciseTime(void)
@@ -2069,6 +2077,8 @@ void I_StartupTimer(void)
 {
 	timer_frequency = SDL_GetPerformanceFrequency();
 	tic_epoch       = SDL_GetPerformanceCounter();
+
+	tic_frequency   = timer_frequency / NEWTICRATE;
 }
 
 void I_Sleep(void)
-- 
GitLab