Skip to content

[TF2] Fix disguise bodygroups being tied to the disguise target #1284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/game/shared/tf/tf_item_wearable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
7 changes: 7 additions & 0 deletions src/game/shared/tf/tf_player_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down