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 );
|
BitmapText::Update( fDelta );
|
||||||
|
|
||||||
// refresh text only once every 1/2 second
|
bool bTimeToUpdate =
|
||||||
float fNowSeconds = RageTimer::GetTimeSinceStart();
|
GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] ||
|
||||||
float fLastSeconds = RageTimer::GetTimeSinceStart() - fDelta;
|
GAMESTATE->m_bAttackEndedThisUpdate[m_PlayerNumber];
|
||||||
bool bTimeToUpdate = froundf(fNowSeconds,0.5f) != froundf(fLastSeconds,0.5f);
|
|
||||||
|
|
||||||
if( bTimeToUpdate )
|
if( bTimeToUpdate )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -85,7 +85,6 @@ void AttackDisplay::Update( float fDelta )
|
|||||||
if( !GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] )
|
if( !GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] )
|
||||||
return;
|
return;
|
||||||
// don't handle this again
|
// don't handle this again
|
||||||
GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] = false;
|
|
||||||
|
|
||||||
for( unsigned s=0; s<GAMESTATE->m_ActiveAttacks[m_PlayerNumber].size(); s++ )
|
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 );
|
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;
|
m_bAttackEndedThisUpdate[p] = false;
|
||||||
|
|
||||||
|
bool bRebuildPlayerOptions = false;
|
||||||
|
|
||||||
/* See if any delayed attacks are starting or ending. */
|
/* See if any delayed attacks are starting or ending. */
|
||||||
for( unsigned s=0; s<m_ActiveAttacks[p].size(); s++ )
|
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 )
|
if( m_ActiveAttacks[p][s].bOn && !bCurrentlyEnabled )
|
||||||
m_bAttackEndedThisUpdate[p] = true;
|
m_bAttackEndedThisUpdate[p] = true;
|
||||||
|
else if( !m_ActiveAttacks[p][s].bOn && bCurrentlyEnabled )
|
||||||
|
m_bAttackBeganThisUpdate[p] = true;
|
||||||
|
|
||||||
bRebuildPlayerOptions = 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 );
|
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,
|
/* 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
|
* 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
|
* 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 )
|
if( GAMESTATE->m_pCurSong==NULL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if( GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] )
|
||||||
|
m_soundAttackLaunch.Play();
|
||||||
if( GAMESTATE->m_bAttackEndedThisUpdate[m_PlayerNumber] )
|
if( GAMESTATE->m_bAttackEndedThisUpdate[m_PlayerNumber] )
|
||||||
m_soundAttackEnding.Play();
|
m_soundAttackEnding.Play();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user