fix assert when creating new profile
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user