diff --git a/OpenRA.Game/GameRules/Settings.cs b/OpenRA.Game/GameRules/Settings.cs index 448220c73f..8be6cfa6a3 100644 --- a/OpenRA.Game/GameRules/Settings.cs +++ b/OpenRA.Game/GameRules/Settings.cs @@ -37,6 +37,7 @@ namespace OpenRA.GameRules public bool Dedicated = false; public bool DedicatedLoop = true; public bool LockBots = false; + public bool AllowVersionMismatch = false; public ServerSettings() { } @@ -55,6 +56,7 @@ namespace OpenRA.GameRules Dedicated = other.Dedicated; DedicatedLoop = other.DedicatedLoop; LockBots = other.LockBots; + AllowVersionMismatch = other.AllowVersionMismatch; } } @@ -66,6 +68,7 @@ namespace OpenRA.GameRules public float LongTickThreshold = 0.001f; public bool SanityCheckUnsyncedCode = false; public int Samples = 25; + public bool IgnoreVersionMismatch = false; } public class GraphicSettings diff --git a/OpenRA.Game/Network/GameServer.cs b/OpenRA.Game/Network/GameServer.cs index 83e4945078..6bdd6bdb96 100644 --- a/OpenRA.Game/Network/GameServer.cs +++ b/OpenRA.Game/Network/GameServer.cs @@ -36,10 +36,10 @@ namespace OpenRA.Network static bool AreVersionsCompatible(string a, string b) { - /* dev versions are assumed compatible; if you're using one, - * we trust that you know what you're doing. */ + if (Game.Settings.Debug.IgnoreVersionMismatch) + return true; - return a == "{DEV_VERSION}" || b == "{DEV_VERSION}" || a == b; + return a == b; } public bool CanJoin() diff --git a/OpenRA.Game/Network/Session.cs b/OpenRA.Game/Network/Session.cs index c10ff6fe82..f7198c45c8 100644 --- a/OpenRA.Game/Network/Session.cs +++ b/OpenRA.Game/Network/Session.cs @@ -87,6 +87,7 @@ namespace OpenRA.Network public bool Dedicated; public string Difficulty; public bool Crates = true; + public bool AllowVersionMismatch; } public Session(string[] mods) diff --git a/OpenRA.Game/Server/Server.cs b/OpenRA.Game/Server/Server.cs index 437a1927af..33086d414a 100644 --- a/OpenRA.Game/Server/Server.cs +++ b/OpenRA.Game/Server/Server.cs @@ -283,12 +283,11 @@ namespace OpenRA.Server var mods = handshake.Mods; // Check that the client has compatible mods - var valid = mods.All( m => m.Contains('@')) && //valid format - mods.Count() == Game.CurrentMods.Count() && //same number - mods.Select( m => Pair.New(m.Split('@')[0], m.Split('@')[1])).All(kv => Game.CurrentMods.ContainsKey(kv.First) && - (kv.Second == "{DEV_VERSION}" || Game.CurrentMods[kv.First].Version == "{DEV_VERSION}" || kv.Second == Game.CurrentMods[kv.First].Version)); - - if (!valid) + var validMod = mods.All(m => m.Contains('@')) && //valid format + mods.Count() == Game.CurrentMods.Count() && //same number + mods.Select(m => Pair.New(m.Split('@')[0], m.Split('@')[1])).All(kv => Game.CurrentMods.ContainsKey(kv.First)); + + if (!validMod) { Log.Write("server", "Rejected connection from {0}; mods do not match.", newConn.socket.RemoteEndPoint); @@ -297,14 +296,16 @@ namespace OpenRA.Server DropClient(newConn); return; } - - // Drop DEV_VERSION if it's a Dedicated - if ( lobbyInfo.GlobalSettings.Dedicated && mods.Any(m => m.Contains("{DEV_VERSION}")) ) + + var validVersion = mods.Select(m => Pair.New(m.Split('@')[0], m.Split('@')[1])).All( + kv => kv.Second == Game.CurrentMods[kv.First].Version); + + if (!validVersion && !lobbyInfo.GlobalSettings.AllowVersionMismatch) { - Log.Write("server", "Rejected connection from {0}; DEV_VERSION is not allowed here.", + Log.Write("server", "Rejected connection from {0}; Not running the same version.", newConn.socket.RemoteEndPoint); - SendOrderTo(newConn, "ServerError", "DEV_VERSION is not allowed here"); + SendOrderTo(newConn, "ServerError", "Not running the same version."); DropClient(newConn); return; } @@ -366,8 +367,8 @@ namespace OpenRA.Server } if (mods.Any(m => m.Contains("{DEV_VERSION}"))) - SendChat(newConn, "is running a development version, "+ - "and may cause desync if they have any incompatible changes."); + SendChat(newConn, "is running a non-versioned development build, "+ + "and may cause desync if it contains any incompatible changes."); } catch (Exception) { DropClient(newConn); } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs index 3c643c0df2..f7222d91a4 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/SettingsMenuLogic.cs @@ -230,6 +230,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic longTickThreshold.Value = Game.Settings.Debug.LongTickThreshold; longTickThreshold.OnChange += x => Game.Settings.Debug.LongTickThreshold = x; + var ignoreVersionMismatchCheckbox = debug.Get("IGNOREVERSIONMISMATCH_CHECKBOX"); + ignoreVersionMismatchCheckbox.IsChecked = () => Game.Settings.Debug.IgnoreVersionMismatch; + ignoreVersionMismatchCheckbox.OnClick = () => Game.Settings.Debug.IgnoreVersionMismatch ^= true; + bg.Get("BUTTON_CLOSE").OnClick = () => { int x, y; diff --git a/mods/ra/chrome/settings.yaml b/mods/ra/chrome/settings.yaml index d6a38a33b1..eead630744 100644 --- a/mods/ra/chrome/settings.yaml +++ b/mods/ra/chrome/settings.yaml @@ -392,3 +392,9 @@ Background@SETTINGS_MENU: Ticks:25 MinimumValue: 0.0001 MaximumValue: 0.01 + Checkbox@IGNOREVERSIONMISMATCH_CHECKBOX: + X:0 + Y:210 + Width:300 + Height:20 + Text:Don't check for compatible version in game server browser. \ No newline at end of file