1
0
Fork 0
forked from fte/fteqw

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
This commit is contained in:
Spoike 2021-07-19 22:47:29 +00:00
parent 2599af212a
commit 90aae69db3
9 changed files with 89 additions and 23 deletions

View file

@ -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; case PTI_ASTC_6X6X6_LDR: w = 6; h = 6; d = 6; b = 16; break;
#endif #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 #ifdef FTE_TARGET_WEB
case PTI_WHOLEFILE: //UNKNOWN! case PTI_WHOLEFILE: //UNKNOWN!
#endif #endif
@ -14622,8 +14643,6 @@ void Image_DestroyTexture(image_t *tex)
Z_Free(tex); Z_Free(tex);
} }
void Shader_TouchTextures(void);
void Image_Purge(void) void Image_Purge(void)
{ {
image_t *tex; image_t *tex;

View file

@ -1807,8 +1807,28 @@ static void *QDECL PlugBI_GetEngineInterface(const char *interfacename, size_t s
Plug_Cmd_AddCommand, Plug_Cmd_AddCommand,
Plug_Cmd_AddText, 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)) if (structsize == sizeof(funcs))
return &funcs; return &funcs;
if (structsize == sizeof(oldfuncs))
return &oldfuncs;
} }
if (!strcmp(interfacename, plugcvarfuncs_name)) if (!strcmp(interfacename, plugcvarfuncs_name))
{ {

View file

@ -2954,7 +2954,7 @@ void BE_GenModelBatches(batch_t **batches, const dlight_t *dl, unsigned int bemo
continue; continue;
} }
switch(emodel->type) safeswitch(emodel->type)
{ {
case mod_brush: 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). 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); Terr_DrawTerrainModel(batches, ent);
#endif #endif
break; break;
safedefault:
break;
} }
break; break;
case RT_SPRITE: case RT_SPRITE:

View file

@ -1515,6 +1515,13 @@ static void R_HL_BuildMeshes(batch_t *b)
} }
qboolean R_CalcModelLighting(entity_t *e, model_t *clmodel); 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) void R_HalfLife_GenerateBatches(entity_t *rent, batch_t **batches)
{ {
hlmodel_t *model = Mod_Extradata(rent->model); hlmodel_t *model = Mod_Extradata(rent->model);

View file

@ -592,6 +592,10 @@ void Mod_Purge(enum mod_purge_e ptype)
Con_DLPrintf(2, "model \"%s\" no longer needed\n", mod->name); Con_DLPrintf(2, "model \"%s\" no longer needed\n", mod->name);
Mod_PurgeModel(mod, (ptype==MP_FLUSH && unused)?MP_RESET:ptype); 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
} }
} }

View file

@ -7940,12 +7940,36 @@ void Shader_ShowShader_f(void)
Con_Printf("Shader \"%s\" is not loaded\n", sourcename); 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) void Shader_TouchTextures(void)
{ {
int i, j, k; int i, j, k;
shader_t *s; shader_t *s;
shaderpass_t *p; shaderpass_t *p;
texnums_t *t;
for (i = 0; i < r_numshaders; i++) for (i = 0; i < r_numshaders; i++)
{ {
s = r_shaders[i]; s = r_shaders[i];
@ -7960,23 +7984,7 @@ void Shader_TouchTextures(void)
p->anim_frames[k]->regsequence = r_regsequence; p->anim_frames[k]->regsequence = r_regsequence;
} }
for (j = 0; j < max(1,s->numdefaulttextures); j++) for (j = 0; j < max(1,s->numdefaulttextures); j++)
{ Shader_TouchTexnums(&s->defaulttextures[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;
}
} }
} }

View file

@ -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_GetBoneData(model_t *model, int firstbone, int lastbone, const framestate_t *fstate, float *result);
int HLMDL_GetAttachment(model_t *model, int tagnum, float *resultmatrix); 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 //stuff only useful for clients that need to draw stuff
void R_DrawHLModel(entity_t *curent); void R_DrawHLModel(entity_t *curent);
void HLMDL_DrawHitBoxes(entity_t *ent); void HLMDL_DrawHitBoxes(entity_t *ent);
void R_HalfLife_GenerateBatches(entity_t *rent, batch_t **batches); void R_HalfLife_GenerateBatches(entity_t *rent, batch_t **batches);
void R_HalfLife_TouchTextures(model_t *mod);
#endif #endif

View file

@ -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 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 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_ShaderGetCinematic(shader_t *s);
cin_t *R_ShaderFindCinematic(const char *name); cin_t *R_ShaderFindCinematic(const char *name);
shader_t *R_ShaderFind(const char *name); //does NOT increase the shader refcount. shader_t *R_ShaderFind(const char *name); //does NOT increase the shader refcount.

View file

@ -234,6 +234,8 @@ qboolean NATIVEEXPORT FTEPlug_Init(plugcorefuncs_t *corefuncs)
plugfuncs = corefuncs; plugfuncs = corefuncs;
cmdfuncs = (plugcmdfuncs_t*)plugfuncs->GetEngineInterface(plugcmdfuncs_name, sizeof(*cmdfuncs)); cmdfuncs = (plugcmdfuncs_t*)plugfuncs->GetEngineInterface(plugcmdfuncs_name, sizeof(*cmdfuncs));
cvarfuncs = (plugcvarfuncs_t*)plugfuncs->GetEngineInterface(plugcvarfuncs_name, sizeof(*cvarfuncs)); cvarfuncs = (plugcvarfuncs_t*)plugfuncs->GetEngineInterface(plugcvarfuncs_name, sizeof(*cvarfuncs));
if (!plugfuncs || !cmdfuncs || !cvarfuncs)
return false; //erk
return Plug_Init(); return Plug_Init();
} }