Map pool cvar (#12313)

* it just works

* nuke votable

* whoops
This commit is contained in:
Rane
2022-11-01 21:17:35 -04:00
committed by GitHub
parent 784e0ab51f
commit 88186f2106
13 changed files with 59 additions and 16 deletions

View File

@@ -68,7 +68,22 @@ public sealed class GameMapManager : IGameMapManager
public IEnumerable<GameMapPrototype> AllVotableMaps()
{
return _prototypeManager.EnumeratePrototypes<GameMapPrototype>().Where(x => x.Votable);
if (_prototypeManager.TryIndex<GameMapPoolPrototype>(_configurationManager.GetCVar(CCVars.GameMapPool), out var pool))
{
foreach (var map in pool.Maps)
{
if (!_prototypeManager.TryIndex<GameMapPrototype>(map, out var mapProto))
{
Logger.Error("Couldn't index map " + map + " in pool " + pool.ID);
continue;
}
yield return mapProto;
}
} else
{
throw new Exception("Could not index map pool prototype " + _configurationManager.GetCVar(CCVars.GameMapPool) + "!");
}
}
public IEnumerable<GameMapPrototype> AllMaps()
@@ -170,7 +185,6 @@ public sealed class GameMapManager : IGameMapManager
{
Logger.InfoS("mapsel", string.Join(", ", _previousMaps));
var eligible = CurrentlyEligibleMaps()
.Where(x => x.Votable)
.Select(x => (proto: x, weight: GetMapQueuePriority(x.ID)))
.OrderByDescending(x => x.weight).ToArray();
Logger.InfoS("mapsel", string.Join(", ", eligible.Select(x => (x.proto.ID, x.weight))));