Skip to content

Commit

Permalink
Fix scr_loadingscreen_maxfps, related polishing
Browse files Browse the repository at this point in the history
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 <bones_was_here@xonotic.au>
  • Loading branch information
bones-was-here committed Sep 14, 2024
1 parent bcea095 commit 40cdb05
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
7 changes: 3 additions & 4 deletions cl_screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
13 changes: 6 additions & 7 deletions libcurl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion libcurl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions sys_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 40cdb05

Please sign in to comment.