aboutsummaryrefslogtreecommitdiff
path: root/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp
diff options
context:
space:
mode:
authorJoe Ludwig <[email protected]>2014-05-15 13:59:18 -0700
committerJoe Ludwig <[email protected]>2014-05-15 13:59:18 -0700
commit53e78c503e6e9c7d15e2eefc480755fe37dd7077 (patch)
treec8cc106eb4c0a2b2b5d79f534f2facb0514f5f55 /mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp
parentAdded many shader source files (diff)
downloadsource-sdk-2013-53e78c503e6e9c7d15e2eefc480755fe37dd7077.tar.xz
source-sdk-2013-53e78c503e6e9c7d15e2eefc480755fe37dd7077.zip
General:
* Upgraded Steamworks SDK to v1.29 * Fixed mod compatibility problem with Multiplayer Base that was introduced in September. * In Hammer, while using the Vertex Tool, pressing CTRL+B will snap selected vertices to the grid. Virtual Reality: * Mods that support virtual reality now need to have a line in gameinfo.txt that says “supportsvr 1”. This indicates to gameui and engine that certain UI should be enabled. * VR-enabled mods will now start up in VR mode when launched from Steam’s VR mode. Windows: * Upgraded to Visual Studio 2013. If you need to build projects for VS 2010, add /2010 to your VPC command line. OSX: * Upgraded to XCode 5.
Diffstat (limited to 'mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp')
-rw-r--r--mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp64
1 files changed, 57 insertions, 7 deletions
diff --git a/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp b/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp
index 975eec17..4d1ad4fe 100644
--- a/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp
+++ b/mp/src/game/shared/Multiplayer/multiplayer_animstate.cpp
@@ -358,16 +358,21 @@ void CMultiPlayerAnimState::PlayFlinchGesture( Activity iActivity )
//-----------------------------------------------------------------------------
bool CMultiPlayerAnimState::InitGestureSlots( void )
{
- // Get the base player.
- CBasePlayer *pPlayer = GetBasePlayer();
- if( pPlayer )
+ // Setup the number of gesture slots.
+ m_aGestureSlots.AddMultipleToTail( GESTURE_SLOT_COUNT );
+
+ // Assign all of the the CAnimationLayer pointers to null early in case we bail.
+ for ( int iGesture = 0; iGesture < GESTURE_SLOT_COUNT; ++iGesture )
{
- // Set the number of animation overlays we will use.
- pPlayer->SetNumAnimOverlays( GESTURE_SLOT_COUNT );
+ m_aGestureSlots[iGesture].m_pAnimLayer = NULL;
}
- // Setup the number of gesture slots.
- m_aGestureSlots.AddMultipleToTail( GESTURE_SLOT_COUNT );
+ // Get the base player.
+ CBasePlayer *pPlayer = GetBasePlayer();
+
+ // Set the number of animation overlays we will use.
+ pPlayer->SetNumAnimOverlays( GESTURE_SLOT_COUNT );
+
for ( int iGesture = 0; iGesture < GESTURE_SLOT_COUNT; ++iGesture )
{
m_aGestureSlots[iGesture].m_pAnimLayer = pPlayer->GetAnimOverlay( iGesture );
@@ -409,6 +414,9 @@ void CMultiPlayerAnimState::ResetGestureSlot( int iGestureSlot )
// Sanity Check
Assert( iGestureSlot >= 0 && iGestureSlot < GESTURE_SLOT_COUNT );
+ if ( !VerifyAnimLayerInSlot( iGestureSlot ) )
+ return;
+
GestureSlot_t *pGestureSlot = &m_aGestureSlots[iGestureSlot];
if ( pGestureSlot )
{
@@ -486,6 +494,36 @@ bool CMultiPlayerAnimState::IsGestureSlotActive( int iGestureSlot )
return m_aGestureSlots[iGestureSlot].m_bActive;
}
+
+//-----------------------------------------------------------------------------
+// Purpose: Track down a crash
+//-----------------------------------------------------------------------------
+bool CMultiPlayerAnimState::VerifyAnimLayerInSlot( int iGestureSlot )
+{
+ if ( iGestureSlot < 0 || iGestureSlot >= GESTURE_SLOT_COUNT )
+ {
+ return false;
+ }
+
+ if ( GetBasePlayer()->GetNumAnimOverlays() < iGestureSlot + 1 )
+ {
+ AssertMsg2( false, "Player %d doesn't have gesture slot %d any more.", GetBasePlayer()->entindex(), iGestureSlot );
+ Msg( "Player %d doesn't have gesture slot %d any more.\n", GetBasePlayer()->entindex(), iGestureSlot );
+ m_aGestureSlots[iGestureSlot].m_pAnimLayer = NULL;
+ return false;
+ }
+
+ CAnimationLayer *pExpected = GetBasePlayer()->GetAnimOverlay( iGestureSlot );
+ if ( m_aGestureSlots[iGestureSlot].m_pAnimLayer != pExpected )
+ {
+ AssertMsg3( false, "Gesture slot %d pointing to wrong address %p. Updating to new address %p.", iGestureSlot, m_aGestureSlots[iGestureSlot].m_pAnimLayer, pExpected );
+ Msg( "Gesture slot %d pointing to wrong address %p. Updating to new address %p.\n", iGestureSlot, m_aGestureSlots[iGestureSlot].m_pAnimLayer, pExpected );
+ m_aGestureSlots[iGestureSlot].m_pAnimLayer = pExpected;
+ }
+
+ return true;
+}
+
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@@ -509,6 +547,9 @@ void CMultiPlayerAnimState::RestartGesture( int iGestureSlot, Activity iGestureA
// Sanity Check
Assert( iGestureSlot >= 0 && iGestureSlot < GESTURE_SLOT_COUNT );
+ if ( !VerifyAnimLayerInSlot( iGestureSlot ) )
+ return;
+
if ( !IsGestureSlotPlaying( iGestureSlot, iGestureActivity ) )
{
#ifdef CLIENT_DLL
@@ -549,6 +590,9 @@ void CMultiPlayerAnimState::AddToGestureSlot( int iGestureSlot, Activity iGestur
if ( !m_aGestureSlots[iGestureSlot].m_pAnimLayer )
return;
+ if ( !VerifyAnimLayerInSlot( iGestureSlot ) )
+ return;
+
// Get the sequence.
int iGestureSequence = pPlayer->SelectWeightedSequence( iGestureActivity );
if ( iGestureSequence <= 0 )
@@ -623,6 +667,9 @@ void CMultiPlayerAnimState::AddVCDSequenceToGestureSlot( int iGestureSlot, int i
if ( !m_aGestureSlots[iGestureSlot].m_pAnimLayer )
return;
+ if ( !VerifyAnimLayerInSlot( iGestureSlot ) )
+ return;
+
// Set the activity.
Activity iGestureActivity = ACT_MP_VCD;
@@ -1154,6 +1201,9 @@ void CMultiPlayerAnimState::ComputeGestureSequence( CStudioHdr *pStudioHdr )
if ( !m_aGestureSlots[iGesture].m_bActive )
continue;
+ if ( !VerifyAnimLayerInSlot( iGesture ) )
+ continue;
+
UpdateGestureLayer( pStudioHdr, &m_aGestureSlots[iGesture] );
}
}