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

@@ -27,7 +27,10 @@ namespace OpenRA.Network
Queue<Chunk> chunks = new Queue<Chunk>();
List<byte[]> sync = new List<byte[]>();
readonly int orderLatency;
int ordersFrame;
Dictionary<int, int> lastClientsFrame = new Dictionary<int, int>();
public int LocalClientId => -1;
@@ -122,7 +125,10 @@ namespace OpenRA.Network
}
}
ordersFrame = LobbyInfo.GlobalSettings.OrderLatency;
var gameSpeeds = Game.ModData.Manifest.Get<GameSpeeds>();
var gameSpeedName = LobbyInfo.GlobalSettings.OptionOrDefault("gamespeed", gameSpeeds.DefaultSpeed);
orderLatency = gameSpeeds.Speeds[gameSpeedName].OrderLatency;
ordersFrame = orderLatency;
}
// Do nothing: ignore locally generated orders
@@ -137,7 +143,7 @@ namespace OpenRA.Network
sync.Add(ms.GetBuffer());
// Store the current frame so Receive() can return the next chunk of orders.
ordersFrame = frame + LobbyInfo.GlobalSettings.OrderLatency;
ordersFrame = frame + orderLatency;
}
public void Receive(Action<int, byte[]> packetFn)

View File

@@ -222,8 +222,6 @@ namespace OpenRA.Network
{
public string ServerName;
public string Map;
public int Timestep = 40;
public int OrderLatency = 3; // net tick frames (x 120 = ms)
public int RandomSeed = 0;
public bool AllowSpectators = true;
public string GameUid;

View File

@@ -254,7 +254,6 @@ namespace OpenRA.Network
case "SyncInfo":
{
orderManager.LobbyInfo = Session.Deserialize(order.TargetString);
SetOrderLag(orderManager);
Game.SyncLobbyInfo();
break;
}
@@ -304,7 +303,6 @@ namespace OpenRA.Network
orderManager.LobbyInfo.GlobalSettings = Session.Global.Deserialize(node.Value);
}
SetOrderLag(orderManager);
Game.SyncLobbyInfo();
break;
}
@@ -354,14 +352,5 @@ namespace OpenRA.Network
if (world.OrderValidators.All(vo => vo.OrderValidation(orderManager, world, clientId, order)))
order.Subject.ResolveOrder(order);
}
static void SetOrderLag(OrderManager o)
{
if (o.FramesAhead != o.LobbyInfo.GlobalSettings.OrderLatency && !o.GameStarted)
{
o.FramesAhead = o.LobbyInfo.GlobalSettings.OrderLatency;
Log.Write("server", "Order lag is now {0} frames.", o.LobbyInfo.GlobalSettings.OrderLatency);
}
}
}
}