1
0
Fork 0
forked from fte/fteqw

Misc tweaks.

This commit is contained in:
Shpoike 2025-01-26 06:54:34 +00:00
parent 12721c764b
commit 247556928f
7 changed files with 34 additions and 22 deletions

View file

@ -733,8 +733,11 @@ static void CL_WebDownloadFinished(struct dl_download *dl)
}
#endif
static void CL_SendDownloadStartRequest(char *filename, char *localname, unsigned int flags)
static void CL_SendDownloadStartRequest(downloadlist_t *pending)
{
char *filename = pending->rname;
char *localname = pending->localname;
unsigned int flags = pending->flags;
static int dlsequence;
qdownload_t *dl;
@ -1670,7 +1673,6 @@ void CL_RequestNextDownload (void)
if (cl.downloadlist)
{
downloadlist_t *dl;
unsigned int fl;
//download required downloads first
for (dl = cl.downloadlist; dl; dl = dl->next)
@ -1688,14 +1690,13 @@ void CL_RequestNextDownload (void)
if (!dl)
dl = cl.downloadlist;
}
fl = dl->flags;
/*if we don't require downloads don't queue requests until we're actually on the server, slightly more deterministic*/
if (cls.state == ca_active || (requiredownloads.value && !(cls.demoplayback && !(fl&DLLF_TRYWEB))) || (fl & DLLF_REQUIRED))
if (cls.state == ca_active || (requiredownloads.value && !(cls.demoplayback && !(dl->flags&DLLF_TRYWEB))) || (dl->flags & DLLF_REQUIRED))
{
if ((fl & DLLF_OVERWRITE) || !CL_CheckFile (dl->localname))
if ((dl->flags & DLLF_OVERWRITE) || !CL_CheckFile (dl->localname))
{
CL_SendDownloadStartRequest(dl->rname, dl->localname, fl);
CL_SendDownloadStartRequest(dl);
return;
}
else

View file

@ -1316,7 +1316,9 @@ static void DoSign(const char *fname, int signtype)
}
else if (f)
{
hashfunc_t *h = (signtype==1)?&hash_sha2_256:&hash_sha2_512;
hashfunc_t *h = (signtype==1)?&hash_sha1:
(signtype==256)?&hash_sha2_256:
&hash_sha2_512;
size_t l, ts = 0;
void *ctx = alloca(h->contextsize);
qbyte data[65536*16];

View file

@ -364,7 +364,7 @@ char *VFS_GETS(vfsfile_t *vf, char *buffer, size_t buflen)
void VARGS VFS_PRINTF(vfsfile_t *vf, const char *format, ...)
{
va_list argptr;
char string[1024];
char string[2048];
va_start (argptr, format);
vsnprintf (string,sizeof(string)-1, format,argptr);
@ -1119,7 +1119,7 @@ static qboolean FS_Manifest_ParseTokens(ftemanifest_t *man)
char *sl = strchr(newdir+6, '/');
if (!sl)
break; //malformed steam link
man->gamepath[i].flags |= GAMEDIR_STEAMGAME;
man->gamepath[i].flags |= GAMEDIR_PRIVATE|GAMEDIR_STEAMGAME;
*sl = 0;
if (!FS_GamedirIsOkay(sl+1))
break;
@ -4320,7 +4320,9 @@ static searchpath_t *FS_AddPathHandle(searchpath_t **oldpaths, const char *purep
depth++;
}
*link = search;
search->handle->BuildHash(search->handle, depth, FS_AddFileHashUnsafe);
if (filesystemhash.numbuckets)
search->handle->BuildHash(search->handle, depth, FS_AddFileHashUnsafe);
}
else
{

View file

@ -5479,7 +5479,7 @@ enum
WCATTR_ACCEPT_ENCODING,
WCATTR_TRANSFER_ENCODING
};
typedef char httparg_t[64];
typedef char httparg_t[256];
#include "fs.h"
#ifdef _WIN32
#include "resource.h"
@ -5715,7 +5715,7 @@ qboolean FTENET_TCP_HTTPResponse(ftenet_tcp_stream_t *st, httparg_t arg[WCATTR_C
"{"
"if (Module['sched'] === undefined)"
"{" //our main function failed to set up the main loop. ie: main didn't get called. panic.
"alert('Unable to initialise. You may need to restart your browser. If you get this often and inconsistently, consider using a 64bit browser instead.');"
"alert('Unable to initialise. You may need to restart your browser.');"
"Module.setStatus('Initialisation Failure');"
"}"
"}"
@ -6121,7 +6121,7 @@ static const char *FTENET_TCP_ParseHTTPRequest(ftenet_tcp_connection_t *con, fte
int websocketver = 0;
qboolean acceptsgzip = false;
qboolean sendingweirdness = false;
char arg[WCATTR_COUNT][64];
httparg_t arg[WCATTR_COUNT];
if (!net_enable_http.ival && !net_enable_websockets.ival && !net_enable_rtcbroker.ival)
@ -6138,7 +6138,7 @@ static const char *FTENET_TCP_ParseHTTPRequest(ftenet_tcp_connection_t *con, fte
arg[i][0] = 0;
for (i = 0; i < st->inlen; i++)
{
if (alen == 63)
if (alen >= sizeof(arg[attr])-1)
{
Con_Printf("http request overflow from %s\n", NET_AdrToString (adr, sizeof(adr), &st->remoteaddr));
//we need to respond, firefox will create 10 different connections if we just close it
@ -6289,7 +6289,7 @@ static const char *FTENET_TCP_ParseHTTPRequest(ftenet_tcp_connection_t *con, fte
websocketver = atoi(&st->inbuffer[j]);
break;
default:
Q_strncpyz(arg[attr], &st->inbuffer[j], (i-j > 63)?64:(i - j + 1));
Q_strncpyz(arg[attr], &st->inbuffer[j], (i-j >= sizeof(arg[attr]))?sizeof(arg[attr]):(i - j + 1));
break;
}
}

View file

@ -826,7 +826,7 @@ void QCBUILTIN PF_json_get_name(pubprogfuncs_t *prinst, struct globalvars_s *pr_
void QCBUILTIN PF_json_get_integer(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
qcjson_t *handle = JSONFromQC(G_INT(OFS_PARM0));
switch (handle->type)
safeswitch (handle->type)
{
case json_type_number:
case json_type_true:
@ -836,7 +836,10 @@ void QCBUILTIN PF_json_get_integer(pubprogfuncs_t *prinst, struct globalvars_s *
case json_type_string:
G_INT(OFS_RETURN) = atoi(PR_GetString(prinst, handle->u.strofs));
break;
default:
case json_type_object:
case json_type_array:
case json_type_null:
safedefault:
G_INT(OFS_RETURN) = 0;
break;
}
@ -844,7 +847,7 @@ void QCBUILTIN PF_json_get_integer(pubprogfuncs_t *prinst, struct globalvars_s *
void QCBUILTIN PF_json_get_float(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
qcjson_t *handle = JSONFromQC(G_INT(OFS_PARM0));
switch (handle->type)
safeswitch (handle->type)
{
case json_type_number:
case json_type_true:
@ -854,7 +857,10 @@ void QCBUILTIN PF_json_get_float(pubprogfuncs_t *prinst, struct globalvars_s *pr
case json_type_string:
G_FLOAT(OFS_RETURN) = atof(PR_GetString(prinst, handle->u.strofs));
break;
default:
case json_type_object:
case json_type_array:
case json_type_null:
safedefault:
G_FLOAT(OFS_RETURN) = 0;
break;
}

View file

@ -404,6 +404,7 @@ static struct
} trackerimages[256];
static int numtrackerimages;
#define TRACKERFIRST 0xe200
#define TRACKERCOUNT 0x100 //an upper bound. so misused codepoints won't go weird.
int Font_RegisterTrackerImage(const char *image)
{
int i;
@ -412,7 +413,7 @@ int Font_RegisterTrackerImage(const char *image)
if (!strcmp(trackerimages[i].name, image))
return TRACKERFIRST + i;
}
if (numtrackerimages == 256)
if (numtrackerimages == TRACKERCOUNT)
return 0;
trackerimages[i].image = NULL; //actually load it elsewhere, because we're lazy.
Q_strncpyz(trackerimages[i].name, image, sizeof(trackerimages[i].name));
@ -1546,7 +1547,7 @@ static struct charcache_s *Font_GetChar(font_t *f, unsigned int codepoint)
c = Font_GetCharIfLoaded(f, charidx);
if (!c)
{
if (charidx >= TRACKERFIRST && charidx < TRACKERFIRST+100)
if (charidx >= TRACKERFIRST && charidx < TRACKERFIRST+TRACKERCOUNT)
{
static struct charcache_s tc;
tc.texplane = TRACKERIMAGE;

View file

@ -135,7 +135,7 @@ mergeInto(LibraryManager.library,
//do this first in the hope that it'll make firefox a smidge smoother.
if (FTEC.dovsync)
Browser.requestAnimationFrame(FTEC.step);
window.requestAnimationFrame(FTEC.step);
else
setTimeout(FTEC.step, 0, performance.now());