From 81d5369e97fda1f0a5b626a1b92c9c902dccb9be Mon Sep 17 00:00:00 2001 From: WPMGPRoSToTeMa Date: Tue, 2 Feb 2016 01:15:22 +0300 Subject: [PATCH] Added texture and seqgroup auto precache --- rehlds/engine/pr_cmds.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 767ec59..dc7244f 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1455,6 +1455,38 @@ int EXT_FUNC PF_precache_model_I(const char *s) g_psv.models[i] = Mod_ForName(s, 1, 1); if (!iOptional) g_psv.model_precache_flags[i] |= 1u; + +#ifdef REHLDS_FIXES + if (g_psv.models[i]->type == mod_studio) + { + studiohdr_t *pStudioHeader = (studiohdr_t *)Mod_Extradata(g_psv.models[i]); + + size_t modelNameLength = Q_strlen(s); + if (!pStudioHeader->textureindex && modelNameLength < MAX_QPATH - 1) + { + char textureModelName[MAX_QPATH]; + Q_strcpy(textureModelName, s); + + size_t modelExtensionLength = sizeof(".mdl") - 1; + char *modelExtension = &textureModelName[modelNameLength - modelExtensionLength]; + Q_strcpy(modelExtension, "T.mdl"); + + PF_precache_model_I(textureModelName); + } + if (pStudioHeader->numseqgroups) + { + mstudioseqgroup_t *pSeqGroup = (mstudioseqgroup_t *)((uint8_t *)pStudioHeader + pStudioHeader->seqgroupindex); + for (int i = 0; i < pStudioHeader->numseqgroups; i++, pSeqGroup++) + { + if (pSeqGroup->name[0] == '\0') + continue; + + PF_precache_generic_I(pSeqGroup->name); + } + } + } +#endif // REHLDS_FIXES + return i; }