fix assert when creating new profile

This commit is contained in:
Glenn Maynard
2005-08-14 03:28:00 +00:00
parent 7477d63f04
commit 4574e3e496
+9 -12
View File
@@ -42,23 +42,20 @@ static MenuDef g_TempMenu(
static bool ValidateLocalProfileName( const CString &sAnswer, CString &sErrorOut ) static bool ValidateLocalProfileName( const CString &sAnswer, CString &sErrorOut )
{ {
Profile *pProfile = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
ASSERT( pProfile );
CString sCurrentProfileOldName = pProfile->m_sDisplayName;
vector<CString> vsProfileNames;
PROFILEMAN->GetLocalProfileDisplayNames( vsProfileNames );
bool bAlreadyAProfileWithThisName = find( vsProfileNames.begin(), vsProfileNames.end(), sAnswer ) != vsProfileNames.end();
if( sAnswer == "" ) if( sAnswer == "" )
{ {
sErrorOut = "Profile name cannot be blank."; sErrorOut = "Profile name cannot be blank.";
return false; return false;
} }
else if( sAnswer == sCurrentProfileOldName )
{ Profile *pProfile = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID );
return true; if( pProfile != NULL && sAnswer == pProfile->m_sDisplayName )
} return true; // unchanged
else if( bAlreadyAProfileWithThisName )
vector<CString> vsProfileNames;
PROFILEMAN->GetLocalProfileDisplayNames( vsProfileNames );
bool bAlreadyAProfileWithThisName = find( vsProfileNames.begin(), vsProfileNames.end(), sAnswer ) != vsProfileNames.end();
if( bAlreadyAProfileWithThisName )
{ {
sErrorOut = "There is already another profile with this name. Please choose a different name."; sErrorOut = "There is already another profile with this name. Please choose a different name.";
return false; return false;