1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-09-19 12:06:07 +08:00

Sync with upstream (Issue #30).

Recompiled tier1 and mathlib  for all platforms will come in next commit.
This commit is contained in:
Nicholas Hastings
2016-11-30 10:01:15 -05:00
parent 98fe5b5a34
commit 3957adff10
491 changed files with 29846 additions and 10698 deletions

View File

@ -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