clean up AttackBeganThisUpdate flag
fix Player LaunchAttack sound
This commit is contained in:
@@ -31,10 +31,9 @@ void ActiveAttackList::Update( float fDelta )
|
||||
{
|
||||
BitmapText::Update( fDelta );
|
||||
|
||||
// refresh text only once every 1/2 second
|
||||
float fNowSeconds = RageTimer::GetTimeSinceStart();
|
||||
float fLastSeconds = RageTimer::GetTimeSinceStart() - fDelta;
|
||||
bool bTimeToUpdate = froundf(fNowSeconds,0.5f) != froundf(fLastSeconds,0.5f);
|
||||
bool bTimeToUpdate =
|
||||
GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] ||
|
||||
GAMESTATE->m_bAttackEndedThisUpdate[m_PlayerNumber];
|
||||
|
||||
if( bTimeToUpdate )
|
||||
{
|
||||
|
||||
@@ -85,7 +85,6 @@ void AttackDisplay::Update( float fDelta )
|
||||
if( !GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] )
|
||||
return;
|
||||
// don't handle this again
|
||||
GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] = false;
|
||||
|
||||
for( unsigned s=0; s<GAMESTATE->m_ActiveAttacks[m_PlayerNumber].size(); s++ )
|
||||
{
|
||||
|
||||
@@ -333,9 +333,13 @@ void GameState::Update( float fDelta )
|
||||
{
|
||||
m_CurrentPlayerOptions[p].Approach( m_PlayerOptions[p], fDelta );
|
||||
|
||||
bool bRebuildPlayerOptions = false;
|
||||
// TRICKY: GAMESTATE->Update is run before any of the Screen update's,
|
||||
// so we'll clear these flags here and let them get turned on later
|
||||
m_bAttackBeganThisUpdate[p] = false;
|
||||
m_bAttackEndedThisUpdate[p] = false;
|
||||
|
||||
bool bRebuildPlayerOptions = false;
|
||||
|
||||
/* See if any delayed attacks are starting or ending. */
|
||||
for( unsigned s=0; s<m_ActiveAttacks[p].size(); s++ )
|
||||
{
|
||||
@@ -355,6 +359,8 @@ void GameState::Update( float fDelta )
|
||||
|
||||
if( m_ActiveAttacks[p][s].bOn && !bCurrentlyEnabled )
|
||||
m_bAttackEndedThisUpdate[p] = true;
|
||||
else if( !m_ActiveAttacks[p][s].bOn && bCurrentlyEnabled )
|
||||
m_bAttackBeganThisUpdate[p] = true;
|
||||
|
||||
bRebuildPlayerOptions = true;
|
||||
|
||||
@@ -990,8 +996,6 @@ void GameState::LaunchAttack( PlayerNumber target, Attack a )
|
||||
{
|
||||
LOG->Trace( "Launch attack '%s' against P%d at %f", a.sModifier.c_str(), target+1, a.fStartSecond );
|
||||
|
||||
m_bAttackBeganThisUpdate[target] = true;
|
||||
|
||||
/* If fStartSecond is -1, it means "launch as soon as possible". For m_ActiveAttacks,
|
||||
* mark the real time it's starting (now), so Update() can know when the attack started
|
||||
* so it can be removed later. For m_ModsToApply, leave the -1 in, so Player::Update
|
||||
|
||||
@@ -244,6 +244,8 @@ void PlayerMinus::Update( float fDeltaTime )
|
||||
if( GAMESTATE->m_pCurSong==NULL )
|
||||
return;
|
||||
|
||||
if( GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] )
|
||||
m_soundAttackLaunch.Play();
|
||||
if( GAMESTATE->m_bAttackEndedThisUpdate[m_PlayerNumber] )
|
||||
m_soundAttackEnding.Play();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user