Skip to content

Conversation

@mtxfellen
Copy link

Currently in CTFPlayer::OnTakeDamage_Alive, this safeguard exists to prevent a stack overflow whenever a reflected damage instance occurs against a player who themselves is also holding a Reflect power-up.

// Don't recieve reflected damage if you are carrying Reflect (prevents a loop in a game with two Reflect players)
if ( ( info.GetDamageType() & TF_DMG_CUSTOM_RUNE_REFLECT ) && m_Shared.GetCarryingRuneType() == RUNE_REFLECT )
{
	return 0;
}

The game will still crash when two players with Reflect power-ups attack each other, however, due to two issues:

  • info.GetDamageType() is checked for TF_DMG_CUSTOM_RUNE_REFLECT, when info.GetDamageCustom() should be checked instead.
  • This test is done in CTFPlayer::OnTakeDamage_Alive, but new reflected damage instances are created before that function call is reached in CTFPlayer::OnTakeDamage, meaning the stack overflows before this safeguard is ever reached.

This PR addresses both of the above issues by rectifying the conditional and moving the safeguard to a more appropriate location.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant