Fixed a tiny mistake that prevented morphs from working correctly

Actors now have a working dynamic facial expression (moving eyes/mouth/brown...)
This commit is contained in:
smallmodel 2024-06-11 00:06:31 +02:00
parent 4d231fbc50
commit fb15f0f2b3
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
2 changed files with 7 additions and 11 deletions

View file

@ -217,6 +217,6 @@ void skeletor_c::LoadMorphTargetNames(skelHeaderGame_t *modelHeader)
m_targetBlink = morphTargetIndex; m_targetBlink = morphTargetIndex;
} }
newTargetName += strlen(newTargetName + 1); newTargetName += strlen(newTargetName) + 1;
} }
} }

View file

@ -439,14 +439,12 @@ void TIKI_CacheFileSkel(skelHeader_t *pHeader, skelcache_t *cache, int length)
} }
if (nBoxBytes) { if (nBoxBytes) {
const int ofsBoxes = LongNoSwapPtr(&pHeader->ofsBoxes); if (pHeader->ofsBoxes <= 0 || (nBoxBytes + pHeader->ofsBoxes) > length) {
if (ofsBoxes <= 0 || (nBoxBytes + ofsBoxes) >= length) {
Com_Printf("^~^~^ Box data is corrupted for '%s'\n", cache->path); Com_Printf("^~^~^ Box data is corrupted for '%s'\n", cache->path);
pSkel->numMorphTargets = 0; pSkel->numBoxes = 0;
pSkel->pMorphTargets = NULL; pSkel->pBoxes = NULL;
} else { } else {
memcpy(pSkel->pBoxes, ((byte *)pHeader + ofsBoxes), nBoxBytes); memcpy(pSkel->pBoxes, ((byte *)pHeader + pHeader->ofsBoxes), nBoxBytes);
} }
} else { } else {
pSkel->numBoxes = 0; pSkel->numBoxes = 0;
@ -460,14 +458,12 @@ void TIKI_CacheFileSkel(skelHeader_t *pHeader, skelcache_t *cache, int length)
} }
if (nMorphBytes) { if (nMorphBytes) {
const int ofsMorphTargets = LongNoSwapPtr(&pHeader->ofsBoxes); if (pHeader->ofsMorphTargets <= 0 || (nMorphBytes + pHeader->ofsMorphTargets) > length) {
if (ofsMorphTargets <= 0 || (nMorphBytes + ofsMorphTargets) >= length) {
Com_Printf("^~^~^ Morph targets data is corrupted for '%s'\n", cache->path); Com_Printf("^~^~^ Morph targets data is corrupted for '%s'\n", cache->path);
pSkel->numMorphTargets = 0; pSkel->numMorphTargets = 0;
pSkel->pMorphTargets = NULL; pSkel->pMorphTargets = NULL;
} else { } else {
memcpy(pSkel->pMorphTargets, ((byte *)pHeader + ofsMorphTargets), nMorphBytes); memcpy(pSkel->pMorphTargets, ((byte *)pHeader + pHeader->ofsMorphTargets), nMorphBytes);
} }
} else { } else {
pSkel->numMorphTargets = 0; pSkel->numMorphTargets = 0;