Mapbase protagonist system team and precache fixes

This commit is contained in:
ALLEN-PC\acj30 2025-07-07 10:04:44 -05:00
parent 84aaf3bb33
commit 834196c2eb
2 changed files with 27 additions and 4 deletions

View File

@ -176,11 +176,11 @@ void CProtagonistSystem::LoadProtagonistFile( const char *pszFile )
else if (FStrEq( pszSubKeyName, "team" )) else if (FStrEq( pszSubKeyName, "team" ))
{ {
#ifdef HL2MP #ifdef HL2MP
if (FStrEq( pszSubKeyName, "combine" )) if (FStrEq( pSubKey->GetString(), "combine" ))
{ {
pProtag->nTeam = TEAM_COMBINE; pProtag->nTeam = TEAM_COMBINE;
} }
else if (FStrEq( pszSubKeyName, "rebels" )) else if (FStrEq( pSubKey->GetString(), "rebels" ))
{ {
pProtag->nTeam = TEAM_REBELS; pProtag->nTeam = TEAM_REBELS;
} }
@ -188,7 +188,7 @@ void CProtagonistSystem::LoadProtagonistFile( const char *pszFile )
#endif #endif
{ {
// Try to get a direct integer // Try to get a direct integer
pProtag->nTeam = atoi( pszSubKeyName ); pProtag->nTeam = atoi( pSubKey->GetString() );
} }
} }
#endif #endif
@ -335,6 +335,12 @@ void CProtagonistSystem::PrecacheProtagonist( CBaseEntity *pSource, int nIdx )
ProtagonistData_t &pProtag = m_Protagonists[nIdx]; ProtagonistData_t &pProtag = m_Protagonists[nIdx];
// Don't if it's already precached
if (pProtag.bPrecached)
return;
CBaseEntity::SetAllowPrecache( true );
// Playermodel // Playermodel
if (pProtag.pszPlayerModel) if (pProtag.pszPlayerModel)
{ {
@ -358,6 +364,16 @@ void CProtagonistSystem::PrecacheProtagonist( CBaseEntity *pSource, int nIdx )
pSource->PrecacheModel( pProtag.dictWpnData[i].pszVM ); pSource->PrecacheModel( pProtag.dictWpnData[i].pszVM );
} }
} }
CBaseEntity::SetAllowPrecache( false );
// Precache parents
FOR_EACH_VEC( pProtag.vecParents, i )
{
PrecacheProtagonist( pSource, pProtag.vecParents[i] );
}
pProtag.bPrecached = true;
#endif #endif
} }
@ -416,7 +432,6 @@ GetProtagParamBody( ResponseContexts, bool, GetProtagParamInner( ResponseConte
int nLast = V_strlen( pszContexts )-1; int nLast = V_strlen( pszContexts )-1;
if (pszContexts[nLast] == ',') if (pszContexts[nLast] == ',')
{ {
Msg( "Removing trailing comma from \"%s\"\n", pszContexts );
pszContexts[nLast] = '\0'; pszContexts[nLast] = '\0';
} }
} }
@ -681,6 +696,11 @@ void CProtagonistSystem::PrintProtagonistData()
if (pProtag.pszPlayerModel) if (pProtag.pszPlayerModel)
Msg( "\t\tPlayer model: \"%s\" (%i, %i)\n", pProtag.pszPlayerModel, pProtag.nPlayerSkin, pProtag.nPlayerBody ); Msg( "\t\tPlayer model: \"%s\" (%i, %i)\n", pProtag.pszPlayerModel, pProtag.nPlayerSkin, pProtag.nPlayerBody );
#ifdef HL2MP
if ( pProtag.nTeam != TEAM_ANY )
Msg( "\t\tTeam: %i\n", pProtag.nTeam );
#endif
for (int j = 0; j < NUM_HAND_RIG_TYPES; j++) for (int j = 0; j < NUM_HAND_RIG_TYPES; j++)
{ {
extern const char *pHandRigs[NUM_HAND_RIG_TYPES]; extern const char *pHandRigs[NUM_HAND_RIG_TYPES];

View File

@ -61,6 +61,9 @@ private:
// Multiplayer // Multiplayer
int nTeam = TEAM_ANY; int nTeam = TEAM_ANY;
// Precached (used by system, not actual data)
bool bPrecached = false;
#endif #endif
// Weapon Data // Weapon Data