From 18c9d38f5084be17df3db0557b5b2021d410fd5b Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 26 Oct 2003 03:02:30 +0000 Subject: [PATCH] course timed attack support fix HowToPlay crash --- stepmania/src/Attack.cpp | 5 +++++ stepmania/src/Course.cpp | 34 ++++++++++++++++++++++++++++++- stepmania/src/Course.h | 2 ++ stepmania/src/GameState.cpp | 16 ++++++++++----- stepmania/src/GameState.h | 1 + stepmania/src/Player.cpp | 2 ++ stepmania/src/ScoreKeeperMAX2.cpp | 2 ++ stepmania/src/ScreenGameplay.cpp | 15 +------------- 8 files changed, 57 insertions(+), 20 deletions(-) diff --git a/stepmania/src/Attack.cpp b/stepmania/src/Attack.cpp index 8ce45f1ca3..bf9117a231 100644 --- a/stepmania/src/Attack.cpp +++ b/stepmania/src/Attack.cpp @@ -10,6 +10,11 @@ void Attack::GetAttackBeats( const Song *song, PlayerNumber pn, float &fStartBea fStartBeat = song->GetBeatFromElapsedTime( fStartSecond ); fEndBeat = song->GetBeatFromElapsedTime( fStartSecond+fSecsRemaining ); } else { + /* If fStartSecond < 0, then the attack starts right off the screen; this requires + * that a song actually be playing. Pre-queued course attacks must always have + * fStartSecond >= 0. */ + ASSERT( GAMESTATE->m_pCurSong ); + /* We're setting this effect on the fly. If it's an arrow-changing effect * (transform or note skin), apply it in the future, past what's currently on * screen, so new arrows will scroll on screen with this effect. */ diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 91d224bf5f..b026e49ac6 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -132,6 +132,7 @@ void Course::LoadFromCRSFile( CString sPath ) BANNERCACHE->CacheBanner( m_sBannerPath ); } + AttackArray attacks; for( unsigned i=0; i &ci, int Difficul cinfo.pSong = pSong; cinfo.pNotes = pNotes; cinfo.Modifiers = e.modifiers; + cinfo.Attacks = e.attacks; cinfo.Random = ( e.type == COURSE_ENTRY_RANDOM || e.type == COURSE_ENTRY_RANDOM_WITHIN_GROUP ); cinfo.Mystery = e.mystery; cinfo.CourseIndex = i; @@ -938,10 +968,12 @@ void Course::UpdateCourseStats() void Course::Info::GetAttackArray( AttackArray &out ) const { Attack a; - a.fStartSecond = -1; + a.fStartSecond = 0; a.fSecsRemaining = 10000; /* whole song */ a.level = ATTACK_LEVEL_1; a.sModifier = Modifiers; out.push_back( a ); + + out.insert( out.end(), Attacks.begin(), Attacks.end() ); } diff --git a/stepmania/src/Course.h b/stepmania/src/Course.h index 6b6f897e7a..7f3e6f207e 100644 --- a/stepmania/src/Course.h +++ b/stepmania/src/Course.h @@ -55,6 +55,7 @@ public: int high_meter; // = -1 if no meter range specified int players_index; // ignored if type isn't 'best' or 'worst' CString modifiers; // set player and song options using these + AttackArray attacks; // set timed modifiers CourseEntry() { @@ -101,6 +102,7 @@ public: Song* pSong; Steps* pNotes; CString Modifiers; + AttackArray Attacks; bool Random; bool Mystery; bool Difficult; /* set to true if this is the difficult version */ diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 99c22691d3..dabc760798 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -83,6 +83,7 @@ void GameState::Reset() m_iCurrentStageIndex = 0; m_bAllow2ndExtraStage = true; m_bDifficultCourses = false; + m_BeatToNoteSkinRev = 0; NOTESKIN->RefreshNoteSkinData( GAMESTATE->m_CurGame ); @@ -576,12 +577,17 @@ void GameState::RestoreSelectedOptions() void GameState::ResetNoteSkins() { for( int pn = 0; pn < NUM_PLAYERS; ++pn ) - { - m_BeatToNoteSkin[pn].clear(); - m_BeatToNoteSkin[pn][-1000] = GAMESTATE->m_PlayerOptions[pn].m_sNoteSkin; - } + ResetNoteSkinsForPlayer( (PlayerNumber) pn ); - m_BeatToNoteSkinRev = 0; + ++m_BeatToNoteSkinRev; +} + +void GameState::ResetNoteSkinsForPlayer( PlayerNumber pn ) +{ + m_BeatToNoteSkin[pn].clear(); + m_BeatToNoteSkin[pn][-1000] = GAMESTATE->m_PlayerOptions[pn].m_sNoteSkin; + + ++m_BeatToNoteSkinRev; } void GameState::GetAllUsedNoteSkins( vector &out ) const diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index 47f09b7d9b..271cb2c5cd 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -153,6 +153,7 @@ public: map m_BeatToNoteSkin[NUM_PLAYERS]; int m_BeatToNoteSkinRev; /* hack: incremented whenever m_BeatToNoteSkin changes */ void ResetNoteSkins(); + void ResetNoteSkinsForPlayer( PlayerNumber pn ); void GetAllUsedNoteSkins( vector &out ) const; static const float MUSIC_SECONDS_INVALID; diff --git a/stepmania/src/Player.cpp b/stepmania/src/Player.cpp index 67197ce5a7..238f39444a 100644 --- a/stepmania/src/Player.cpp +++ b/stepmania/src/Player.cpp @@ -94,6 +94,8 @@ void PlayerMinus::Load( PlayerNumber pn, const NoteData* pNoteData, LifeMeter* p { //LOG->Trace( "PlayerMinus::Load()", ); + GAMESTATE->ResetNoteSkinsForPlayer( pn ); + m_PlayerNumber = pn; m_pLifeMeter = pLM; m_pCombinedLifeMeter = pCombinedLM; diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index 15d2683352..f272702298 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -28,6 +28,8 @@ ScoreKeeperMAX2::ScoreKeeperMAX2( const vector& apSongs, const vector& apNotes_, const vector &asModifiers, PlayerNumber pn_ ): ScoreKeeper(pn_), apNotes(apNotes_) { + ASSERT( apSongs.size() == apNotes_.size() ); + ASSERT( apSongs.size() == asModifiers.size() ); // // Fill in m_CurStageStats, calculate multiplier // diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 4b070a279f..30e07963dc 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -81,17 +81,6 @@ const ScreenMessage SM_GoToScreenAfterFail = ScreenMessage(SM_User+31); const ScreenMessage SM_StartHereWeGo = ScreenMessage(SM_User+40); const ScreenMessage SM_StopHereWeGo = ScreenMessage(SM_User+41); -void GetCourseAttackArray( const Course::Info &ci, AttackArray &out ) -{ - Attack a; - a.fStartSecond = 0; - a.fSecsRemaining = 10000; /* whole song */ - a.level = ATTACK_LEVEL_1; - a.sModifier = ci.Modifiers; - - out.push_back( a ); -} - /* XXX: Not using sName yet here until I work out jukebox/demo. */ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("ScreenGameplay") @@ -170,7 +159,7 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S { m_apNotesQueue[p].push_back( ci[c].pNotes ); AttackArray a; - GetCourseAttackArray( ci[c], a ); + ci[c].GetAttackArray( a ); m_asModifiersQueue[p].push_back( a ); } } @@ -691,8 +680,6 @@ void ScreenGameplay::LoadNextSong() GAMESTATE->RemoveAllActiveAttacks(); GAMESTATE->RestoreSelectedOptions(); - GAMESTATE->ResetNoteSkins(); - m_textSongOptions.SetText( GAMESTATE->m_SongOptions.GetString() ); for( p=0; p