From fad130be18c80ccbc1dd1609b2057908e260b538 Mon Sep 17 00:00:00 2001 From: Gideon Reich Date: Thu, 15 May 2025 22:05:22 +0200 Subject: [PATCH] Fix disguise bodygroups being tied to the disguise target --- src/game/shared/tf/tf_item_wearable.cpp | 18 ++++++++---------- src/game/shared/tf/tf_player_shared.cpp | 7 +++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/game/shared/tf/tf_item_wearable.cpp b/src/game/shared/tf/tf_item_wearable.cpp index db20eb12bd4..1d4b46f4f33 100644 --- a/src/game/shared/tf/tf_item_wearable.cpp +++ b/src/game/shared/tf/tf_item_wearable.cpp @@ -525,15 +525,13 @@ bool CTFWearable::UpdateBodygroups( CBaseCombatCharacter* pOwner, int iState ) if ( !pTFOwner ) return false; - bool bBaseUpdate = BaseClass::UpdateBodygroups( pOwner, iState ); - if ( bBaseUpdate && m_bDisguiseWearable ) - { - CEconItemView *pItem = GetAttributeContainer()->GetItem(); // Safe. Checked in base class call. + BaseClass::UpdateBodygroups( pOwner, iState ); - CTFPlayer *pDisguiseTarget = pTFOwner->m_Shared.GetDisguiseTarget(); - if ( !pDisguiseTarget ) - return false; + CEconItemView *pItem = GetAttributeContainer() ? GetAttributeContainer()->GetItem() : NULL; +#ifdef CLIENT_DLL + if ( pItem && m_bDisguiseWearable ) + { // Update our disguise bodygroup. int iDisguiseBody = pTFOwner->m_Shared.GetDisguiseBody(); int iTeam = pTFOwner->m_Shared.GetDisguiseTeam(); @@ -542,18 +540,18 @@ bool CTFWearable::UpdateBodygroups( CBaseCombatCharacter* pOwner, int iState ) { int iBody = 0; const char *pszBodyGroup = pItem->GetStaticData()->GetModifiedBodyGroup( iTeam, i, iBody ); - int iBodyGroup = pDisguiseTarget->FindBodygroupByName( pszBodyGroup ); + int iBodyGroup = pTFOwner->FindBodygroupByName( pszBodyGroup ); if ( iBodyGroup == -1 ) continue; - ::SetBodygroup( pDisguiseTarget->GetModelPtr(), iDisguiseBody, iBodyGroup, iState ); + ::SetBodygroup( pTFOwner->GetModelPtr(), iDisguiseBody, iBodyGroup, iState ); } pTFOwner->m_Shared.SetDisguiseBody( iDisguiseBody ); } +#endif // CLIENT_DLL - CEconItemView *pItem = GetAttributeContainer() ? GetAttributeContainer()->GetItem() : NULL; if ( pItem ) { int iTeam = pTFOwner->GetTeamNumber(); diff --git a/src/game/shared/tf/tf_player_shared.cpp b/src/game/shared/tf/tf_player_shared.cpp index abe67cf9c09..03a81c29c58 100644 --- a/src/game/shared/tf/tf_player_shared.cpp +++ b/src/game/shared/tf/tf_player_shared.cpp @@ -13584,6 +13584,13 @@ void CTFPlayerShared::RecalculatePlayerBodygroups( void ) // like if we switch to a class that uses those bits for other things. m_pOuter->m_nBody = 0; +#ifdef CLIENT_DLL + // Do the same to m_iDisguiseBody on the client. + // Leaving it will make it stick between different disguises + m_iDisguiseBody = 0; +#endif // CLIENT_DLL + + // Update our weapon bodygroups that change state purely based on whether they're // equipped or not. CTFWeaponBase::UpdateWeaponBodyGroups( m_pOuter, false );