From f38a6264b82512f197ab388f9145fb6f95c3e0f2 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 12 Mar 2019 06:41:52 +0000 Subject: [PATCH] Fix a stupid bug with allow_download cvar. Fix recursive errors from Sys_Error on worker threads. Fix shader parsing on worker thread with hlmdl. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5431 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/sys_droid.c | 1 + engine/client/sys_linux.c | 3 +++ engine/client/sys_sdl.c | 1 + engine/client/sys_xdk.c | 2 ++ engine/gl/gl_hlmdl.c | 22 ++++++++++------------ engine/gl/model_hl.h | 1 + engine/http/iwebiface.c | 2 +- engine/nacl/sys_ppapi.c | 1 + engine/server/sv_main.c | 2 +- engine/server/sv_sys_unix.c | 1 + engine/server/sv_sys_win.c | 1 + engine/web/sys_web.c | 1 + 12 files changed, 24 insertions(+), 14 deletions(-) diff --git a/engine/client/sys_droid.c b/engine/client/sys_droid.c index 7e36432bc..5d8aaeb89 100644 --- a/engine/client/sys_droid.c +++ b/engine/client/sys_droid.c @@ -346,6 +346,7 @@ void Sys_Error (const char *error, ...) va_start (argptr, error); vsnprintf (string,sizeof(string)-1, error,argptr); va_end (argptr); + COM_WorkerAbort(string); if (!*string) strcpy(string, "no error"); diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index 7f5922cf0..946c8bbae 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -422,6 +422,9 @@ void Sys_Error (const char *error, ...) va_start (argptr,error); vsnprintf (string,sizeof(string)-1, error,argptr); va_end (argptr); + + COM_WorkerAbort(string); + fprintf(stderr, "Error: %s\n", string); Host_Shutdown (); diff --git a/engine/client/sys_sdl.c b/engine/client/sys_sdl.c index b27ceeda9..955fdb98a 100644 --- a/engine/client/sys_sdl.c +++ b/engine/client/sys_sdl.c @@ -38,6 +38,7 @@ void Sys_Error (const char *error, ...) va_start (argptr,error); vsnprintf (string, sizeof (string), error, argptr); va_end (argptr); + COM_WorkerAbort(string); fprintf(stderr, "Error: %s\n", string); Sys_Printf ("Quake Error: %s\n", string); diff --git a/engine/client/sys_xdk.c b/engine/client/sys_xdk.c index ae4ff0c46..c7d3e5f62 100644 --- a/engine/client/sys_xdk.c +++ b/engine/client/sys_xdk.c @@ -35,6 +35,8 @@ unsigned int Sys_Milliseconds (void) NORETURN void VARGS Sys_Error (const char *error, ...) { + COM_WorkerAbort(error); + //FIXME: panic! everyone panic! //you might want to figure out some way to display the message... for(;;) diff --git a/engine/gl/gl_hlmdl.c b/engine/gl/gl_hlmdl.c index 94800c985..65c9380b1 100644 --- a/engine/gl/gl_hlmdl.c +++ b/engine/gl/gl_hlmdl.c @@ -336,18 +336,13 @@ qboolean QDECL Mod_LoadHLModel (model_t *mod, void *buffer, size_t fsize) shader = HLSHADER_CHROME; else shader = ""; - shaders[i].shader = R_RegisterShader(shaders[i].name, SUF_NONE, shader); - shaders[i].shader->defaulttextures->base = Image_GetTexture(shaders[i].name, "", IF_NOALPHA, (qbyte *) texheader + tex[i].offset, (qbyte *) texheader + tex[i].w * tex[i].h + tex[i].offset, tex[i].w, tex[i].h, TF_8PAL24); - shaders[i].shader->width = tex[i].w; - shaders[i].shader->height = tex[i].h; - } - else - { - memset(&shaders[i].defaulttex, 0, sizeof(shaders[i].defaulttex)); - shaders[i].defaulttex.base = Image_GetTexture(shaders[i].name, "", IF_NOALPHA, (qbyte *) texheader + tex[i].offset, (qbyte *) texheader + tex[i].w * tex[i].h + tex[i].offset, tex[i].w, tex[i].h, TF_8PAL24); - shaders[i].w = tex[i].w; - shaders[i].h = tex[i].h; + shaders[i].defaultshadertext = shader; } + shaders[i].defaultshadertext = NULL; + memset(&shaders[i].defaulttex, 0, sizeof(shaders[i].defaulttex)); + shaders[i].defaulttex.base = Image_GetTexture(shaders[i].name, "", IF_NOALPHA, (qbyte *) texheader + tex[i].offset, (qbyte *) texheader + tex[i].w * tex[i].h + tex[i].offset, tex[i].w, tex[i].h, TF_8PAL24); + shaders[i].w = tex[i].w; + shaders[i].h = tex[i].h; } model->numskinrefs = texheader->skinrefs; @@ -1320,7 +1315,10 @@ static void R_HalfLife_WalkMeshes(entity_t *rent, batch_t *b, batch_t **batches) if (!s->shader) { - s->shader = R_RegisterSkin(s->name, rent->model->name); + if (s->defaultshadertext) + s->shader = R_RegisterShader(s->name, SUF_NONE, s->defaultshadertext); + else + s->shader = R_RegisterSkin(s->name, rent->model->name); R_BuildDefaultTexnums(&s->defaulttex, s->shader, 0); } b->skin = NULL; diff --git a/engine/gl/model_hl.h b/engine/gl/model_hl.h index db7583781..26a826dc0 100644 --- a/engine/gl/model_hl.h +++ b/engine/gl/model_hl.h @@ -291,6 +291,7 @@ typedef struct //this is stored as the cache. an hlmodel_t is generated when dra struct hlmodelshaders_s { char name[MAX_QPATH]; + char *defaultshadertext; texnums_t defaulttex; shader_t *shader; int w, h; diff --git a/engine/http/iwebiface.c b/engine/http/iwebiface.c index 64dc3a336..b24073192 100644 --- a/engine/http/iwebiface.c +++ b/engine/http/iwebiface.c @@ -283,7 +283,7 @@ void COM_EnumerateFiles (const char *match, int (*func)(const char *, qofs_t, ti HANDLE r; WIN32_FIND_DATAA fd; char apath[MAX_OSPATH]; - char file[MAX_OSPATH]; + char file[MAX_OSPATH+MAX_PATH]; char *s; int go; strcpy(apath, match); diff --git a/engine/nacl/sys_ppapi.c b/engine/nacl/sys_ppapi.c index bff93aafe..fac0c5ce1 100644 --- a/engine/nacl/sys_ppapi.c +++ b/engine/nacl/sys_ppapi.c @@ -212,6 +212,7 @@ NORETURN void VARGS Sys_Error (const char *error, ...) va_start (argptr, error); vsnprintf (string, sizeof(string)-1, error, argptr); va_end (argptr); + COM_WorkerAbort(string); Sys_Printf("Sys_Error: %s", string); exit(1); diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 8845a6ed6..a514dd4aa 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -81,7 +81,7 @@ extern cvar_t password; #endif cvar_t spectator_password = CVARF("spectator_password", "", CVAR_NOUNSAFEEXPAND); // password for entering as a sepctator -cvar_t allow_download = CVARAD("allow_download", /*q3*/"sv_allowDownload", "1", "If 1, permits downloading. Set to 0 to unconditionally block *ALL* downloads."); +cvar_t allow_download = CVARAD("allow_download", "1", /*q3*/"sv_allowDownload", "If 1, permits downloading. Set to 0 to unconditionally block *ALL* downloads."); cvar_t allow_download_skins = CVARD("allow_download_skins", "1", "0 blocks downloading of any file in the skins/ directory"); cvar_t allow_download_models = CVARD("allow_download_models", "1", "0 blocks downloading of any file in the progs/ or models/ directory"); cvar_t allow_download_sounds = CVARD("allow_download_sounds", "1", "0 blocks downloading of any file in the sound/ directory"); diff --git a/engine/server/sv_sys_unix.c b/engine/server/sv_sys_unix.c index b1616c231..6cf6460ab 100644 --- a/engine/server/sv_sys_unix.c +++ b/engine/server/sv_sys_unix.c @@ -190,6 +190,7 @@ void Sys_Error (const char *error, ...) va_start (argptr,error); vsnprintf (string,sizeof(string)-1, error,argptr); va_end (argptr); + COM_WorkerAbort(string); printf ("Fatal error: %s\n",string); tcsetattr(STDIN_FILENO, TCSADRAIN, &orig); diff --git a/engine/server/sv_sys_win.c b/engine/server/sv_sys_win.c index 74b32900a..d3949c9c2 100644 --- a/engine/server/sv_sys_win.c +++ b/engine/server/sv_sys_win.c @@ -770,6 +770,7 @@ void Sys_Error (const char *error, ...) va_start (argptr,error); vsnprintf (text,sizeof(text)-1, error,argptr); va_end (argptr); + COM_WorkerAbort(text); // MessageBox(NULL, text, "Error", 0 /* MB_OK */ ); diff --git a/engine/web/sys_web.c b/engine/web/sys_web.c index 5ed875676..def53f69c 100644 --- a/engine/web/sys_web.c +++ b/engine/web/sys_web.c @@ -24,6 +24,7 @@ void Sys_Error (const char *error, ...) va_start (argptr,error); vsnprintf (string, sizeof (string), error, argptr); va_end (argptr); + COM_WorkerAbort(string); Sys_Printf("Error: %s\n", string); Con_Print ("Quake Error: ");