make the whole version mismatch mechanic user-configurable
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace OpenRA.Network
|
||||
public bool Dedicated;
|
||||
public string Difficulty;
|
||||
public bool Crates = true;
|
||||
public bool AllowVersionMismatch;
|
||||
}
|
||||
|
||||
public Session(string[] mods)
|
||||
|
||||
@@ -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); }
|
||||
}
|
||||
|
||||
@@ -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<CheckboxWidget>("IGNOREVERSIONMISMATCH_CHECKBOX");
|
||||
ignoreVersionMismatchCheckbox.IsChecked = () => Game.Settings.Debug.IgnoreVersionMismatch;
|
||||
ignoreVersionMismatchCheckbox.OnClick = () => Game.Settings.Debug.IgnoreVersionMismatch ^= true;
|
||||
|
||||
bg.Get<ButtonWidget>("BUTTON_CLOSE").OnClick = () =>
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user