From df8f9261bfe94bcfe31d38dd678c6888f1c98325 Mon Sep 17 00:00:00 2001 From: Andrei Drexler Date: Sat, 9 Nov 2024 18:30:11 +0100 Subject: [PATCH] Change MAXALIASVERTS/TRIS errors to QS compat dev warnings (#352) --- Quake/gl_model.c | 30 ++++++++++++++++-------------- Quake/gl_model.h | 20 +++++++------------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/Quake/gl_model.c b/Quake/gl_model.c index 371855639..a4ee6f5dc 100644 --- a/Quake/gl_model.c +++ b/Quake/gl_model.c @@ -2728,10 +2728,10 @@ ALIAS MODELS ============================================================================== */ -aliashdr_t *pheader; +aliashdr_t *pheader; -stvert_t stverts[MAXALIASVERTS]; -mtriangle_t triangles[MAXALIASTRIS]; +const stvert_t *stverts; +const dtriangle_t *triangles; // a pose is a single set of vertexes. a frame may be // an animating sequence of poses @@ -3257,16 +3257,16 @@ static void Mod_LoadAliasModel (qmodel_t *mod, void *buffer) if (pheader->numverts <= 0) Sys_Error ("model %s has no vertices", mod->name); - if (pheader->numverts > MAXALIASVERTS) - Sys_Error ("model %s has too many vertices (%d; max = %d)", mod->name, pheader->numverts, MAXALIASVERTS); + if (pheader->numverts > MAXALIASVERTS_QS && (developer.value || map_checks.value)) + Con_Warning ("model %s vertex count of %d exceeds QS limit of %d\n", mod->name, pheader->numverts, MAXALIASVERTS_QS); pheader->numtris = LittleLong (pinmodel->numtris); if (pheader->numtris <= 0) Sys_Error ("model %s has no triangles", mod->name); - if (pheader->numtris > MAXALIASTRIS) - Sys_Error ("model %s has too many triangles (%d; max = %d)", mod->name, pheader->numtris, MAXALIASTRIS); + if (pheader->numtris > MAXALIASTRIS_QS && (developer.value || map_checks.value)) + Con_Warning ("model %s triangle count of %d exceeds QS limit of %d\n", mod->name, pheader->numtris, MAXALIASTRIS_QS); pheader->numframes = LittleLong (pinmodel->numframes); numframes = pheader->numframes; @@ -3291,29 +3291,31 @@ static void Mod_LoadAliasModel (qmodel_t *mod, void *buffer) pskintype = (daliasskintype_t *) Mod_LoadAllSkins (pheader->numskins, pskintype); // -// load base s and t vertices +// endian-swap base s and t vertices in place // pinstverts = (stvert_t *)pskintype; + stverts = pinstverts; for (i=0 ; inumverts ; i++) { - stverts[i].onseam = LittleLong (pinstverts[i].onseam); - stverts[i].s = LittleLong (pinstverts[i].s); - stverts[i].t = LittleLong (pinstverts[i].t); + pinstverts[i].onseam = LittleLong (pinstverts[i].onseam); + pinstverts[i].s = LittleLong (pinstverts[i].s); + pinstverts[i].t = LittleLong (pinstverts[i].t); } // -// load triangle lists +// endian-swap triangle lists in place // pintriangles = (dtriangle_t *)&pinstverts[pheader->numverts]; + triangles = pintriangles; for (i=0 ; inumtris ; i++) { - triangles[i].facesfront = LittleLong (pintriangles[i].facesfront); + pintriangles[i].facesfront = LittleLong (pintriangles[i].facesfront); for (j=0 ; j<3 ; j++) { - triangles[i].vertindex[j] = + pintriangles[i].vertindex[j] = LittleLong (pintriangles[i].vertindex[j]); } } diff --git a/Quake/gl_model.h b/Quake/gl_model.h index a5b8e9fb0..b242c68be 100644 --- a/Quake/gl_model.h +++ b/Quake/gl_model.h @@ -311,12 +311,6 @@ typedef struct maliasgroupframedesc_t frames[1]; } maliasgroup_t; -// !!! if this is changed, it must be changed in asm_draw.h too !!! -typedef struct mtriangle_s { - int facesfront; - int vertindex[3]; -} mtriangle_t; - #define MAX_SKINS 32 typedef struct { @@ -386,13 +380,13 @@ typedef struct bonepose_t inverse; } boneinfo_t; -#define MAXALIASVERTS 2000 //johnfitz -- was 1024 -#define MAXALIASFRAMES 1024 //spike -- was 256 -#define MAXALIASTRIS 4096 //ericw -- was 2048 -extern aliashdr_t *pheader; -extern stvert_t stverts[MAXALIASVERTS]; -extern mtriangle_t triangles[MAXALIASTRIS]; -extern trivertx_t *poseverts[MAXALIASFRAMES]; +#define MAXALIASVERTS_QS 2000 //johnfitz -- was 1024 +#define MAXALIASFRAMES 1024 //spike -- was 256 +#define MAXALIASTRIS_QS 4096 //ericw -- was 2048 +extern aliashdr_t *pheader; +extern const stvert_t *stverts; +extern const dtriangle_t *triangles; +extern trivertx_t *poseverts[MAXALIASFRAMES]; //===================================================================