Skip to content

Commit f11f56f

Browse files
authored
Fix PickRandomMap not working with Favourited map list (#657)
1 parent 034090e commit f11f56f

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

DXMainClient/DXGUI/Multiplayer/GameLobby/GameLobbyBase.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,8 @@ private void PickRandomMap()
735735
return;
736736

737737
int random = new Random().Next(0, maps.Count);
738-
GameModeMap = GameModeMaps.Find(gmm => gmm.GameMode == GameMode && gmm.Map == maps[random]);
739-
738+
bool isFavoriteMapsSelected = IsFavoriteMapsSelected();
739+
GameModeMap = GameModeMaps.Find(gmm => (gmm.GameMode == GameMode || gmm.IsFavorite && isFavoriteMapsSelected) && gmm.Map == maps[random]);
740740
Logger.Log("PickRandomMap: Rolled " + random + " out of " + maps.Count + ". Picked map: " + Map.Name);
741741

742742
ChangeMap(GameModeMap);
@@ -747,17 +747,18 @@ private void PickRandomMap()
747747

748748
private List<Map> GetMapList(int playerCount)
749749
{
750-
if (playerCount == 1)
751-
{
752-
List<Map> allMaps = GameMode?.Maps.ToList() ?? new List<Map>();
753-
return allMaps;
754-
}
755-
756-
List<Map> mapList = (GameMode?.Maps.Where(x => x.MaxPlayers == playerCount) ?? Array.Empty<Map>()).ToList();
757-
if (mapList.Count < 1 && playerCount <= MAX_PLAYER_COUNT)
758-
return GetMapList(playerCount + 1);
759-
else
760-
return mapList;
750+
List<Map> maps = IsFavoriteMapsSelected()
751+
? GetFavoriteGameModeMaps().Select(gmm => gmm.Map).ToList()
752+
: GameMode?.Maps.ToList() ?? new List<Map>();
753+
754+
if (playerCount != 1)
755+
{
756+
maps = maps.Where(x => x.MaxPlayers == playerCount).ToList();
757+
if (maps.Count < 1 && playerCount <= MAX_PLAYER_COUNT)
758+
return GetMapList(playerCount + 1);
759+
}
760+
761+
return maps;
761762
}
762763

763764
/// <summary>

0 commit comments

Comments
 (0)