Fix crashing if there are zero profiles defined

This commit is contained in:
Josh Allen
2006-04-09 21:49:42 +00:00
parent 512322c11e
commit da5b02d2b6
+24 -12
View File
@@ -20,6 +20,7 @@ REGISTER_SCREEN_CLASS(ScreenSMOnlineLogin);
AutoScreenMessage( SM_SMOnlinePack ) AutoScreenMessage( SM_SMOnlinePack )
AutoScreenMessage( SM_PasswordDone ) AutoScreenMessage( SM_PasswordDone )
AutoScreenMessage( SM_NoProfilesDefined )
static LocalizedString DEFINE_A_PROFILE( "ScreenSMOnlineLogin", "You must define a Profile." ); static LocalizedString DEFINE_A_PROFILE( "ScreenSMOnlineLogin", "You must define a Profile." );
void ScreenSMOnlineLogin::Init() void ScreenSMOnlineLogin::Init()
@@ -28,21 +29,27 @@ void ScreenSMOnlineLogin::Init()
m_iPlayer = 0; m_iPlayer = 0;
vector<OptionRowHandler*> vHands; vector<OptionRowHandler*> vHands;
vHands.push_back( OptionRowHandlerUtil::MakeNull() );
OptionRowDefinition &def = vHands.back()->m_Def; OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull();
def.m_sName = "Profile";
def.m_bOneChoiceForAllPlayers = false; pHand->m_Def.m_sName = "Profile";
def.m_bAllowThemeItems = false; pHand->m_Def.m_bOneChoiceForAllPlayers = true;
def.m_vEnabledForPlayers.clear(); pHand->m_Def.m_bAllowThemeItems = false;
pHand->m_Def.m_vEnabledForPlayers.clear();
FOREACH_PlayerNumber( pn ) FOREACH_PlayerNumber( pn )
def.m_vEnabledForPlayers.insert( pn ); pHand->m_Def.m_vEnabledForPlayers.insert( pn );
def.m_vsChoices.clear();
PROFILEMAN->GetLocalProfileDisplayNames( def.m_vsChoices ); PROFILEMAN->GetLocalProfileDisplayNames( pHand->m_Def.m_vsChoices );
if( def.m_vsChoices.empty() )
if( pHand->m_Def.m_vsChoices.empty() )
{ {
SCREENMAN->SystemMessage( DEFINE_A_PROFILE ); //Give myself a message so that I can bail out later
SCREENMAN->SetNewScreen("ScreenProfileOptions"); PostScreenMessage(SM_NoProfilesDefined, 0);
SAFE_DELETE(pHand);
} }
else
vHands.push_back( pHand );
InitMenu( vHands ); InitMenu( vHands );
SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions", "music")); SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions", "music"));
@@ -103,6 +110,11 @@ void ScreenSMOnlineLogin::HandleScreenMessage(const ScreenMessage SM)
else else
SCREENMAN->PostMessageToTopScreen( SM_GoToPrevScreen, 0 ); SCREENMAN->PostMessageToTopScreen( SM_GoToPrevScreen, 0 );
} }
else if( SM == SM_NoProfilesDefined )
{
SCREENMAN->SystemMessage(DEFINE_A_PROFILE);
SCREENMAN->SetNewScreen("ScreenOptionsManageProfiles");
}
else if( SM == SM_SMOnlinePack ) else if( SM == SM_SMOnlinePack )
{ {
int ResponceCode = NSMAN->m_SMOnlinePacket.Read1(); int ResponceCode = NSMAN->m_SMOnlinePacket.Read1();