Skip to content

Commit

Permalink
refactor attackround logic to remove redundant dynamic cast
Browse files Browse the repository at this point in the history
  • Loading branch information
Dukilles committed Dec 20, 2024
1 parent e5c1004 commit 8fe0b7b
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/map/attackround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,25 @@ CAttackRound::CAttackRound(CBattleEntity* attacker, CBattleEntity* defender)
m_coverAbilityUserEntity = nullptr;
}

if (IsH2H()) // Build H2H attacks.
{
CreateAttacks(dynamic_cast<CItemWeapon*>(attacker->m_Weapons[SLOT_MAIN]), LEFTATTACK);
CreateAttacks(dynamic_cast<CItemWeapon*>(attacker->m_Weapons[SLOT_MAIN]), LEFTATTACK);
}
else // Build main weapon attacks.
auto* PMain = dynamic_cast<CItemWeapon*>(attacker->m_Weapons[SLOT_MAIN]);
auto* PSub = dynamic_cast<CItemWeapon*>(attacker->m_Weapons[SLOT_SUB]);

if (PMain)
{
CreateAttacks(dynamic_cast<CItemWeapon*>(attacker->m_Weapons[SLOT_MAIN]), RIGHTATTACK);
if (IsH2H()) // Build H2H attacks.
{
CreateAttacks(PMain, LEFTATTACK);
CreateAttacks(PMain, LEFTATTACK);
}
else // Build main weapon attacks.
{
CreateAttacks(PMain, RIGHTATTACK);
}
}

if (attacker->m_dualWield)
if (PSub && attacker->m_dualWield)
{
CreateAttacks(dynamic_cast<CItemWeapon*>(attacker->m_Weapons[SLOT_SUB]), LEFTATTACK);
CreateAttacks(PSub, LEFTATTACK);
}

// Build kick attacks.
Expand Down

0 comments on commit 8fe0b7b

Please sign in to comment.