Merge pull request #12600 from pchote/externalmods

Add support for switching to mods from other engine installations.
This commit is contained in:
reaperrr
2017-02-12 13:18:53 +01:00
committed by GitHub
19 changed files with 443 additions and 32 deletions

View File

@@ -39,16 +39,29 @@ namespace OpenRA.Network
FieldLoader.Load(this, yaml);
Manifest mod;
ExternalMod external;
var modVersion = Mods.Split('@');
if (modVersion.Length == 2 && Game.Mods.TryGetValue(modVersion[0], out mod))
ModLabel = "Unknown mod: {0}".F(Mods);
if (modVersion.Length == 2)
{
ModId = modVersion[0];
ModVersion = modVersion[1];
ModLabel = "{0} ({1})".F(mod.Metadata.Title, modVersion[1]);
IsCompatible = Game.Settings.Debug.IgnoreVersionMismatch || ModVersion == mod.Metadata.Version;
if (Game.Mods.TryGetValue(modVersion[0], out mod))
{
ModLabel = "{0} ({1})".F(mod.Metadata.Title, modVersion[1]);
IsCompatible = Game.Settings.Debug.IgnoreVersionMismatch || ModVersion == mod.Metadata.Version;
}
var externalKey = ExternalMod.MakeKey(modVersion[0], modVersion[1]);
if (!IsCompatible && Game.ExternalMods.TryGetValue(externalKey, out external)
&& external.Version == modVersion[1])
{
ModLabel = "{0} ({1})".F(external.Title, external.Version);
IsCompatible = true;
}
}
else
ModLabel = "Unknown mod: {0}".F(Mods);
var mapAvailable = Game.Settings.Game.AllowDownloading || Game.ModData.MapCache[Map].Status == MapStatus.Available;
IsJoinable = IsCompatible && State == 1 && mapAvailable;

View File

@@ -34,6 +34,7 @@ namespace OpenRA.Network
public string ServerError = "Server is not responding";
public bool AuthenticationFailed = false;
public ExternalMod ServerExternalMod = null;
public int NetFrameNumber { get; private set; }
public int LocalFrameNumber;

View File

@@ -135,19 +135,14 @@ namespace OpenRA.Network
var mod = Game.ModData.Manifest;
var request = HandshakeRequest.Deserialize(order.TargetString);
Manifest serverMod;
if (request.Mod != mod.Id &&
Game.Mods.TryGetValue(request.Mod, out serverMod) &&
serverMod.Metadata.Version == request.Version)
var externalKey = ExternalMod.MakeKey(request.Mod, request.Version);
ExternalMod external;
if ((request.Mod != mod.Id || request.Version != mod.Metadata.Version)
&& Game.ExternalMods.TryGetValue(externalKey, out external))
{
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));
// The ConnectionFailedLogic will prompt the user to switch mods
orderManager.ServerExternalMod = external;
orderManager.Connection.Dispose();
break;
}
@@ -187,6 +182,7 @@ namespace OpenRA.Network
case "AuthenticationError":
{
// The ConnectionFailedLogic will prompt the user for the password
orderManager.ServerError = order.TargetString;
orderManager.AuthenticationFailed = true;
break;