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

@@ -115,6 +115,7 @@ namespace Content.Client.Entry
_prototypeManager.RegisterIgnore("htnCompound"); _prototypeManager.RegisterIgnore("htnCompound");
_prototypeManager.RegisterIgnore("htnPrimitive"); _prototypeManager.RegisterIgnore("htnPrimitive");
_prototypeManager.RegisterIgnore("gameMap"); _prototypeManager.RegisterIgnore("gameMap");
_prototypeManager.RegisterIgnore("gameMapPool");
_prototypeManager.RegisterIgnore("faction"); _prototypeManager.RegisterIgnore("faction");
_prototypeManager.RegisterIgnore("lobbyBackground"); _prototypeManager.RegisterIgnore("lobbyBackground");
_prototypeManager.RegisterIgnore("advertisementsPack"); _prototypeManager.RegisterIgnore("advertisementsPack");

View File

@@ -68,7 +68,22 @@ public sealed class GameMapManager : IGameMapManager
public IEnumerable<GameMapPrototype> AllVotableMaps() 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() public IEnumerable<GameMapPrototype> AllMaps()
@@ -170,7 +185,6 @@ public sealed class GameMapManager : IGameMapManager
{ {
Logger.InfoS("mapsel", string.Join(", ", _previousMaps)); Logger.InfoS("mapsel", string.Join(", ", _previousMaps));
var eligible = CurrentlyEligibleMaps() var eligible = CurrentlyEligibleMaps()
.Where(x => x.Votable)
.Select(x => (proto: x, weight: GetMapQueuePriority(x.ID))) .Select(x => (proto: x, weight: GetMapQueuePriority(x.ID)))
.OrderByDescending(x => x.weight).ToArray(); .OrderByDescending(x => x.weight).ToArray();
Logger.InfoS("mapsel", string.Join(", ", eligible.Select(x => (x.proto.ID, x.weight)))); Logger.InfoS("mapsel", string.Join(", ", eligible.Select(x => (x.proto.ID, x.weight))));

View File

@@ -0,0 +1,22 @@
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
namespace Content.Server.Maps;
/// <summary>
/// Prototype that holds a pool of maps that can be indexed based on the map pool CCVar.
/// </summary>
[Prototype("gameMapPool"), PublicAPI]
public sealed class GameMapPoolPrototype : IPrototype
{
/// <inheritdoc/>
[IdDataField]
public string ID { get; } = default!;
/// <summary>
/// Which maps are in this pool.
/// </summary>
[DataField("maps", customTypeSerializer:typeof(PrototypeIdHashSetSerializer<GameMapPrototype>), required: true)]
public readonly HashSet<string> Maps = new(0);
}

View File

@@ -8,12 +8,6 @@ public sealed partial class GameMapPrototype
[DataField("fallback")] [DataField("fallback")]
public bool Fallback { get; } public bool Fallback { get; }
/// <summary>
/// Controls if the map can be voted for.
/// </summary>
[DataField("votable")]
public bool Votable { get; } = true;
/// <summary> /// <summary>
/// Minimum players for the given map. /// Minimum players for the given map.
/// </summary> /// </summary>

View File

@@ -184,6 +184,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<string> public static readonly CVarDef<string>
GameMap = CVarDef.Create("game.map", "Saltern", CVar.SERVERONLY); GameMap = CVarDef.Create("game.map", "Saltern", CVar.SERVERONLY);
/// <summary>
/// Prototype to use for map pool.
/// </summary>
public static readonly CVarDef<string>
GameMapPool = CVarDef.Create("game.map_pool", "DefaultMapPool", CVar.SERVERONLY);
/// <summary> /// <summary>
/// Controls if the game should obey map criteria or not. Overriden if a map vote or similar occurs. /// Controls if the game should obey map criteria or not. Overriden if a map vote or similar occurs.
/// </summary> /// </summary>

View File

@@ -0,0 +1,13 @@
- type: gameMapPool
id: DefaultMapPool
maps:
- Bagel
- Box
- Cluster
- Kettle
- Lighthouse
- Marathon
- Omega
- Origin
- Pillar
- Saltern

View File

@@ -3,7 +3,6 @@
mapName: 'Central Command' mapName: 'Central Command'
mapPath: /Maps/centcomm.yml mapPath: /Maps/centcomm.yml
minPlayers: 10 minPlayers: 10
votable: false
stations: stations:
centcomm: centcomm:
mapNameTemplate: '{0} Central Command {1}' mapNameTemplate: '{0} Central Command {1}'

View File

@@ -4,7 +4,6 @@
mapPath: /Maps/cluster.yml mapPath: /Maps/cluster.yml
minPlayers: 0 minPlayers: 0
maxPlayers: 35 maxPlayers: 35
votable: true
stations: stations:
Cluster: Cluster:
mapNameTemplate: '{0} Cluster Station {1}' mapNameTemplate: '{0} Cluster Station {1}'

View File

@@ -3,7 +3,6 @@
mapName: 'Dart ERT' mapName: 'Dart ERT'
mapPath: /Maps/dart.yml mapPath: /Maps/dart.yml
minPlayers: 0 minPlayers: 0
votable: false
stations: stations:
Dart: Dart:
mapNameTemplate: '{0} Dart ERT {1}' mapNameTemplate: '{0} Dart ERT {1}'
@@ -16,4 +15,4 @@
ERTEngineer: [ 0, 1 ] ERTEngineer: [ 0, 1 ]
ERTSecurity: [ 0, 1 ] ERTSecurity: [ 0, 1 ]
ERTMedical: [ 0, 1 ] ERTMedical: [ 0, 1 ]
ERTJanitor: [ 0, 1 ] ERTJanitor: [ 0, 1 ]

View File

@@ -3,7 +3,6 @@
mapName: 'Syndicate Infiltrator' mapName: 'Syndicate Infiltrator'
mapPath: /Maps/infiltrator.yml mapPath: /Maps/infiltrator.yml
minPlayers: 0 minPlayers: 0
votable: false
stations: stations:
Station: #TODO: Mapper, add a BecomesStation component to the primary grid of the map. Station: #TODO: Mapper, add a BecomesStation component to the primary grid of the map.
mapNameTemplate: '{0} Infiltrator {1}' mapNameTemplate: '{0} Infiltrator {1}'

View File

@@ -4,7 +4,6 @@
mapPath: /Maps/omega.yml mapPath: /Maps/omega.yml
minPlayers: 0 minPlayers: 0
maxPlayers: 35 maxPlayers: 35
votable: true
stations: stations:
Omega: Omega:
mapNameTemplate: '{0} Omega Station {1}' mapNameTemplate: '{0} Omega Station {1}'

View File

@@ -3,7 +3,6 @@
mapName: 'Pirate Ship' mapName: 'Pirate Ship'
mapPath: /Maps/pirate.yml mapPath: /Maps/pirate.yml
minPlayers: 0 minPlayers: 0
votable: false
stations: stations:
Station: #TODO: Mapper, add a BecomesStation component to the primary grid of the map. Station: #TODO: Mapper, add a BecomesStation component to the primary grid of the map.
mapNameTemplate: '{0} Pirate {1}' mapNameTemplate: '{0} Pirate {1}'

View File

@@ -3,7 +3,6 @@
mapName: Empty mapName: Empty
mapPath: /Maps/Test/empty.yml mapPath: /Maps/Test/empty.yml
minPlayers: 0 minPlayers: 0
votable: false
stations: stations:
Empty: Empty:
mapNameTemplate: "Empty" mapNameTemplate: "Empty"