diff --git a/main/source/cl_dll/hl/hl_baseentity.cpp b/main/source/cl_dll/hl/hl_baseentity.cpp index 2d00f2f3..08d7c450 100644 --- a/main/source/cl_dll/hl/hl_baseentity.cpp +++ b/main/source/cl_dll/hl/hl_baseentity.cpp @@ -125,7 +125,7 @@ void CBaseMonster :: MakeIdealYaw( Vector vecTarget ) { } float CBaseMonster::ChangeYaw ( int yawSpeed ) { return 0; } int CBaseAnimating :: LookupActivity ( int activity ) { return 0; } int CBaseAnimating :: LookupActivityHeaviest ( int activity ) { return 0; } -int CBaseAnimating :: LookupSequence ( const char *label ) { return 0; } +int CBaseAnimating :: LookupSequence ( const char *label, int queue ) { return 0; } void CBaseAnimating :: ResetSequenceInfo ( ) { } BOOL CBaseAnimating :: GetSequenceFlags( ) { return FALSE; } void CBaseAnimating :: DispatchAnimEvents ( float flInterval ) { } diff --git a/main/source/dlls/animating.cpp b/main/source/dlls/animating.cpp index f3638a1d..ed1ba759 100644 --- a/main/source/dlls/animating.cpp +++ b/main/source/dlls/animating.cpp @@ -97,11 +97,18 @@ int CBaseAnimating :: LookupActivityHeaviest ( int activity ) //========================================================= //========================================================= -int CBaseAnimating :: LookupSequence ( const char *label ) +int CBaseAnimating :: LookupSequence ( const char *label, int queue ) { void *pmodel = GET_MODEL_PTR( ENT(pev) ); - return ::LookupSequence( pmodel, label ); + if (strcmp(label, this->mPreviousLookupString[queue]) == 0) + { + return this->mPreviousLookupSequence[queue]; + } + + strcpy(this->mPreviousLookupSequence[queue], label); + this->mPreviousLookupSequence[queue] = ::LookupSequence( pmodel, label ); + return this->mPreviousLookupSequence[queue]; } const char* CBaseAnimating::LookupSequence(int inSequence) diff --git a/main/source/dlls/animation.cpp b/main/source/dlls/animation.cpp index 99c84654..7bb91bb1 100644 --- a/main/source/dlls/animation.cpp +++ b/main/source/dlls/animation.cpp @@ -172,12 +172,12 @@ int LookupSequence( void *pmodel, const char *label ) } //if(GetGameRules()->GetIsTesting()) - if(CVAR_GET_FLOAT(kvTesting) > 0) - { - char theMessage[256]; - sprintf(theMessage, "%s%s\n", "Couldn't find animation: ", label); - ALERT(at_console, theMessage); - } + //if(CVAR_GET_FLOAT(kvTesting) > 0) + //{ + // char theMessage[256]; + // sprintf(theMessage, "%s%s\n", "Couldn't find animation: ", label); + // ALERT(at_console, theMessage); + //} return -1; } diff --git a/main/source/dlls/cbase.h b/main/source/dlls/cbase.h index 02d548aa..c47ecd5e 100644 --- a/main/source/dlls/cbase.h +++ b/main/source/dlls/cbase.h @@ -487,7 +487,7 @@ public: int GetSequenceFlags( void ); int LookupActivity ( int activity ); int LookupActivityHeaviest ( int activity ); - int LookupSequence ( const char *label ); + int LookupSequence ( const char *label, int queue = 0 ); const char* LookupSequence(int inSequence); void ResetSequenceInfo ( ); void DispatchAnimEvents ( float flFutureInterval = 0.1 ); // Handle events that have happend since last time called up until X seconds into the future @@ -510,6 +510,10 @@ public: float m_flLastEventCheck; // last time the event list was checked BOOL m_fSequenceFinished;// flag set when StudioAdvanceFrame moves across a frame boundry BOOL m_fSequenceLoops; // true if the sequence loops + + // For performance gain during LookupSequence + char mPreviousLookupString[3][64]; + int mPreviousLookupSequence[3]; }; diff --git a/main/source/dlls/player.cpp b/main/source/dlls/player.cpp index 756311ca..3d85bdd7 100644 --- a/main/source/dlls/player.cpp +++ b/main/source/dlls/player.cpp @@ -1311,7 +1311,7 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) } // Set the gaitsequence - gaitDesired = LookupSequence(szAnim); + gaitDesired = LookupSequence(szAnim, 1); if(gaitDesired == -1) { gaitDesired = 0;