diff --git a/stepmania/src/GameCommand.cpp b/stepmania/src/GameCommand.cpp index ab74a4746b..3222b30fbe 100644 --- a/stepmania/src/GameCommand.cpp +++ b/stepmania/src/GameCommand.cpp @@ -52,7 +52,6 @@ void GameCommand::Init() m_bDeletePreparedScreens = false; m_iWeightPounds = -1; m_iGoalCalories = -1; - m_iStopCourseAtSeconds = -1; m_GoalType = GOAL_INVALID; m_bClearBookkeepingData = false; @@ -130,8 +129,6 @@ bool GameCommand::DescribesCurrentMode( PlayerNumber pn ) const return false; if( m_iGoalCalories != -1 && PROFILEMAN->IsUsingProfile(pn) && PROFILEMAN->GetProfile(pn)->m_iGoalCalories != m_iGoalCalories ) return false; - if( m_iStopCourseAtSeconds != -1 && GAMESTATE->m_iStopCourseAtSeconds != m_iStopCourseAtSeconds ) - return false; if( m_GoalType != GOAL_INVALID && PROFILEMAN->IsUsingProfile(pn) && PROFILEMAN->GetProfile(pn)->m_GoalType != m_GoalType ) return false; @@ -322,11 +319,6 @@ void GameCommand::Load( int iIndex, const Commands& cmds ) m_iGoalCalories = atoi( sValue ); } - else if( sName == "stopcourseatseconds" ) - { - m_iStopCourseAtSeconds = atoi( sValue ); - } - else if( sName == "goaltype" ) { m_GoalType = StringToGoalType( sValue ); @@ -682,8 +674,6 @@ void GameCommand::Apply( const vector &vpns ) const FOREACH_CONST( PlayerNumber, vpns, pn ) if( PROFILEMAN->IsUsingProfile(*pn) ) PROFILEMAN->GetProfile(*pn)->m_iGoalCalories = m_iGoalCalories; - if( m_iStopCourseAtSeconds != -1 ) - GAMESTATE->m_iStopCourseAtSeconds = m_iStopCourseAtSeconds; if( m_GoalType != GOAL_INVALID ) FOREACH_CONST( PlayerNumber, vpns, pn ) if( PROFILEMAN->IsUsingProfile(*pn) ) @@ -830,7 +820,6 @@ bool GameCommand::IsZero() const m_SortOrder != SORT_INVALID || m_iWeightPounds != -1 || m_iGoalCalories != -1 || - m_iStopCourseAtSeconds != -1 || m_GoalType != GOAL_INVALID ) return false; diff --git a/stepmania/src/GameCommand.h b/stepmania/src/GameCommand.h index 6f99e92add..f74613893f 100644 --- a/stepmania/src/GameCommand.h +++ b/stepmania/src/GameCommand.h @@ -63,7 +63,6 @@ public: bool m_bDeletePreparedScreens; int m_iWeightPounds; // -1 == none specified int m_iGoalCalories; // -1 == none specified - int m_iStopCourseAtSeconds; // -1 == none specified GoalType m_GoalType; bool m_bClearBookkeepingData; diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 5a00d68713..539261e8bf 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -30,6 +30,7 @@ #include "Actor.h" #include "PlayerState.h" #include "Style.h" +#include "MessageManager.h" #include #include @@ -202,8 +203,6 @@ void GameState::Reset() ASSERT( m_pCurCharacters[p] ); } - m_iStopCourseAtSeconds = -1; - m_bTemporaryEventMode = false; LIGHTSMAN->SetLightsMode( LIGHTSMODE_ATTRACT ); @@ -1804,15 +1803,10 @@ public: static int GetCurrentSong( T* p, lua_State *L ) { if(p->m_pCurSong) p->m_pCurSong->PushSelf(L); else lua_pushnil(L); return 1; } static int SetCurrentSong( T* p, lua_State *L ) { - if( lua_isnil(L,1) ) - { - p->m_pCurSong = NULL; - } - else - { - Song *pS = Luna::check(L,1); - p->m_pCurSong = pS; - } + if( lua_isnil(L,1) ) { p->m_pCurSong = NULL; } + else { Song *pS = Luna::check(L,1); p->m_pCurSong = pS; } + MESSAGEMAN->Broadcast( "CurrentSongChanged" ); + return 0; } static int GetCurrentSteps( T* p, lua_State *L ) @@ -1838,6 +1832,16 @@ public: return 0; } static int SetTemporaryEventMode( T* p, lua_State *L ) { p->m_bTemporaryEventMode = BArg(1); return 0; } + static int SetEnv( T* p, lua_State *L ) { p->m_mapEnv[SArg(1)] = SArg(2); return 0; } + static int GetEnv( T* p, lua_State *L ) + { + map::const_iterator iter = p->m_mapEnv.find(SArg(1)); + if( iter != p->m_mapEnv.end() ) + lua_pushstring(L,iter->second); + else + lua_pushnil(L); + return 1; + } static void Register(lua_State *L) { @@ -1853,13 +1857,19 @@ public: ADD_METHOD( GetCurrentCourse ) ADD_METHOD( SetCurrentCourse ) ADD_METHOD( SetTemporaryEventMode ) + ADD_METHOD( SetEnv ) + ADD_METHOD( GetEnv ) Luna::Register( L ); - // add global singleton - ASSERT( GAMESTATE ); - lua_pushstring(L, "GAMESTATE"); - GAMESTATE->PushSelf( LUA->L ); - lua_settable(L, LUA_GLOBALSINDEX); + // Add global singleton if constructed already. If it's not constructed yet, + // then we'll register it later when we reinit Lua just before + // initializing the display. + if( GAMESTATE ) + { + lua_pushstring(L, "GAMESTATE"); + GAMESTATE->PushSelf( LUA->L ); + lua_settable(L, LUA_GLOBALSINDEX); + } } }; diff --git a/stepmania/src/GameState.h b/stepmania/src/GameState.h index c934c437f8..c4e484423d 100644 --- a/stepmania/src/GameState.h +++ b/stepmania/src/GameState.h @@ -266,11 +266,6 @@ public: // PlayerState* m_pPlayerState[NUM_PLAYERS]; - // - // Workout stuff - // - int m_iStopCourseAtSeconds; // -1 == don't stop early - // // Preference wrappers // @@ -280,7 +275,6 @@ public: bool GetEventMode(); CoinMode GetCoinMode(); Premium GetPremium(); - // Lua void PushSelf( lua_State *L );