course timed attack support

fix HowToPlay crash
This commit is contained in:
Glenn Maynard
2003-10-26 03:02:30 +00:00
parent 30fc222183
commit 18c9d38f50
8 changed files with 57 additions and 20 deletions
+5
View File
@@ -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. */
+33 -1
View File
@@ -132,6 +132,7 @@ void Course::LoadFromCRSFile( CString sPath )
BANNERCACHE->CacheBanner( m_sBannerPath );
}
AttackArray attacks;
for( unsigned i=0; i<msd.GetNumValues(); i++ )
{
CString sValueName = msd.GetParam(i, 0);
@@ -157,6 +158,32 @@ void Course::LoadFromCRSFile( CString sPath )
else if( 0 == stricmp(sValueName, "METER") )
m_iMeter = atoi( sParams[1] );
else if( 0 == stricmp(sValueName, "MODS") )
{
Attack attack;
for( unsigned j = 1; j < sParams.params.size(); ++j )
{
CStringArray sBits;
split( sParams[j], "=", sBits, false );
if( sBits.size() == 0 )
continue;
LOG->Trace("b '%s'", sBits[0].c_str());
TrimLeft( sBits[0] );
TrimRight( sBits[0] );
if( !sBits[0].CompareNoCase("TIME") )
attack.fStartSecond = (float) atof( sBits[1] );
else if( !sBits[0].CompareNoCase("LEN") )
attack.fSecsRemaining = (float) atof( sBits[1] );
else if( !sBits[0].CompareNoCase("MODS") )
{
attack.sModifier = sBits[1];
attacks.push_back( attack );
}
}
}
else if( 0 == stricmp(sValueName, "SONG") )
{
CourseEntry new_entry;
@@ -254,6 +281,8 @@ void Course::LoadFromCRSFile( CString sPath )
new_entry.modifiers = join( ",", mods );
}
new_entry.attacks = attacks;
m_entries.push_back( new_entry );
}
@@ -613,6 +642,7 @@ void Course::GetCourseInfo( StepsType nt, vector<Course::Info> &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() );
}
+2
View File
@@ -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 */
+11 -5
View File
@@ -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<CString> &out ) const
+1
View File
@@ -153,6 +153,7 @@ public:
map<float,CString> m_BeatToNoteSkin[NUM_PLAYERS];
int m_BeatToNoteSkinRev; /* hack: incremented whenever m_BeatToNoteSkin changes */
void ResetNoteSkins();
void ResetNoteSkinsForPlayer( PlayerNumber pn );
void GetAllUsedNoteSkins( vector<CString> &out ) const;
static const float MUSIC_SECONDS_INVALID;
+2
View File
@@ -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;
+2
View File
@@ -28,6 +28,8 @@
ScoreKeeperMAX2::ScoreKeeperMAX2( const vector<Song*>& apSongs, const vector<Steps*>& apNotes_, const vector<AttackArray> &asModifiers, PlayerNumber pn_ ):
ScoreKeeper(pn_), apNotes(apNotes_)
{
ASSERT( apSongs.size() == apNotes_.size() );
ASSERT( apSongs.size() == asModifiers.size() );
//
// Fill in m_CurStageStats, calculate multiplier
//
+1 -14
View File
@@ -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<NUM_PLAYERS; p++ )