From 90aae69db3157d70ed5337c1ee5802bf6cfc6e03 Mon Sep 17 00:00:00 2001 From: Spoike Date: Mon, 19 Jul 2021 22:47:29 +0000 Subject: [PATCH] Try to make things a little more stable. git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5983 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/image.c | 25 +++++++++++++++++++++--- engine/common/plugin.c | 20 +++++++++++++++++++ engine/gl/gl_alias.c | 4 +++- engine/gl/gl_hlmdl.c | 7 +++++++ engine/gl/gl_model.c | 4 ++++ engine/gl/gl_shader.c | 44 +++++++++++++++++++++++++----------------- engine/gl/model_hl.h | 3 ++- engine/gl/shader.h | 3 +++ plugins/plugin.c | 2 ++ 9 files changed, 89 insertions(+), 23 deletions(-) diff --git a/engine/client/image.c b/engine/client/image.c index 0e545ae50..a9762dcf9 100644 --- a/engine/client/image.c +++ b/engine/client/image.c @@ -11335,7 +11335,28 @@ void Image_BlockSizeForEncoding(uploadfmt_t encoding, unsigned int *blockbytes, case PTI_ASTC_6X6X6_LDR: w = 6; h = 6; d = 6; b = 16; break; #endif - case PTI_EMULATED: + case TF_BGR24_FLIP: + case TF_SOLID8: + case TF_TRANS8: + case TF_TRANS8_FULLBRIGHT: + case TF_HEIGHT8: + case TF_HEIGHT8PAL: + case TF_H2_T7G1: + case TF_H2_TRANS8_0: + case TF_H2_T4A4: + b=1; + break; + case PTI_LLLX8: + case PTI_LLLA8: + b=4; + break; + case TF_8PAL24: + case TF_8PAL32: + case TF_INVALID: + case TF_MIP4_P8: + case TF_MIP4_SOLID8: + case TF_MIP4_8PAL24: + case TF_MIP4_8PAL24_T255: #ifdef FTE_TARGET_WEB case PTI_WHOLEFILE: //UNKNOWN! #endif @@ -14622,8 +14643,6 @@ void Image_DestroyTexture(image_t *tex) Z_Free(tex); } - -void Shader_TouchTextures(void); void Image_Purge(void) { image_t *tex; diff --git a/engine/common/plugin.c b/engine/common/plugin.c index 5d821ee0f..aa6b283c7 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -1807,8 +1807,28 @@ static void *QDECL PlugBI_GetEngineInterface(const char *interfacename, size_t s Plug_Cmd_AddCommand, Plug_Cmd_AddText, }; + + static struct + { + qboolean (QDECL*AddCommand) (const char *cmdname); + void (QDECL*TokenizeString) (const char *msg); + void (QDECL*Args) (char *buffer, int bufsize); + void (QDECL*Argv) (int argnum, char *buffer, size_t bufsize); + int (QDECL*Argc) (void); + void (QDECL*AddText) (const char *text, qboolean insert); + } oldfuncs = + { + Plug_Cmd_AddCommand, + Plug_Cmd_TokenizeString, + Plug_Cmd_Args, + Plug_Cmd_Argv, + Plug_Cmd_Argc, + Plug_Cmd_AddText, + }; if (structsize == sizeof(funcs)) return &funcs; + if (structsize == sizeof(oldfuncs)) + return &oldfuncs; } if (!strcmp(interfacename, plugcvarfuncs_name)) { diff --git a/engine/gl/gl_alias.c b/engine/gl/gl_alias.c index 41ef0e799..bd2401a90 100644 --- a/engine/gl/gl_alias.c +++ b/engine/gl/gl_alias.c @@ -2954,7 +2954,7 @@ void BE_GenModelBatches(batch_t **batches, const dlight_t *dl, unsigned int bemo continue; } - switch(emodel->type) + safeswitch(emodel->type) { case mod_brush: if (r_drawentities.ival == 2 && cls.allow_cheats) //2 is considered a cheat, because it can be used as a wallhack (whereas mdls are not normally considered as occluding). @@ -2981,6 +2981,8 @@ void BE_GenModelBatches(batch_t **batches, const dlight_t *dl, unsigned int bemo Terr_DrawTerrainModel(batches, ent); #endif break; + safedefault: + break; } break; case RT_SPRITE: diff --git a/engine/gl/gl_hlmdl.c b/engine/gl/gl_hlmdl.c index 82dd59755..6d3eb78f9 100644 --- a/engine/gl/gl_hlmdl.c +++ b/engine/gl/gl_hlmdl.c @@ -1515,6 +1515,13 @@ static void R_HL_BuildMeshes(batch_t *b) } qboolean R_CalcModelLighting(entity_t *e, model_t *clmodel); +void R_HalfLife_TouchTextures(model_t *mod) +{ + hlmodel_t *model = Mod_Extradata(mod); + unsigned int t; + for (t = 0; t < model->header->numtextures; t++) + Shader_TouchTexnums(&model->shaders[t].defaulttex); +} void R_HalfLife_GenerateBatches(entity_t *rent, batch_t **batches) { hlmodel_t *model = Mod_Extradata(rent->model); diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index 2e527f672..0d13cedea 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -592,6 +592,10 @@ void Mod_Purge(enum mod_purge_e ptype) Con_DLPrintf(2, "model \"%s\" no longer needed\n", mod->name); Mod_PurgeModel(mod, (ptype==MP_FLUSH && unused)?MP_RESET:ptype); } +#if defined(HALFLIFEMODELS) && defined(HAVE_CLIENT) + else if (mod->fromgame == fg_halflife) + R_HalfLife_TouchTextures(mod); +#endif } } diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index a1c99482c..69993d329 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -7940,12 +7940,36 @@ void Shader_ShowShader_f(void) Con_Printf("Shader \"%s\" is not loaded\n", sourcename); } +void Shader_TouchTexnums(texnums_t *t) +{ + if (t->base) + t->base->regsequence = r_regsequence; + if (t->bump) + t->bump->regsequence = r_regsequence; + if (t->specular) + t->specular->regsequence = r_regsequence; + if (t->upperoverlay) + t->upperoverlay->regsequence = r_regsequence; + if (t->loweroverlay) + t->loweroverlay->regsequence = r_regsequence; + if (t->paletted) + t->paletted->regsequence = r_regsequence; + if (t->fullbright) + t->fullbright->regsequence = r_regsequence; + if (t->reflectcube) + t->reflectcube->regsequence = r_regsequence; + if (t->reflectmask) + t->reflectmask->regsequence = r_regsequence; + if (t->displacement) + t->displacement->regsequence = r_regsequence; + if (t->occlusion) + t->occlusion->regsequence = r_regsequence; +} void Shader_TouchTextures(void) { int i, j, k; shader_t *s; shaderpass_t *p; - texnums_t *t; for (i = 0; i < r_numshaders; i++) { s = r_shaders[i]; @@ -7960,23 +7984,7 @@ void Shader_TouchTextures(void) p->anim_frames[k]->regsequence = r_regsequence; } for (j = 0; j < max(1,s->numdefaulttextures); j++) - { - t = &s->defaulttextures[j]; - if (t->base) - t->base->regsequence = r_regsequence; - if (t->paletted) - t->paletted->regsequence = r_regsequence; - if (t->bump) - t->bump->regsequence = r_regsequence; - if (t->fullbright) - t->fullbright->regsequence = r_regsequence; - if (t->specular) - t->specular->regsequence = r_regsequence; - if (t->upperoverlay) - t->upperoverlay->regsequence = r_regsequence; - if (t->loweroverlay) - t->loweroverlay->regsequence = r_regsequence; - } + Shader_TouchTexnums(&s->defaulttextures[j]); } } diff --git a/engine/gl/model_hl.h b/engine/gl/model_hl.h index d78336960..478386670 100644 --- a/engine/gl/model_hl.h +++ b/engine/gl/model_hl.h @@ -339,9 +339,10 @@ const char *HLMDL_GetBoneName(model_t *mod, int bonenum); int HLMDL_GetBoneData(model_t *model, int firstbone, int lastbone, const framestate_t *fstate, float *result); int HLMDL_GetAttachment(model_t *model, int tagnum, float *resultmatrix); -#ifndef SERVERONLY +#ifdef HAVE_CLIENT //stuff only useful for clients that need to draw stuff void R_DrawHLModel(entity_t *curent); void HLMDL_DrawHitBoxes(entity_t *ent); void R_HalfLife_GenerateBatches(entity_t *rent, batch_t **batches); +void R_HalfLife_TouchTextures(model_t *mod); #endif diff --git a/engine/gl/shader.h b/engine/gl/shader.h index 3875f1a27..8756864ce 100644 --- a/engine/gl/shader.h +++ b/engine/gl/shader.h @@ -731,6 +731,9 @@ void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader, unsigned int i void QDECL R_BuildLegacyTexnums(shader_t *shader, const char *fallbackname, const char *subpath, unsigned int loadflags, unsigned int imageflags, uploadfmt_t basefmt, size_t width, size_t height, qbyte *mipdata, qbyte *palette); void R_RemapShader(const char *sourcename, const char *destname, float timeoffset); +void Shader_TouchTexnums(texnums_t *t); +void Shader_TouchTextures(void); + cin_t *R_ShaderGetCinematic(shader_t *s); cin_t *R_ShaderFindCinematic(const char *name); shader_t *R_ShaderFind(const char *name); //does NOT increase the shader refcount. diff --git a/plugins/plugin.c b/plugins/plugin.c index 5cef025c1..1822017cf 100644 --- a/plugins/plugin.c +++ b/plugins/plugin.c @@ -234,6 +234,8 @@ qboolean NATIVEEXPORT FTEPlug_Init(plugcorefuncs_t *corefuncs) plugfuncs = corefuncs; cmdfuncs = (plugcmdfuncs_t*)plugfuncs->GetEngineInterface(plugcmdfuncs_name, sizeof(*cmdfuncs)); cvarfuncs = (plugcvarfuncs_t*)plugfuncs->GetEngineInterface(plugcvarfuncs_name, sizeof(*cvarfuncs)); + if (!plugfuncs || !cmdfuncs || !cvarfuncs) + return false; //erk return Plug_Init(); }