The command loops are handled.

This commit is contained in:
Jason Felds
2013-04-30 19:32:28 -04:00
parent 09d6203fea
commit 8ff71f01f8
+30 -30
View File
@@ -156,8 +156,8 @@ void GameCommand::Load( int iIndex, const Commands& cmds )
m_bInvalid = false; m_bInvalid = false;
m_Commands = cmds; m_Commands = cmds;
FOREACH_CONST( Command, cmds.v, cmd ) for (Command const &cmd : cmds.v)
LoadOne( *cmd ); LoadOne( cmd );
} }
void GameCommand::LoadOne( const Command& cmd ) void GameCommand::LoadOne( const Command& cmd )
@@ -548,12 +548,12 @@ void GameCommand::Apply( const vector<PlayerNumber> &vpns ) const
if( m_Commands.v.size() ) if( m_Commands.v.size() )
{ {
// We were filled using a GameCommand from metrics. Apply the options in order. // We were filled using a GameCommand from metrics. Apply the options in order.
FOREACH_CONST( Command, m_Commands.v, cmd ) for (Command const &cmd : m_Commands.v)
{ {
GameCommand gc; GameCommand gc;
gc.m_bInvalid = false; gc.m_bInvalid = false;
gc.m_bApplyCommitsScreens = m_bApplyCommitsScreens; gc.m_bApplyCommitsScreens = m_bApplyCommitsScreens;
gc.LoadOne( *cmd ); gc.LoadOne( cmd );
gc.ApplySelf( vpns ); gc.ApplySelf( vpns );
} }
} }
@@ -595,25 +595,25 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
} }
} }
if( m_dc != Difficulty_Invalid ) if( m_dc != Difficulty_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_PreferredDifficulty[*pn].Set( m_dc ); GAMESTATE->m_PreferredDifficulty[pn].Set( m_dc );
if( m_sAnnouncer != "" ) if( m_sAnnouncer != "" )
ANNOUNCER->SwitchAnnouncer( m_sAnnouncer ); ANNOUNCER->SwitchAnnouncer( m_sAnnouncer );
if( m_sPreferredModifiers != "" ) if( m_sPreferredModifiers != "" )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->ApplyPreferredModifiers( *pn, m_sPreferredModifiers ); GAMESTATE->ApplyPreferredModifiers( pn, m_sPreferredModifiers );
if( m_sStageModifiers != "" ) if( m_sStageModifiers != "" )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->ApplyStageModifiers( *pn, m_sStageModifiers ); GAMESTATE->ApplyStageModifiers( pn, m_sStageModifiers );
if( m_LuaFunction.IsSet() ) if( m_LuaFunction.IsSet() )
{ {
Lua *L = LUA->Get(); Lua *L = LUA->Get();
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
{ {
m_LuaFunction.PushSelf( L ); m_LuaFunction.PushSelf( L );
ASSERT( !lua_isnil(L, -1) ); ASSERT( !lua_isnil(L, -1) );
lua_pushnumber( L, *pn ); // 1st parameter lua_pushnumber( L, pn ); // 1st parameter
lua_call( L, 1, 0 ); // call function with 1 argument and 0 results lua_call( L, 1, 0 ); // call function with 1 argument and 0 results
} }
LUA->Release(L); LUA->Release(L);
@@ -626,22 +626,22 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
GAMESTATE->m_pPreferredSong = m_pSong; GAMESTATE->m_pPreferredSong = m_pSong;
} }
if( m_pSteps ) if( m_pSteps )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurSteps[*pn].Set( m_pSteps ); GAMESTATE->m_pCurSteps[pn].Set( m_pSteps );
if( m_pCourse ) if( m_pCourse )
{ {
GAMESTATE->m_pCurCourse.Set( m_pCourse ); GAMESTATE->m_pCurCourse.Set( m_pCourse );
GAMESTATE->m_pPreferredCourse = m_pCourse; GAMESTATE->m_pPreferredCourse = m_pCourse;
} }
if( m_pTrail ) if( m_pTrail )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurTrail[*pn].Set( m_pTrail ); GAMESTATE->m_pCurTrail[pn].Set( m_pTrail );
if( m_CourseDifficulty != Difficulty_Invalid ) if( m_CourseDifficulty != Difficulty_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->ChangePreferredCourseDifficulty( *pn, m_CourseDifficulty ); GAMESTATE->ChangePreferredCourseDifficulty( pn, m_CourseDifficulty );
if( m_pCharacter ) if( m_pCharacter )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
GAMESTATE->m_pCurCharacters[*pn] = m_pCharacter; GAMESTATE->m_pCurCharacters[pn] = m_pCharacter;
for( map<RString,RString>::const_iterator i = m_SetEnv.begin(); i != m_SetEnv.end(); i++ ) for( map<RString,RString>::const_iterator i = m_SetEnv.begin(); i != m_SetEnv.end(); i++ )
{ {
Lua *L = LUA->Get(); Lua *L = LUA->Get();
@@ -659,17 +659,17 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_sSoundPath != "" ) if( m_sSoundPath != "" )
SOUND->PlayOnce( THEME->GetPathS( "", m_sSoundPath ) ); SOUND->PlayOnce( THEME->GetPathS( "", m_sSoundPath ) );
if( m_iWeightPounds != -1 ) if( m_iWeightPounds != -1 )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(*pn)->m_iWeightPounds = m_iWeightPounds; PROFILEMAN->GetProfile(pn)->m_iWeightPounds = m_iWeightPounds;
if( m_iGoalCalories != -1 ) if( m_iGoalCalories != -1 )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(*pn)->m_iGoalCalories = m_iGoalCalories; PROFILEMAN->GetProfile(pn)->m_iGoalCalories = m_iGoalCalories;
if( m_GoalType != GoalType_Invalid ) if( m_GoalType != GoalType_Invalid )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
PROFILEMAN->GetProfile(*pn)->m_GoalType = m_GoalType; PROFILEMAN->GetProfile(pn)->m_GoalType = m_GoalType;
if( !m_sProfileID.empty() ) if( !m_sProfileID.empty() )
FOREACH_CONST( PlayerNumber, vpns, pn ) for (PlayerNumber const &pn : vpns)
ProfileManager::m_sDefaultLocalProfileID[*pn].Set( m_sProfileID ); ProfileManager::m_sDefaultLocalProfileID[pn].Set( m_sProfileID );
if( !m_sUrl.empty() ) if( !m_sUrl.empty() )
{ {
if( HOOKS->GoToURL( m_sUrl ) ) if( HOOKS->GoToURL( m_sUrl ) )
@@ -688,8 +688,8 @@ void GameCommand::ApplySelf( const vector<PlayerNumber> &vpns ) const
if( m_bFadeMusic ) if( m_bFadeMusic )
SOUND->DimMusic(m_fMusicFadeOutVolume, m_fMusicFadeOutSeconds); SOUND->DimMusic(m_fMusicFadeOutVolume, m_fMusicFadeOutSeconds);
FOREACH_CONST( RString, m_vsScreensToPrepare, s ) for (RString const &s : m_vsScreensToPrepare)
SCREENMAN->PrepareScreen( *s ); SCREENMAN->PrepareScreen( s );
if( m_bApplyDefaultOptions ) if( m_bApplyDefaultOptions )
{ {