Add Server.MapPool setting for dedicated servers.

This takes a list of map UIDs which may be locally installed or hosted
on the resource center. If any maps aren't found, startup will be
delayed by up to 10 seconds while it attempts to query the resource
center.
This commit is contained in:
Paul Chote
2021-05-09 17:18:25 +01:00
committed by Gustas
parent 01fec1ae02
commit 72646fc7ff
4 changed files with 95 additions and 16 deletions

View File

@@ -128,7 +128,8 @@ namespace OpenRA.Server
// Managed by LobbyCommands
public MapPreview Map;
public readonly MapStatusCache MapStatusCache;
public GameSave GameSave = null;
public GameSave GameSave;
public HashSet<string> MapPool;
// Default to the next frame for ServerType.Local - MP servers take the value from the selected GameSpeed.
public int OrderLatency = 1;
@@ -316,7 +317,6 @@ namespace OpenRA.Server
serverTraits.TrimExcess();
Map = ModData.MapCache[settings.Map];
MapStatusCache = new MapStatusCache(modData, MapStatusChanged, type == ServerType.Dedicated && settings.EnableLintChecks);
playerMessageTracker = new PlayerMessageTracker(this, DispatchOrdersToClient, SendLocalizedMessageTo);
@@ -327,8 +327,6 @@ namespace OpenRA.Server
GlobalSettings =
{
RandomSeed = randomSeed,
Map = Map.Uid,
MapStatus = Session.MapStatus.Unknown,
ServerName = settings.Name,
EnableSingleplayer = settings.EnableSingleplayer || Type != ServerType.Dedicated,
EnableSyncReports = settings.EnableSyncReports,
@@ -348,8 +346,7 @@ namespace OpenRA.Server
new Thread(_ =>
{
// Initial status is set off the main thread to avoid triggering a load screen when joining a skirmish game
LobbyInfo.GlobalSettings.MapStatus = MapStatusCache[Map];
// Note: at least one of these is required to set the initial LobbyInfo.Map and MapStatus
foreach (var t in serverTraits.WithInterface<INotifyServerStart>())
t.ServerStarted(this);
@@ -1434,6 +1431,27 @@ namespace OpenRA.Server
return new ConnectionTarget(endpoints);
}
public bool MapIsUnknown(string uid)
{
if (string.IsNullOrEmpty(uid))
return true;
var status = ModData.MapCache[uid].Status;
return status != MapStatus.Available && status != MapStatus.DownloadAvailable;
}
public bool MapIsKnown(string uid)
{
if (string.IsNullOrEmpty(uid))
return false;
if (MapPool != null && !MapPool.Contains(uid))
return false;
var status = ModData.MapCache[uid].Status;
return status == MapStatus.Available || status == MapStatus.DownloadAvailable;
}
interface IServerEvent { void Invoke(Server server); }
sealed class ConnectionConnectEvent : IServerEvent