From: bones_was_here Date: Sat, 14 Sep 2024 07:58:03 +0000 (+1000) Subject: Fix scr_loadingscreen_maxfps, related polishing X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=40cdb054026fe5acb26c79adabe3db55bee282c2;p=xonotic%2Fdarkplaces.git Fix scr_loadingscreen_maxfps, related polishing Since that cvar was implemented, unix time has grown too large to be represented precisely by a float, causing FPS to be much lower than configured. Should be using host.realtime (relative) here anyway. Simplifies Curl_Select() and improves some debug messages. Signed-off-by: bones_was_here --- diff --git a/cl_screen.c b/cl_screen.c index 7c2ab0dc..fcec1383 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -2249,11 +2249,10 @@ void CL_UpdateScreen(void) SCR_EndLoadingPlaque(); else if (scr_loadingscreen_maxfps.value > 0) { - static float lastupdate; - float now = Sys_DirtyTime(); - if (now - lastupdate < min(1.0f / scr_loadingscreen_maxfps.value, 0.1)) + static double lastupdate; + if (host.realtime - lastupdate < min(1.0f / scr_loadingscreen_maxfps.value, 0.1)) return; - lastupdate = now; + lastupdate = host.realtime; } } diff --git a/libcurl.c b/libcurl.c index d4b2defc..d8435720 100644 --- a/libcurl.c +++ b/libcurl.c @@ -1260,19 +1260,18 @@ Returns 0 immediately if there's no transfers to wait for, or > 0 if a transfer is ready or the timeout was reached. ==================== */ -int Curl_Select(int timeout_ms) +bool Curl_Select(int timeout_ms) { CURLMcode err; - int numfds; if (List_Is_Empty(&downloads)) - return 0; + return false; - err = qcurl_multi_wait(curlm, NULL, 0, timeout_ms, &numfds); + err = qcurl_multi_wait(curlm, NULL, 0, timeout_ms, NULL); if (err == CURLM_OK) - return numfds; - Con_Printf("curl_multi_wait() failed, code %d\n", err); - return 0; + return true; + Con_Printf(CON_ERROR "curl_multi_wait() failed with code %d\n", err); + return false; } /* diff --git a/libcurl.h b/libcurl.h index 908bc482..a494c937 100644 --- a/libcurl.h +++ b/libcurl.h @@ -14,7 +14,7 @@ typedef void (*curl_callback_t) (int status, size_t length_received, unsigned ch // code is one of the CURLCBSTATUS constants, or the HTTP error code (when > 0). void Curl_Frame(void); -int Curl_Select(int timeout_ms); +bool Curl_Select(int timeout_ms); qbool Curl_Running(void); qbool Curl_Begin_ToFile(const char *URL, double maxspeed, const char *name, int loadtype, qbool forthismap); diff --git a/sys_shared.c b/sys_shared.c index 1777353a..b9a353de 100644 --- a/sys_shared.c +++ b/sys_shared.c @@ -520,7 +520,7 @@ double Sys_Sleep(double time) } if(sys_debugsleep.integer) - Con_Printf("sys_debugsleep: requesting %u ", usec); + Con_Printf("sys_debugsleep: requested %u, ", usec); dt = Sys_DirtyTime(); // less important on newer libcurl so no need to disturb dedicated servers @@ -598,7 +598,7 @@ double Sys_Sleep(double time) dt = Sys_DirtyTime() - dt; if(sys_debugsleep.integer) - Con_Printf(" got %u oversleep %d\n", (unsigned int)(dt * 1000000), (unsigned int)(dt * 1000000) - usec); + Con_Printf("got %u, oversleep %d\n", (uint32_t)(dt * 1000000), (uint32_t)(dt * 1000000) - usec); return (dt < 0 || dt >= 1800) ? 0 : dt; }