From 9d3949a94833c6346094956fe20452ba51f6c423 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 5 Jan 2024 02:25:10 +0300 Subject: [PATCH] ref: gl: replace skin texture num bound by a proper check, fixes wrong skin on flags in Adrenaline Gamer --- ref/gl/gl_studio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ref/gl/gl_studio.c b/ref/gl/gl_studio.c index 3de2dec4..ad09a6c9 100644 --- a/ref/gl/gl_studio.c +++ b/ref/gl/gl_studio.c @@ -2242,8 +2242,7 @@ static void R_StudioDrawPoints( void ) g_studio.numverts = g_studio.numelems = 0; - // safety bounding the skinnum - m_skinnum = bound( 0, RI.currententity->curstate.skin, ( m_pStudioHeader->numskinfamilies - 1 )); + m_skinnum = RI.currententity->curstate.skin; ptexture = (mstudiotexture_t *)((byte *)m_pStudioHeader + m_pStudioHeader->textureindex); pvertbone = ((byte *)m_pStudioHeader + m_pSubModel->vertinfoindex); pnormbone = ((byte *)m_pStudioHeader + m_pSubModel->norminfoindex); @@ -2253,7 +2252,8 @@ static void R_StudioDrawPoints( void ) pstudionorms = (vec3_t *)((byte *)m_pStudioHeader + m_pSubModel->normindex); pskinref = (short *)((byte *)m_pStudioHeader + m_pStudioHeader->skinindex); - if( m_skinnum != 0 ) pskinref += (m_skinnum * m_pStudioHeader->numskinref); + if( m_skinnum > 0 && m_skinnum < m_pStudioHeader->numskinfamilies ) + pskinref += (m_skinnum * m_pStudioHeader->numskinref); if( FBitSet( m_pStudioHeader->flags, STUDIO_HAS_BONEWEIGHTS ) && m_pSubModel->blendvertinfoindex != 0 && m_pSubModel->blendnorminfoindex != 0 ) {