Remove runtime mod merging. Closes #3421.
This commit is contained in:
@@ -21,49 +21,47 @@ namespace OpenRA.Network
|
||||
public readonly int State = 0;
|
||||
public readonly int Players = 0;
|
||||
public readonly string Map = null;
|
||||
public readonly string[] Mods = { };
|
||||
|
||||
// Retained name compatibility with the master server
|
||||
public readonly string Mods = "";
|
||||
public readonly int TTL = 0;
|
||||
|
||||
public Dictionary<string, string> UsefulMods
|
||||
{
|
||||
get
|
||||
{
|
||||
return Mods
|
||||
.Where(v => v.Contains('@'))
|
||||
.ToDictionary(v => v.Split('@')[0], v => v.Split('@')[1]);
|
||||
}
|
||||
}
|
||||
|
||||
static bool AreVersionsCompatible(string a, string b)
|
||||
{
|
||||
if (Game.Settings.Debug.IgnoreVersionMismatch)
|
||||
return true;
|
||||
|
||||
return a == b;
|
||||
}
|
||||
|
||||
public bool CanJoin()
|
||||
{
|
||||
//"waiting for players"
|
||||
// "waiting for players"
|
||||
if (State != 1)
|
||||
return false;
|
||||
|
||||
// Mods won't match if there are a different number
|
||||
if (Game.CurrentMods.Count != Mods.Count())
|
||||
if (!CompatibleVersion())
|
||||
return false;
|
||||
|
||||
// Don't have the map locally
|
||||
if (!Game.modData.AvailableMaps.ContainsKey(Map))
|
||||
if (!Game.Settings.Game.AllowDownloading)
|
||||
return false;
|
||||
// TODO: We allow joining, then drop on game start if the map isn't available
|
||||
if (!Game.modData.AvailableMaps.ContainsKey(Map) && !Game.Settings.Game.AllowDownloading)
|
||||
return false;
|
||||
|
||||
return CompatibleVersion();
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool CompatibleVersion()
|
||||
{
|
||||
return UsefulMods.All(m => Game.CurrentMods.ContainsKey(m.Key)
|
||||
&& AreVersionsCompatible(m.Value, Game.CurrentMods[m.Key].Version));
|
||||
// Invalid game listing - we require one entry of id@version
|
||||
var modVersion = Mods.Split('@');
|
||||
if (modVersion.Length != 2)
|
||||
return false;
|
||||
|
||||
var mod = Game.modData.Manifest.Mod;
|
||||
|
||||
// Different mod
|
||||
// TODO: Allow mod switch when joining server
|
||||
if (modVersion[0] != mod.Id)
|
||||
return false;
|
||||
|
||||
// Same mod, but different version
|
||||
if (modVersion[1] != mod.Version && !Game.Settings.Debug.IgnoreVersionMismatch)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace OpenRA.Network
|
||||
{
|
||||
public class HandshakeRequest
|
||||
{
|
||||
public string[] Mods;
|
||||
public string Mod;
|
||||
public string Version;
|
||||
public string Map;
|
||||
|
||||
public string Serialize()
|
||||
@@ -36,7 +37,8 @@ namespace OpenRA.Network
|
||||
|
||||
public class HandshakeResponse
|
||||
{
|
||||
public string[] Mods;
|
||||
public string Mod;
|
||||
public string Version;
|
||||
public string Password;
|
||||
[FieldLoader.Ignore] public Session.Client Client;
|
||||
|
||||
@@ -44,7 +46,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
var data = new List<MiniYamlNode>();
|
||||
data.Add( new MiniYamlNode( "Handshake", null,
|
||||
new string[]{ "Mods", "Password" }.Select( p => FieldSaver.SaveField(this, p) ).ToList() ) );
|
||||
new string[]{ "Mod", "Version", "Password" }.Select( p => FieldSaver.SaveField(this, p) ).ToList() ) );
|
||||
data.Add(new MiniYamlNode("Client", FieldSaver.Save(Client)));
|
||||
|
||||
return data.WriteToString();
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Network
|
||||
readonly SyncReport syncReport;
|
||||
readonly FrameData frameData = new FrameData();
|
||||
|
||||
public Session LobbyInfo = new Session(Game.Settings.Game.Mods);
|
||||
public Session LobbyInfo = new Session();
|
||||
public Session.Client LocalClient { get { return LobbyInfo.ClientWithIndex(Connection.LocalClientId); } }
|
||||
public World world;
|
||||
|
||||
|
||||
@@ -34,7 +34,8 @@ namespace OpenRA.Network
|
||||
void StartSavingReplay(byte[] initialContent)
|
||||
{
|
||||
var filename = chooseFilename();
|
||||
var dir = new[] { Platform.SupportDir, "Replays", WidgetUtils.ActiveModId(), WidgetUtils.ActiveModVersion() }.Aggregate(Path.Combine);
|
||||
var mod = Game.modData.Manifest.Mod;
|
||||
var dir = new[] { Platform.SupportDir, "Replays", mod.Id, mod.Version }.Aggregate(Path.Combine);
|
||||
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace OpenRA.Network
|
||||
{
|
||||
try
|
||||
{
|
||||
var session = new Session(Game.Settings.Game.Mods);
|
||||
var session = new Session();
|
||||
|
||||
var ys = MiniYaml.FromString(data);
|
||||
foreach (var y in ys)
|
||||
@@ -123,10 +123,9 @@ namespace OpenRA.Network
|
||||
{
|
||||
public string ServerName;
|
||||
public string Map;
|
||||
public string[] Mods = { "ra" }; // mod names
|
||||
public int OrderLatency = 3; // net tick frames (x 120 = ms)
|
||||
public int OrderLatency = 3; // net tick frames (x 120 = ms)
|
||||
public int RandomSeed = 0;
|
||||
public bool FragileAlliances = false; // Allow diplomatic stance changes after game start.
|
||||
public bool FragileAlliances = false; // Allow diplomatic stance changes after game start.
|
||||
public bool AllowCheats = false;
|
||||
public bool Dedicated;
|
||||
public string Difficulty;
|
||||
@@ -140,12 +139,6 @@ namespace OpenRA.Network
|
||||
public string GameUid;
|
||||
}
|
||||
|
||||
public Session(string[] mods)
|
||||
{
|
||||
this.GlobalSettings.Mods = mods.ToArray();
|
||||
this.GlobalSettings.GameUid = Guid.NewGuid().ToString();
|
||||
}
|
||||
|
||||
public string Serialize()
|
||||
{
|
||||
var clientData = new List<MiniYamlNode>();
|
||||
|
||||
@@ -178,8 +178,8 @@ namespace OpenRA.Network
|
||||
{
|
||||
if (r.Frame == frame)
|
||||
{
|
||||
var mod = Game.modData.Manifest.Mod;
|
||||
Log.Write("sync", "Player: {0} ({1} {2} {3})", Game.Settings.Player.Name, Platform.CurrentPlatform, Environment.OSVersion, Platform.RuntimeVersion);
|
||||
var mod = Game.CurrentMods.First().Value;
|
||||
Log.Write("sync", "Game ID: {0} (Mod: {1} at Version {2})", orderManager.LobbyInfo.GlobalSettings.GameUid, mod.Title, mod.Version);
|
||||
Log.Write("sync", "Sync for net frame {0} -------------", r.Frame);
|
||||
Log.Write("sync", "SharedRandom: {0} (#{1})", r.SyncedRandom, r.TotalCount);
|
||||
|
||||
@@ -119,9 +119,14 @@ namespace OpenRA.Network
|
||||
case "HandshakeRequest":
|
||||
{
|
||||
var request = HandshakeRequest.Deserialize(order.TargetString);
|
||||
var localMods = orderManager.LobbyInfo.GlobalSettings.Mods.Select(m => "{0}@{1}".F(m, Mod.AllMods[m].Version)).ToArray();
|
||||
|
||||
// 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
|
||||
var mod = Game.modData.Manifest.Mod;
|
||||
|
||||
// Check that the map exists on the client
|
||||
// TODO: This will behave badly if joining a server with a different mod
|
||||
// This needs to occur *after* joining the server
|
||||
if (!Game.modData.AvailableMaps.ContainsKey(request.Map))
|
||||
{
|
||||
if (Game.Settings.Game.AllowDownloading)
|
||||
@@ -144,7 +149,8 @@ namespace OpenRA.Network
|
||||
var response = new HandshakeResponse()
|
||||
{
|
||||
Client = info,
|
||||
Mods = localMods,
|
||||
Mod = mod.Id,
|
||||
Version = mod.Version,
|
||||
Password = orderManager.Password
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user