Fix ScreenSelectProfile::Finish()

Unload all profiles first, so we don't end up in a situation where two
players might have the same profile assigned during iteration.
This commit is contained in:
Martin Natano
2022-06-12 23:02:25 +02:00
parent df0a27d607
commit 742a3c1c26
+6 -1
View File
@@ -181,13 +181,18 @@ bool ScreenSelectProfile::Finish(){
if( iUnselectedProfiles && iUsedLocalProfiles < PROFILEMAN->GetNumLocalProfiles() )
return false;
// all ok - load profiles and go to next screen
// unload all profiles, so we don't end up in a situation where two
// players might have the same profile assigned
FOREACH_PlayerNumber( p )
{
MEMCARDMAN->UnlockCard( p );
MEMCARDMAN->UnmountCard( p );
PROFILEMAN->UnloadProfile( p );
}
// all ok - load profiles and go to next screen
FOREACH_PlayerNumber( p )
{
if( m_iSelectedProfiles[p] > 0 )
{
PROFILEMAN->m_sDefaultLocalProfileID[p].Set( PROFILEMAN->GetLocalProfileIDFromIndex( m_iSelectedProfiles[p] - 1 ) );