Refactor GameSpeed setting

*Remove internal GameSpeed defaults
 Enforce setting values explicitly all the time
 Require definition of a DefaultSpeed

*Remove Global.Timestep default

*Remove the hacky Timestep/OrderLatency setting via LobbyInfo

*Fix shellmaps ignoring mod-defined gamespeeds

*Make DateTimeGlobal use the MapOptions gamespeed
This commit is contained in:
reaperrr
2021-04-02 14:11:45 +02:00
committed by Paul Chote
parent fe129956bb
commit 1a9dfc0893
22 changed files with 214 additions and 205 deletions

View File

@@ -36,7 +36,12 @@ namespace OpenRA
readonly Queue<Action<World>> frameEndActions = new Queue<Action<World>>();
public int Timestep;
public readonly GameSpeed GameSpeed;
public readonly int Timestep;
public readonly int OrderLatency;
public int ReplayTimestep;
internal readonly OrderManager OrderManager;
public Session LobbyInfo => OrderManager.LobbyInfo;
@@ -180,7 +185,18 @@ namespace OpenRA
OrderManager = orderManager;
orderGenerator = new UnitOrderGenerator();
Map = map;
Timestep = orderManager.LobbyInfo.GlobalSettings.Timestep;
var gameSpeeds = modData.Manifest.Get<GameSpeeds>();
var gameSpeedName = orderManager.LobbyInfo.GlobalSettings.OptionOrDefault("gamespeed", gameSpeeds.DefaultSpeed);
GameSpeed = gameSpeeds.Speeds[gameSpeedName];
Timestep = ReplayTimestep = GameSpeed.Timestep;
OrderLatency = GameSpeed.OrderLatency;
// HACK: Turn down the latency if there is only one real player/spectator
if (orderManager.LobbyInfo.NonBotClients.Count() == 1)
OrderLatency = 1;
SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
LocalRandom = new MersenneTwister();