From 08d3abbe44ad4147e84d74937b5fc7f65f400aac Mon Sep 17 00:00:00 2001 From: Jason Felds Date: Thu, 23 Feb 2012 22:50:03 -0500 Subject: [PATCH] New branch: [sm5a2futures] Want to make sure we don't cause conflicts for future 1a builds. This commit: change the sentinel for launching attacks immediately. This way, songs with negative gaps can have attacks work here. Thanks to Saturn for the assist. --- src/Attack.h | 6 ++++-- src/Player.cpp | 2 +- src/PlayerState.cpp | 12 ++++++------ src/ScreenGameplay.cpp | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Attack.h b/src/Attack.h index fe61a48723..2ca69181f9 100644 --- a/src/Attack.h +++ b/src/Attack.h @@ -8,6 +8,8 @@ class PlayerState; /** @brief An action made against a Player to make things more difficult. */ struct Attack { + static const int ATTACK_STARTS_NOW = -10000; + AttackLevel level; /** * @brief the starting point of this attack. @@ -25,14 +27,14 @@ struct Attack void MakeBlank() { level = ATTACK_LEVEL_1; - fStartSecond = -1; + fStartSecond = ATTACK_STARTS_NOW; fSecsRemaining = 0; sModifiers = RString(); bOn = false; bGlobal = false; bShowInAttackList = true; } - Attack(): level(ATTACK_LEVEL_1), fStartSecond(-1), + Attack(): level(ATTACK_LEVEL_1), fStartSecond(ATTACK_STARTS_NOW), fSecsRemaining(0), sModifiers(RString()), bOn(false), bGlobal(false), bShowInAttackList(true) {} // MakeBlank() is effectively called here. diff --git a/src/Player.cpp b/src/Player.cpp index c913e1b46d..24132d4cbc 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -2859,7 +2859,7 @@ void Player::UpdateJudgedRows() Attack attMineAttack; attMineAttack.sModifiers = ApplyRandomAttack(); - attMineAttack.fStartSecond = -1.0f; + attMineAttack.fStartSecond = attMineAttack.ATTACK_STARTS_NOW; attMineAttack.fSecsRemaining = fAttackRunTime; m_pPlayerState->LaunchAttack( attMineAttack ); diff --git a/src/PlayerState.cpp b/src/PlayerState.cpp index 18194cdc59..fcfe2d5f9c 100644 --- a/src/PlayerState.cpp +++ b/src/PlayerState.cpp @@ -63,10 +63,10 @@ void PlayerState::Update( float fDelta ) { Attack &attack = m_ActiveAttacks[s]; - // -1 is the "starts now" sentinel value. You must add the attack - // by calling GameState::LaunchAttack, or else the -1 won't be + // You must add sattack by calling GameState::LaunchAttack, + // or else the sentinel value won't be // converted into the current music time. - ASSERT( attack.fStartSecond != -1 ); + ASSERT( attack.fStartSecond != attack.ATTACK_STARTS_NOW ); bool bCurrentlyEnabled = attack.bGlobal || @@ -111,12 +111,12 @@ void PlayerState::LaunchAttack( const Attack& a ) Attack attack = a; - /* If fStartSecond is -1, it means "launch as soon as possible". For m_ActiveAttacks, + /* If fStartSecond is the sentinel, 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, + * started so it can be removed later. For m_ModsToApply, leave the sentinel in, * so Player::Update knows to apply attack transforms correctly. (yuck) */ m_ModsToApply.push_back( attack ); - if( attack.fStartSecond == -1 ) + if( attack.fStartSecond == attack.ATTACK_STARTS_NOW ) attack.fStartSecond = m_Position.m_fMusicSeconds; m_ActiveAttacks.push_back( attack ); diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 59f77cffd7..0c26d85123 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -968,7 +968,7 @@ void ScreenGameplay::SetupSong( int iSongIndex ) Attack a = pi->m_asModifiersQueue[iSongIndex][i]; if( a.fStartSecond != 0 ) continue; - a.fStartSecond = -1; // now + a.fStartSecond = a.ATTACK_STARTS_NOW; // now PlayerOptions po; po.FromString( a.sModifiers ); @@ -1018,7 +1018,7 @@ void ScreenGameplay::SetupSong( int iSongIndex ) { Attack a = pi->m_asModifiersQueue[iSongIndex][i]; if( a.fStartSecond == 0 ) - a.fStartSecond = -1; // now + a.fStartSecond = a.ATTACK_STARTS_NOW; // now pi->GetPlayerState()->LaunchAttack( a ); GAMESTATE->m_SongOptions.FromString( ModsLevel_Song, a.sModifiers );