From 4e583772d73ce9ca8b4d4270d9b4c0c2e4504809 Mon Sep 17 00:00:00 2001 From: Chernoskill Date: Sat, 6 Mar 2021 11:26:31 +0100 Subject: [PATCH] Update models_md3.cpp --- src/common/models/models_md3.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/common/models/models_md3.cpp b/src/common/models/models_md3.cpp index b706b4a7c9..c40f78e1ee 100644 --- a/src/common/models/models_md3.cpp +++ b/src/common/models/models_md3.cpp @@ -307,7 +307,7 @@ void FMD3Model::AddSkins(uint8_t *hitlist) for (unsigned i = 0; i < Surfaces.Size(); i++) { int ssIndex = i + curMDLIndex * MD3_MAX_SURFACES; - if (curSpriteMDLFrame->surfaceskinIDs[ssIndex].isValid()) + if (curSpriteMDLFrame && curSpriteMDLFrame->surfaceskinIDs[ssIndex].isValid()) { hitlist[curSpriteMDLFrame->surfaceskinIDs[ssIndex].GetIndex()] |= FTextureManager::HIT_Flat; } @@ -358,14 +358,17 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FGameTexture * skin, int f FGameTexture *surfaceSkin = skin; if (!surfaceSkin) { - int ssIndex = i + curMDLIndex * MD3_MAX_SURFACES; - if (curSpriteMDLFrame->surfaceskinIDs[ssIndex].isValid()) + if (curSpriteMDLFrame) { - surfaceSkin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[ssIndex], true); - } - else if (surf->numSkins > 0 && surf->Skins[0].isValid()) - { - surfaceSkin = TexMan.GetGameTexture(surf->Skins[0], true); + int ssIndex = i + curMDLIndex * MD3_MAX_SURFACES; + if (curSpriteMDLFrame->surfaceskinIDs[ssIndex].isValid()) + { + surfaceSkin = TexMan.GetGameTexture(curSpriteMDLFrame->surfaceskinIDs[ssIndex], true); + } + else if (surf->numSkins > 0 && surf->Skins[0].isValid()) + { + surfaceSkin = TexMan.GetGameTexture(surf->Skins[0], true); + } } if (!surfaceSkin)