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:
1 parent
3f5cb818a2
commit
1a85f56fb4
2 files changed
+5
-16
No files matched your search
@@ -774,7 +774,8 @@ namespace VocaluxeLib.Menu
|
|||||||
for (int p = 0; p < _NumPlayerTeams[t]; p++)
|
for (int p = 0; p < _NumPlayerTeams[t]; p++)
|
||||||
{
|
{
|
||||||
int profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile();
|
int profileID = _NameSelections[_NameSelection].GetRandomUnusedProfile();
|
||||||
_AddPlayer(t, profileID);
|
if(profileID >= 0) //only add valid profiles
|
||||||
|
_AddPlayer(t, profileID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -465,23 +465,11 @@ namespace VocaluxeLib.Menu
|
|||||||
|
|
||||||
public int GetRandomUnusedProfile()
|
public int GetRandomUnusedProfile()
|
||||||
{
|
{
|
||||||
int id = -1;
|
|
||||||
|
|
||||||
if (_VisibleProfiles.Count == 0)
|
if (_VisibleProfiles.Count == 0)
|
||||||
return id;
|
return -1;
|
||||||
|
|
||||||
if (_VisibleProfiles.Count == _UsedProfiles.Count)
|
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
|
||||||
return id;
|
return _VisibleProfiles[rand];
|
||||||
|
|
||||||
while (id == -1)
|
|
||||||
{
|
|
||||||
int rand = CBase.Game.GetRandom(_VisibleProfiles.Count);
|
|
||||||
if (_UsedProfiles.Contains(_VisibleProfiles[rand]))
|
|
||||||
continue;
|
|
||||||
id = _VisibleProfiles[rand];
|
|
||||||
}
|
|
||||||
|
|
||||||
return id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _PrepareTiles()
|
private void _PrepareTiles()
|
||||||
|
|||||||
Reference in new issue
Block a user