Partymodes: Fix "Select random" button selecting invalid profiles

which would happen if the number of visible profiles matched the number of used profiles or if there were more slots than usable profiles
This commit is contained in:
derivator committed 2016-10-19 11:26:02 +02:00
1 parent 3f5cb818a2
commit 1a85f56fb4
2 files changed
+5 -16

No files matched your search

+2 -1
View File
@@ -774,7 +774,8 @@ namespace VocaluxeLib.Menu
for (int p = 0; p < _NumPlayerTeams[t]; p++)
{
int profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile();
_AddPlayer(t, profileID);
if(profileID >= 0) //only add valid profiles
_AddPlayer(t, profileID);
}
}
}
+3 -15
View File
@@ -465,23 +465,11 @@ namespace VocaluxeLib.Menu
public int GetRandomUnusedProfile()
{
int id = -1;
if (_VisibleProfiles.Count == 0)
return id;
return -1;
if (_VisibleProfiles.Count == _UsedProfiles.Count)
return id;
while (id == -1)
{
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
continue;
id = _VisibleProfiles[rand];
}
return id;
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
return _VisibleProfiles[rand];
}
private void _PrepareTiles()