fix ScreenSelect loading screens two or three times (!) due to broken
"clear m_sScreen" logic
This commit is contained in:
@@ -608,6 +608,29 @@ static HighScore MakeRandomHighScore( float fPercentDP )
|
||||
return hs;
|
||||
}
|
||||
|
||||
/* Hack: if this GameCommand would set the screen, clear the setting and return
|
||||
* the screen that would have been set. */
|
||||
CString GameCommand::GetAndClearScreen()
|
||||
{
|
||||
CString sRet;
|
||||
FOREACH( Command, m_Commands.v, cmd )
|
||||
{
|
||||
GameCommand gc;
|
||||
gc.m_bInvalid = false;
|
||||
gc.LoadOne( *cmd );
|
||||
if( gc.m_sScreen != "" )
|
||||
{
|
||||
sRet = gc.m_sScreen;
|
||||
m_Commands.v.erase( cmd );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_sScreen = "";
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
void GameCommand::Apply( const vector<PlayerNumber> &vpns ) const
|
||||
{
|
||||
if( m_Commands.v.size() )
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
bool DescribesCurrentModeForAllPlayers() const;
|
||||
bool IsPlayable( CString *why = NULL ) const;
|
||||
bool IsZero() const;
|
||||
CString GetAndClearScreen();
|
||||
|
||||
// Same as what was passed to Load. We need to keep the original commands
|
||||
// so that we know the order of commands when it comes time to Apply.
|
||||
|
||||
@@ -212,9 +212,9 @@ void ScreenSelect::HandleScreenMessage( const ScreenMessage SM )
|
||||
FOREACH_HumanPlayer( p )
|
||||
{
|
||||
GameCommand gc = m_aGameCommands[this->GetSelectionIndex(p)];
|
||||
CString sThisScreen = gc.GetAndClearScreen();
|
||||
if( sScreen == "" )
|
||||
sScreen = gc.m_sScreen;
|
||||
gc.m_sScreen = "";
|
||||
sScreen = sThisScreen;
|
||||
gc.Apply( p );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user