fix PlayMode change message being broadcast multiple times if 2 players joined

This commit is contained in:
Chris Danford
2005-07-25 06:47:43 +00:00
parent 240666b390
commit cdb3b2da17
+30
View File
@@ -174,6 +174,34 @@ void ScreenSelect::Input( const DeviceInput& DeviceI, const InputEventType type,
void ScreenSelect::HandleScreenMessage( const ScreenMessage SM ) void ScreenSelect::HandleScreenMessage( const ScreenMessage SM )
{ {
if( SM == SM_BeginFadingOut ) /* Screen is starting to tween out. */ if( SM == SM_BeginFadingOut ) /* Screen is starting to tween out. */
{
/*
* Don't call GameCommand::Apply once per player on screens that
* have a shared selection. This can cause change messages to be broadcast
* multiple times. Detect whether all players have the same choice, and
* if so, call ApplyToAll instead.
* TODO: Think of a better way to handle this.
*/
int iMastersIndex = this->GetSelectionIndex( GAMESTATE->m_MasterPlayerNumber );
bool bAllPlayersChoseTheSame = true;
FOREACH_HumanPlayer( p )
{
if( this->GetSelectionIndex(p) != iMastersIndex )
{
bAllPlayersChoseTheSame = false;
break;
}
}
if( bAllPlayersChoseTheSame )
{
GameCommand &gc = m_aGameCommands[iMastersIndex];
CString sThisScreen = gc.GetAndClearScreen();
if( m_sNextScreen == "" )
m_sNextScreen = sThisScreen;
gc.ApplyToAllPlayers();
}
else
{ {
FOREACH_HumanPlayer( p ) FOREACH_HumanPlayer( p )
{ {
@@ -184,6 +212,8 @@ void ScreenSelect::HandleScreenMessage( const ScreenMessage SM )
m_sNextScreen = sThisScreen; m_sNextScreen = sThisScreen;
gc.Apply( p ); gc.Apply( p );
} }
}
SCREENMAN->RefreshCreditsMessages(); SCREENMAN->RefreshCreditsMessages();