From 0d8dceea4310fde5706b3ce1c70609d72a38efdf Mon Sep 17 00:00:00 2001 From: John Schoenick Date: Wed, 9 Sep 2015 18:35:41 -0700 Subject: Updated the SDK with the latest code from the TF and HL2 branches. --- mp/src/public/studio.cpp | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'mp/src/public/studio.cpp') diff --git a/mp/src/public/studio.cpp b/mp/src/public/studio.cpp index 4d84e1d0..bf6fdb7d 100644 --- a/mp/src/public/studio.cpp +++ b/mp/src/public/studio.cpp @@ -920,6 +920,16 @@ mstudioseqdesc_t &CStudioHdr::pSeqdesc( int i ) Assert( ( i >= 0 && i < GetNumSeq() ) || ( i == 1 && GetNumSeq() <= 1 ) ); if ( i < 0 || i >= GetNumSeq() ) { + if ( GetNumSeq() <= 0 ) + { + // Return a zero'd out struct reference if we've got nothing. + // C_BaseObject::StopAnimGeneratedSounds was crashing due to this function + // returning a reference to garbage. It should now see numevents is 0, + // and bail. + static mstudioseqdesc_t s_nil_seq; + return s_nil_seq; + } + // Avoid reading random memory. i = 0; } @@ -1026,9 +1036,10 @@ int CStudioHdr::GetSharedPoseParameter( int iSequence, int iLocalPose ) const Assert( m_pVModel ); - virtualgroup_t *pGroup = &m_pVModel->m_group[ m_pVModel->m_seq[iSequence].group ]; + int group = m_pVModel->m_seq[iSequence].group; + virtualgroup_t *pGroup = m_pVModel->m_group.IsValidIndex( group ) ? &m_pVModel->m_group[ group ] : NULL; - return pGroup->masterPose[iLocalPose]; + return pGroup ? pGroup->masterPose[iLocalPose] : iLocalPose; } @@ -1603,6 +1614,7 @@ void CStudioHdr::RunFlexRules( const float *src, float *dest ) //----------------------------------------------------------------------------- #define iabs(i) (( (i) >= 0 ) ? (i) : -(i) ) +CUtlSymbolTable g_ActivityModifiersTable; extern void SetActivityForSequence( CStudioHdr *pstudiohdr, int i ); void CStudioHdr::CActivityToSequenceMapping::Initialize( CStudioHdr * __restrict pstudiohdr ) @@ -1628,7 +1640,7 @@ void CStudioHdr::CActivityToSequenceMapping::Initialize( CStudioHdr * __restrict // Some studio headers have no activities at all. In those // cases we can avoid a lot of this effort. - bool bFoundOne = false; + bool bFoundOne = false; // for each sequence in the header... const int NumSeq = pstudiohdr->GetNumSeq(); @@ -1657,7 +1669,10 @@ void CStudioHdr::CActivityToSequenceMapping::Initialize( CStudioHdr * __restrict HashValueType * __restrict toUpdate = &m_ActToSeqHash.Element(handle); toUpdate->count += 1; toUpdate->totalWeight += iabs(seqdesc.actweight); - Assert( toUpdate->totalWeight > 0 ); + if ( !HushAsserts() ) + { + AssertMsg( toUpdate->totalWeight > 0, "toUpdate->totalWeight: %d", toUpdate->totalWeight ); + } } else { @@ -1720,6 +1735,23 @@ void CStudioHdr::CActivityToSequenceMapping::Initialize( CStudioHdr * __restrict int tupleOffset = seqsPerAct[seqdesc.activity]; Assert( tupleOffset < element.count ); + if ( seqdesc.numactivitymodifiers > 0 ) + { + // add entries for this model's activity modifiers + (tupleList + element.startingIdx + tupleOffset)->pActivityModifiers = new CUtlSymbol[ seqdesc.numactivitymodifiers ]; + (tupleList + element.startingIdx + tupleOffset)->iNumActivityModifiers = seqdesc.numactivitymodifiers; + + for ( int k = 0; k < seqdesc.numactivitymodifiers; k++ ) + { + (tupleList + element.startingIdx + tupleOffset)->pActivityModifiers[ k ] = g_ActivityModifiersTable.AddString( seqdesc.pActivityModifier( k )->pszName() ); + } + } + else + { + (tupleList + element.startingIdx + tupleOffset)->pActivityModifiers = NULL; + (tupleList + element.startingIdx + tupleOffset)->iNumActivityModifiers = 0; + } + // You might be tempted to collapse this pointer math into a single pointer -- // don't! the tuple list is marked __restrict above. (tupleList + element.startingIdx + tupleOffset)->seqnum = i; // store sequence number -- cgit v1.2.3