use BroadcastOnChange wrappers
This commit is contained in:
@@ -641,7 +641,7 @@ void GameCommand::Apply( const vector<PlayerNumber> &vpns ) const
|
||||
}
|
||||
if( m_pSteps )
|
||||
FOREACH_CONST( PlayerNumber, vpns, pn )
|
||||
GAMESTATE->m_pCurSteps[*pn] = m_pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( *pn, m_pSteps );
|
||||
if( m_pCourse )
|
||||
{
|
||||
GAMESTATE->m_pCurCourse = m_pCourse;
|
||||
|
||||
@@ -41,7 +41,12 @@ GameState* GAMESTATE = NULL; // global and accessable from anywhere in our progr
|
||||
#define CHARACTERS_DIR "Characters/"
|
||||
#define NAMES_BLACKLIST_FILE "Data/NamesBlacklist.dat"
|
||||
|
||||
GameState::GameState()
|
||||
GameState::GameState() :
|
||||
m_pCurSong( MESSAGE_CURRENT_SONG_CHANGED ),
|
||||
m_pCurSteps( MESSAGE_CURRENT_STEPS_P1_CHANGED ),
|
||||
m_stEdit( MESSAGE_EDIT_STEPS_TYPE_CHANGED ),
|
||||
m_pEditSourceSteps( MESSAGE_EDIT_SOURCE_STEPS_CHANGED ),
|
||||
m_stEditSource( MESSAGE_EDIT_SOURCE_STEPS_TYPE_CHANGED )
|
||||
{
|
||||
m_pCurStyle = NULL;
|
||||
|
||||
@@ -154,7 +159,7 @@ void GameState::Reset()
|
||||
m_pCurSong.Set( NULL );
|
||||
m_pPreferredSong = NULL;
|
||||
FOREACH_PlayerNumber( p )
|
||||
m_pCurSteps[p] = NULL;
|
||||
m_pCurSteps.Set( p, NULL );
|
||||
m_pCurCourse = NULL;
|
||||
m_pPreferredCourse = NULL;
|
||||
FOREACH_PlayerNumber( p )
|
||||
@@ -208,9 +213,9 @@ void GameState::Reset()
|
||||
|
||||
LIGHTSMAN->SetLightsMode( LIGHTSMODE_ATTRACT );
|
||||
|
||||
m_stEdit = STEPS_TYPE_INVALID;
|
||||
m_pStepsEditSource = NULL;
|
||||
m_stEditSource = STEPS_TYPE_INVALID;
|
||||
m_stEdit.Set( STEPS_TYPE_INVALID );
|
||||
m_pEditSourceSteps.Set( NULL );
|
||||
m_stEditSource.Set( STEPS_TYPE_INVALID );
|
||||
|
||||
ApplyCmdline();
|
||||
}
|
||||
@@ -1841,8 +1846,8 @@ public:
|
||||
static int SetCurrentSteps( T* p, lua_State *L )
|
||||
{
|
||||
PlayerNumber pn = (PlayerNumber)IArg(1);
|
||||
if( lua_isnil(L,2) ) { p->m_pCurSteps[pn] = NULL; }
|
||||
else { Steps *pS = Luna<Steps>::check(L,2); p->m_pCurSteps[pn] = pS; }
|
||||
if( lua_isnil(L,2) ) { p->m_pCurSteps.Set( pn, NULL ); }
|
||||
else { Steps *pS = Luna<Steps>::check(L,2); p->m_pCurSteps.Set( pn, pS ); }
|
||||
MESSAGEMAN->Broadcast( ssprintf("CurrentStepsP%dChanged",pn+1) );
|
||||
return 0;
|
||||
}
|
||||
@@ -1864,6 +1869,13 @@ public:
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
static int GetEditSourceSteps( T* p, lua_State *L )
|
||||
{
|
||||
Steps *pSteps = p->m_pEditSourceSteps;
|
||||
if( pSteps ) { pSteps->PushSelf(L); }
|
||||
else { lua_pushnil(L); }
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void Register(lua_State *L)
|
||||
{
|
||||
@@ -1881,6 +1893,7 @@ public:
|
||||
ADD_METHOD( SetTemporaryEventMode )
|
||||
ADD_METHOD( SetEnv )
|
||||
ADD_METHOD( GetEnv )
|
||||
ADD_METHOD( GetEditSourceSteps )
|
||||
Luna<T>::Register( L );
|
||||
|
||||
// Add global singleton if constructed already. If it's not constructed yet,
|
||||
|
||||
@@ -129,10 +129,10 @@ public:
|
||||
//
|
||||
|
||||
// NULL on ScreenSelectMusic if the currently selected wheel item isn't a Song.
|
||||
BroadcastOnChangePtr<Song,MESSAGE_CURRENT_SONG_CHANGED> m_pCurSong;
|
||||
BroadcastOnChangePtr<Song> m_pCurSong;
|
||||
// The last Song that the user manually changed to.
|
||||
Song* m_pPreferredSong;
|
||||
Steps* m_pCurSteps[NUM_PLAYERS];
|
||||
BroadcastOnChangePtr1D<Steps,NUM_PLAYERS> m_pCurSteps;
|
||||
|
||||
// NULL on ScreenSelectMusic if the currently selected wheel item isn't a Course.
|
||||
Course* m_pCurCourse;
|
||||
@@ -285,9 +285,9 @@ public:
|
||||
//
|
||||
// Edit stuff
|
||||
//
|
||||
StepsType m_stEdit;
|
||||
Steps *m_pStepsEditSource;
|
||||
StepsType m_stEditSource;
|
||||
BroadcastOnChange<StepsType> m_stEdit;
|
||||
BroadcastOnChangePtr<Steps> m_pEditSourceSteps;
|
||||
BroadcastOnChange<StepsType> m_stEditSource;
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
@@ -175,7 +175,7 @@ void MusicWheel::Load()
|
||||
GAMESTATE->m_pPreferredSong = pSong;
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
GAMESTATE->m_pCurSteps[p] = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( p, pSteps );
|
||||
GAMESTATE->m_pPlayerState[p]->m_PlayerOptions = po;
|
||||
GAMESTATE->m_PreferredDifficulty[p] = pSteps->GetDifficulty();
|
||||
}
|
||||
|
||||
@@ -1148,7 +1148,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
|
||||
}
|
||||
|
||||
pSteps = *it;
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1] = m_pSteps = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_1, pSteps );
|
||||
m_pSteps = pSteps;
|
||||
pSteps->GetNoteData( m_NoteDataEdit );
|
||||
SCREENMAN->SystemMessage( ssprintf(
|
||||
"Switched to %s %s '%s'",
|
||||
@@ -1592,7 +1593,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
StepsID id;
|
||||
id.FromSteps( m_pSteps );
|
||||
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1] = NULL; /* make RevertFromDisk not try to reset it */
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_1, NULL ); /* make RevertFromDisk not try to reset it */
|
||||
SONGMAN->RevertFromDisk( GAMESTATE->m_pCurSong );
|
||||
|
||||
CString sMessage = "Reloaded from disk.";
|
||||
@@ -1623,7 +1624,8 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM )
|
||||
|
||||
SCREENMAN->SystemMessage( sMessage );
|
||||
|
||||
m_pSteps = GAMESTATE->m_pCurSteps[PLAYER_1] = pSteps;
|
||||
m_pSteps = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_1, pSteps );
|
||||
m_pSteps->GetNoteData( m_NoteDataEdit );
|
||||
|
||||
break;
|
||||
|
||||
@@ -112,7 +112,7 @@ void ScreenEditMenu::MenuStart( PlayerNumber pn )
|
||||
|
||||
GAMESTATE->m_pCurSong.Set( pSong );
|
||||
GAMESTATE->m_pCurStyle = GAMEMAN->GetEditorStyleForStepsType( st );
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1] = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_1, pSteps );
|
||||
|
||||
//
|
||||
// handle error cases
|
||||
|
||||
@@ -150,8 +150,8 @@ ScreenEnding::ScreenEnding( CString sClassName ) : ScreenAttract( sClassName, fa
|
||||
GAMESTATE->m_MasterPlayerNumber = PLAYER_1;
|
||||
GAMESTATE->m_pCurSong.Set( SONGMAN->GetRandomSong() );
|
||||
GAMESTATE->m_pCurCourse = SONGMAN->GetRandomCourse();
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1] = GAMESTATE->m_pCurSong->GetAllSteps()[0];
|
||||
GAMESTATE->m_pCurSteps[PLAYER_2] = GAMESTATE->m_pCurSong->GetAllSteps()[0];
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_1, GAMESTATE->m_pCurSong->GetAllSteps()[0] );
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_2, GAMESTATE->m_pCurSong->GetAllSteps()[0] );
|
||||
STATSMAN->m_CurStageStats.m_player[PLAYER_1].vpSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] );
|
||||
STATSMAN->m_CurStageStats.m_player[PLAYER_2].vpSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_2] );
|
||||
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_fScrollSpeed = 2;
|
||||
|
||||
@@ -111,8 +111,8 @@ ScreenEvaluation::ScreenEvaluation( CString sClassName ) : ScreenWithMenuElement
|
||||
GAMESTATE->m_pCurSong.Set( SONGMAN->GetRandomSong() );
|
||||
STATSMAN->m_CurStageStats.vpSongs.push_back( GAMESTATE->m_pCurSong );
|
||||
GAMESTATE->m_pCurCourse = SONGMAN->GetRandomCourse();
|
||||
GAMESTATE->m_pCurSteps[PLAYER_1] = GAMESTATE->m_pCurSong->GetAllSteps()[0];
|
||||
GAMESTATE->m_pCurSteps[PLAYER_2] = GAMESTATE->m_pCurSong->GetAllSteps()[0];
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_1, GAMESTATE->m_pCurSong->GetAllSteps()[0] );
|
||||
GAMESTATE->m_pCurSteps.Set( PLAYER_2, GAMESTATE->m_pCurSong->GetAllSteps()[0] );
|
||||
STATSMAN->m_CurStageStats.m_player[PLAYER_1].vpSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_1] );
|
||||
STATSMAN->m_CurStageStats.m_player[PLAYER_2].vpSteps.push_back( GAMESTATE->m_pCurSteps[PLAYER_2] );
|
||||
GAMESTATE->m_pPlayerState[PLAYER_1]->m_PlayerOptions.m_fScrollSpeed = 2;
|
||||
|
||||
@@ -681,7 +681,7 @@ void ScreenEz2SelectMusic::AfterNotesChange( PlayerNumber pn )
|
||||
|
||||
Steps* pSteps = m_arrayNotes[pn].empty()? NULL: m_arrayNotes[pn][m_iSelection[pn]];
|
||||
|
||||
GAMESTATE->m_pCurSteps[pn] = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( pn, pSteps );
|
||||
|
||||
|
||||
if( pSteps != NULL && pn == GAMESTATE->m_MasterPlayerNumber )
|
||||
|
||||
@@ -154,7 +154,7 @@ void ScreenGameplay::Init()
|
||||
|
||||
// fill in difficulty of CPU players with that of the first human player
|
||||
FOREACH_PotentialCpuPlayer(p)
|
||||
GAMESTATE->m_pCurSteps[p] = GAMESTATE->m_pCurSteps[ GAMESTATE->GetFirstHumanPlayer() ];
|
||||
GAMESTATE->m_pCurSteps.Set( p, GAMESTATE->m_pCurSteps[ GAMESTATE->GetFirstHumanPlayer() ] );
|
||||
|
||||
switch( GAMESTATE->m_PlayMode )
|
||||
{
|
||||
@@ -804,7 +804,7 @@ void ScreenGameplay::SetupSong( PlayerNumber p, int iSongIndex )
|
||||
/* This is the first beat that can be changed without it being visible. Until
|
||||
* we draw for the first time, any beat can be changed. */
|
||||
GAMESTATE->m_pPlayerState[p]->m_fLastDrawnBeat = -100;
|
||||
GAMESTATE->m_pCurSteps[p] = m_vpStepsQueue[p][iSongIndex];
|
||||
GAMESTATE->m_pCurSteps.Set( p, m_vpStepsQueue[p][iSongIndex] );
|
||||
|
||||
/* Load new NoteData into Player. Do this before
|
||||
* RebuildPlayerOptionsFromActiveAttacks or else transform mods will get
|
||||
|
||||
@@ -90,7 +90,7 @@ void ScreenGameplayMultiplayer::Init()
|
||||
|
||||
// fill in difficulty of CPU players with that of the first human player
|
||||
FOREACH_PotentialCpuPlayer(p)
|
||||
GAMESTATE->m_pCurSteps[p] = GAMESTATE->m_pCurSteps[ GAMESTATE->GetFirstHumanPlayer() ];
|
||||
GAMESTATE->m_pCurSteps.Set( p, GAMESTATE->m_pCurSteps[ GAMESTATE->GetFirstHumanPlayer() ] );
|
||||
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ void ScreenGameplayMultiplayer::SetupSong( MultiPlayer p, int iSongIndex )
|
||||
/* This is the first beat that can be changed without it being visible. Until
|
||||
* we draw for the first time, any beat can be changed. */
|
||||
GAMESTATE->m_pPlayerState[GAMESTATE->m_MasterPlayerNumber]->m_fLastDrawnBeat = -100;
|
||||
GAMESTATE->m_pCurSteps[GAMESTATE->m_MasterPlayerNumber] = m_vpStepsQueue[iSongIndex];
|
||||
GAMESTATE->m_pCurSteps.Set( GAMESTATE->m_MasterPlayerNumber, m_vpStepsQueue[iSongIndex] );
|
||||
|
||||
/* Load new NoteData into Player. Do this before
|
||||
* RebuildPlayerOptionsFromActiveAttacks or else transform mods will get
|
||||
|
||||
@@ -101,7 +101,7 @@ bool ScreenJukebox::SetSong( bool bDemonstration )
|
||||
// Found something we can use!
|
||||
GAMESTATE->m_pCurSong.Set( pSong );
|
||||
FOREACH_PlayerNumber( p )
|
||||
GAMESTATE->m_pCurSteps[p] = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( p, pSteps );
|
||||
|
||||
return true; // done looking
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ ScreenNameEntryTraditional::ScreenNameEntryTraditional( CString sClassName ) : S
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
ss.m_player[p].vpSteps.push_back( ss.vpSongs[0]->GetAllSteps()[0] );
|
||||
GAMESTATE->m_pCurSteps[p] = ss.m_player[p].vpSteps[0];
|
||||
GAMESTATE->m_pCurSteps.Set( p, ss.m_player[p].vpSteps[0] );
|
||||
ss.m_player[p].iPossibleDancePoints = 1000;
|
||||
ss.m_player[p].iActualDancePoints = 985;
|
||||
|
||||
|
||||
@@ -445,7 +445,7 @@ void ScreenNetSelectMusic::StartSelectedSong()
|
||||
{
|
||||
GAMESTATE->m_PreferredDifficulty[pn] = m_DC[pn];
|
||||
Steps * pSteps = pSong->GetStepsByDifficulty(st,m_DC[pn]);
|
||||
GAMESTATE->m_pCurSteps[pn] = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( pn, pSteps );
|
||||
}
|
||||
|
||||
TweenOffScreen();
|
||||
|
||||
@@ -1225,7 +1225,7 @@ void ScreenSelectMusic::AfterStepsChange( PlayerNumber pn )
|
||||
Song* pSong = GAMESTATE->m_pCurSong;
|
||||
Steps* pSteps = m_vpSteps.empty()? NULL: m_vpSteps[m_iSelection[pn]];
|
||||
|
||||
GAMESTATE->m_pCurSteps[pn] = pSteps;
|
||||
GAMESTATE->m_pCurSteps.Set( pn, pSteps );
|
||||
|
||||
int iScore = 0;
|
||||
if( pSteps )
|
||||
@@ -1397,7 +1397,7 @@ void ScreenSelectMusic::AfterMusicChange()
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
GAMESTATE->m_pCurSteps[p] = NULL;
|
||||
GAMESTATE->m_pCurSteps.Set( p, NULL );
|
||||
GAMESTATE->m_pCurTrail[p] = NULL;
|
||||
m_vpSteps.clear();
|
||||
m_vpTrails.clear();
|
||||
|
||||
@@ -795,14 +795,22 @@ void SongManager::RevertFromDisk( Song *pSong, bool bAllowNotesLoss )
|
||||
if( pSteps != NULL ) { \
|
||||
map<Steps*,StepsID>::iterator it = mapOldStepsToStepsID.find(pSteps); \
|
||||
if( it != mapOldStepsToStepsID.end() ) \
|
||||
pSteps = it->second.ToSteps( pSong, bAllowNotesLoss ); \
|
||||
pSteps = it->second.ToSteps(pSong, bAllowNotesLoss); \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
#define CONVERT_STEPS_POINTER2( pStepsRead, pStepsWrite, p ) do { \
|
||||
if( pStepsRead != NULL ) { \
|
||||
map<Steps*,StepsID>::iterator it = mapOldStepsToStepsID.find(pStepsRead); \
|
||||
if( it != mapOldStepsToStepsID.end() ) \
|
||||
pStepsWrite.Set( p, it->second.ToSteps(pSong, bAllowNotesLoss) ); \
|
||||
} \
|
||||
} while(false)
|
||||
|
||||
|
||||
FOREACH_PlayerNumber( p )
|
||||
{
|
||||
CONVERT_STEPS_POINTER( GAMESTATE->m_pCurSteps[p] );
|
||||
CONVERT_STEPS_POINTER2( GAMESTATE->m_pCurSteps[p], GAMESTATE->m_pCurSteps, p );
|
||||
|
||||
FOREACH( Steps*, STATSMAN->m_CurStageStats.m_player[p].vpSteps, pSteps )
|
||||
CONVERT_STEPS_POINTER( *pSteps );
|
||||
|
||||
Reference in New Issue
Block a user