From 45257e7d7366b9020de3d6aa1402b264c7ebc029 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 21 Dec 2022 15:05:34 -0500 Subject: [PATCH] Force use of external Zombie skins and override MDL loading --- source/gl_model.c | 36 ++++++++++++++++++++++++++++++++++++ source/gl_rmisc.c | 8 ++++++++ 2 files changed, 44 insertions(+) diff --git a/source/gl_model.c b/source/gl_model.c index 418a6db..3a7db43 100644 --- a/source/gl_model.c +++ b/source/gl_model.c @@ -2448,11 +2448,29 @@ void Mod_FloodFillSkin( byte *skin, int skinwidth, int skinheight ) } } +qboolean model_is_zombie(char name[MAX_QPATH]) +{ + if (Q_strcmp(name, "models/ai/zbod.mdl") == 0 || + Q_strcmp(name, "models/ai/zcbod.mdl") == 0 || + Q_strcmp(name, "models/ai/zcfull.mdl") == 0 || + Q_strcmp(name, "models/ai/zchead.mdl") == 0 || + Q_strcmp(name, "models/ai/zclarm.mdl") == 0 || + Q_strcmp(name, "models/ai/zcrarm.mdl") == 0 || + Q_strcmp(name, "models/ai/zfull.mdl") == 0 || + Q_strcmp(name, "models/ai/zhead.mdl") == 0 || + Q_strcmp(name, "models/ai/zlarm.mdl") == 0 || + Q_strcmp(name, "models/ai/zrarm.mdl") == 0) + return qtrue; + + return qfalse; +} + /* =============== Mod_LoadAllSkins =============== */ +extern gltexture_t *zombie_skins[4]; void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype) { int i, j, k, size, groupskins; @@ -2474,6 +2492,24 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype) if (loadmodel->flags & MF_HOLEY) texflags |= TEXPREF_ALPHA; + if (model_is_zombie(loadmodel->name) == qtrue) { + Mod_FloodFillSkin(skin, pheader->skinwidth, pheader->skinheight); + + // save 8 bit texels for the player model to remap + texels = (byte *) Hunk_AllocName(size, loadname); + pheader->texels[i] = texels - (byte *)pheader; + memcpy (texels, (byte *)(pskintype + 1), size); + + // force-fill 4 skin slots + for (int i = 0; i < 4; i++) { + pheader->gltextures[i][0] = zombie_skins[i]; + pheader->fbtextures[i][0] = NULL; + } + + pskintype = (daliasskintype_t *)((byte *)(pskintype+1) + s); + return (void *)pskintype; + } + for (i=0 ; itype == ALIAS_SKIN_SINGLE) diff --git a/source/gl_rmisc.c b/source/gl_rmisc.c index a16f1cb..e1c8977 100644 --- a/source/gl_rmisc.c +++ b/source/gl_rmisc.c @@ -59,6 +59,8 @@ gltexture_t *decal_burn; gltexture_t *decal_mark; gltexture_t *decal_glow; +gltexture_t *zombie_skins[4]; + /* ==================== @@ -676,5 +678,11 @@ void R_InitOtherTextures (void) decal_burn = loadtextureimage ("textures/decals/explo_burn01"); decal_mark = loadtextureimage ("textures/decals/particle_burn01"); decal_glow = loadtextureimage ("textures/decals/glow2"); + + // external zombie skins + zombie_skins[0] = loadtextureimage ("models/ai/zfull.mdl_0", 0, 0, qtrue, qtrue); + zombie_skins[1] = loadtextureimage ("models/ai/zfull.mdl_1", 0, 0, qtrue, qtrue); + zombie_skins[2] = loadtextureimage ("models/ai/zfull.mdl_2", 0, 0, qtrue, qtrue); + zombie_skins[3] = loadtextureimage ("models/ai/zfull.mdl_3", 0, 0, qtrue, qtrue); }