Optimize conditional toggle to bitwise operation (#94)

* Optimize conditional toggle to bitwise operation
This commit is contained in:
In-line 2017-01-06 14:16:54 +04:00 committed by s1lentq
parent 70594c4c39
commit 06d943417b
2 changed files with 3 additions and 12 deletions

View File

@ -65,10 +65,7 @@ void CPathTrack::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller
if (ShouldToggle(useType, on))
{
if (on)
pev->spawnflags |= SF_PATH_ALTERNATE;
else
pev->spawnflags &= ~SF_PATH_ALTERNATE;
pev->spawnflags ^= SF_PATH_ALTERNATE;
}
}
else // Use toggles between enabled/disabled
@ -77,10 +74,7 @@ void CPathTrack::__MAKE_VHOOK(Use)(CBaseEntity *pActivator, CBaseEntity *pCaller
if (ShouldToggle(useType, on))
{
if (on)
pev->spawnflags |= SF_PATH_DISABLED;
else
pev->spawnflags &= ~SF_PATH_DISABLED;
pev->spawnflags ^= SF_PATH_DISABLED;
}
}
}

View File

@ -204,10 +204,7 @@ void CBot::__MAKE_VHOOK(ClearPrimaryAttack)()
void CBot::__MAKE_VHOOK(TogglePrimaryAttack)()
{
if (m_buttonFlags & IN_ATTACK)
m_buttonFlags &= ~IN_ATTACK;
else
m_buttonFlags |= IN_ATTACK;
m_buttonFlags ^= IN_ATTACK;
}
void CBot::__MAKE_VHOOK(SecondaryAttack)()