Automatically switch mods when connecting to a server / replay.
This commit is contained in:
@@ -51,6 +51,8 @@ namespace OpenRA.Network
|
||||
|
||||
public readonly ReadOnlyList<ChatLine> ChatCache;
|
||||
|
||||
bool disposed;
|
||||
|
||||
static void OutOfSync(int frame)
|
||||
{
|
||||
throw new InvalidOperationException("Out of sync in frame {0}.\n Compare syncreport.log with other players.".F(frame));
|
||||
@@ -122,8 +124,16 @@ namespace OpenRA.Network
|
||||
});
|
||||
|
||||
foreach (var p in immediatePackets)
|
||||
{
|
||||
foreach (var o in p.Second.ToOrderList(World))
|
||||
{
|
||||
UnitOrders.ProcessOrder(this, World, p.First, o);
|
||||
|
||||
// A mod switch or other event has pulled the ground from beneath us
|
||||
if (disposed)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dictionary<int, byte[]> syncForFrame = new Dictionary<int, byte[]>();
|
||||
@@ -213,6 +223,7 @@ namespace OpenRA.Network
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
disposed = true;
|
||||
if (Connection != null)
|
||||
Connection.Dispose();
|
||||
}
|
||||
|
||||
@@ -33,9 +33,12 @@ namespace OpenRA.Network
|
||||
public readonly int TickCount;
|
||||
public readonly bool IsValid;
|
||||
public readonly Session LobbyInfo;
|
||||
public readonly string Filename;
|
||||
|
||||
public ReplayConnection(string replayFilename)
|
||||
{
|
||||
Filename = replayFilename;
|
||||
|
||||
// Parse replay data into a struct that can be fed to the game in chunks
|
||||
// to avoid issues with all immediate orders being resolved on the first tick.
|
||||
using (var rs = File.OpenRead(replayFilename))
|
||||
|
||||
@@ -119,10 +119,27 @@ namespace OpenRA.Network
|
||||
|
||||
case "HandshakeRequest":
|
||||
{
|
||||
// TODO: Switch to the server's mod if we have it
|
||||
// Otherwise send the handshake with our current settings and let the server reject us
|
||||
// Switch to the server's mod if we need and are able to
|
||||
var mod = Game.modData.Manifest.Mod;
|
||||
var request = HandshakeRequest.Deserialize(order.TargetString);
|
||||
|
||||
ModMetadata serverMod;
|
||||
if (request.Mod != mod.Id &&
|
||||
ModMetadata.AllMods.TryGetValue(request.Mod, out serverMod) &&
|
||||
serverMod.Version == request.Version)
|
||||
{
|
||||
var replay = orderManager.Connection as ReplayConnection;
|
||||
var launchCommand = replay != null ?
|
||||
"Launch.Replay=" + replay.Filename :
|
||||
"Launch.Connect=" + orderManager.Host + ":" + orderManager.Port;
|
||||
|
||||
Game.modData.LoadScreen.Display();
|
||||
Game.InitializeMod(request.Mod, new Arguments(launchCommand));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Otherwise send the handshake with our current settings and let the server reject us
|
||||
var info = new Session.Client()
|
||||
{
|
||||
Name = Game.Settings.Player.Name,
|
||||
|
||||
Reference in New Issue
Block a user