Skip to content

Commit

Permalink
Get skin family & skinref count from texture header
Browse files Browse the repository at this point in the history
Resolves SamVanheer#57
  • Loading branch information
Solokiller committed Apr 5, 2019
1 parent b81092e commit eb6d1c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/game/entity/CStudioModelEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int CStudioModelEntity::SetSkin( const int iSkin )
if( !m_pModel )
return 0;

if( iSkin < m_pModel->GetStudioHeader()->numskinfamilies )
if( iSkin < m_pModel->GetTextureHeader()->numskinfamilies )
{
m_iSkin = iSkin;
}
Expand Down
5 changes: 3 additions & 2 deletions src/tools/hlmv/CHLMVState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ bool CHLMVState::DumpModelInfo( const char* const pszFilename )
const auto pModel = m_pEntity->GetModel();

const studiohdr_t* const pHdr = pModel->GetStudioHeader();
const auto pTextureHdr = pModel->GetTextureHeader();

const byte* const pByte = reinterpret_cast<const byte* const>( pHdr );

Expand Down Expand Up @@ -375,8 +376,8 @@ bool CHLMVState::DumpModelInfo( const char* const pszFilename )
fprintf( pFile,
"Number of Skin References: %d\n"
"Number of Skin Families: %d\n\n",
pHdr->numskinref,
pHdr->numskinfamilies
pTextureHdr->numskinref,
pTextureHdr->numskinfamilies
);

fprintf( pFile,
Expand Down
9 changes: 5 additions & 4 deletions src/tools/hlmv/ui/controlpanels/CBodyPartsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ void CBodyPartsPanel::InitializeUI()
auto pModel = pEntity->GetModel();

const studiohdr_t* const pHdr = pModel->GetStudioHeader();
const auto pTextureHdr = pModel->GetTextureHeader();

if( pHdr )
if( pHdr && pTextureHdr )
{
const mstudiobodyparts_t* const pbodyparts = ( mstudiobodyparts_t* ) ( ( byte* ) pHdr + pHdr->bodypartindex );

Expand All @@ -140,9 +141,9 @@ void CBodyPartsPanel::InitializeUI()
m_pSubmodel->Enable( false );
}

m_pSkin->Enable( pHdr->numskinfamilies > 0 );
m_pSkin->Enable( pTextureHdr->numskinfamilies > 0 );

for( int i = 0; i < pHdr->numskinfamilies; ++i )
for( int i = 0; i < pTextureHdr->numskinfamilies; ++i )
{
names.Add( wxString::Format( "Skin %d", i + 1 ) );
}
Expand Down Expand Up @@ -317,7 +318,7 @@ void CBodyPartsPanel::SetModelInfo( const studiohdr_t& hdr, const studiohdr_t& t
m_pSequenceGroups ->SetLabelText( wxString::Format( "Sequence Groups: %d", hdr.numseqgroups ) );

m_pTextures ->SetLabelText( wxString::Format( "Textures: %d", texHdr.numtextures ) );
m_pSkinFamilies ->SetLabelText( wxString::Format( "Skin Families: %d", hdr.numskinfamilies ) );
m_pSkinFamilies ->SetLabelText( wxString::Format( "Skin Families: %d", texHdr.numskinfamilies ) );
m_pBodyparts ->SetLabelText( wxString::Format( "Bodyparts: %d", hdr.numbodyparts ) );
m_pAttachments ->SetLabelText( wxString::Format( "Attachments: %d", hdr.numattachments ) );
m_pTransitions ->SetLabelText( wxString::Format( "Transitions: %d", hdr.numtransitions ) );
Expand Down

0 comments on commit eb6d1c8

Please sign in to comment.