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 Dedicated = false;
|
||||||
public bool DedicatedLoop = true;
|
public bool DedicatedLoop = true;
|
||||||
public bool LockBots = false;
|
public bool LockBots = false;
|
||||||
|
public bool AllowVersionMismatch = false;
|
||||||
|
|
||||||
public ServerSettings() { }
|
public ServerSettings() { }
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ namespace OpenRA.GameRules
|
|||||||
Dedicated = other.Dedicated;
|
Dedicated = other.Dedicated;
|
||||||
DedicatedLoop = other.DedicatedLoop;
|
DedicatedLoop = other.DedicatedLoop;
|
||||||
LockBots = other.LockBots;
|
LockBots = other.LockBots;
|
||||||
|
AllowVersionMismatch = other.AllowVersionMismatch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,6 +68,7 @@ namespace OpenRA.GameRules
|
|||||||
public float LongTickThreshold = 0.001f;
|
public float LongTickThreshold = 0.001f;
|
||||||
public bool SanityCheckUnsyncedCode = false;
|
public bool SanityCheckUnsyncedCode = false;
|
||||||
public int Samples = 25;
|
public int Samples = 25;
|
||||||
|
public bool IgnoreVersionMismatch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GraphicSettings
|
public class GraphicSettings
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ namespace OpenRA.Network
|
|||||||
|
|
||||||
static bool AreVersionsCompatible(string a, string b)
|
static bool AreVersionsCompatible(string a, string b)
|
||||||
{
|
{
|
||||||
/* dev versions are assumed compatible; if you're using one,
|
if (Game.Settings.Debug.IgnoreVersionMismatch)
|
||||||
* we trust that you know what you're doing. */
|
return true;
|
||||||
|
|
||||||
return a == "{DEV_VERSION}" || b == "{DEV_VERSION}" || a == b;
|
return a == b;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CanJoin()
|
public bool CanJoin()
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ namespace OpenRA.Network
|
|||||||
public bool Dedicated;
|
public bool Dedicated;
|
||||||
public string Difficulty;
|
public string Difficulty;
|
||||||
public bool Crates = true;
|
public bool Crates = true;
|
||||||
|
public bool AllowVersionMismatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Session(string[] mods)
|
public Session(string[] mods)
|
||||||
|
|||||||
@@ -283,12 +283,11 @@ namespace OpenRA.Server
|
|||||||
var mods = handshake.Mods;
|
var mods = handshake.Mods;
|
||||||
|
|
||||||
// Check that the client has compatible mods
|
// Check that the client has compatible mods
|
||||||
var valid = mods.All( m => m.Contains('@')) && //valid format
|
var validMod = mods.All(m => m.Contains('@')) && //valid format
|
||||||
mods.Count() == Game.CurrentMods.Count() && //same number
|
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) &&
|
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 (!validMod)
|
||||||
if (!valid)
|
|
||||||
{
|
{
|
||||||
Log.Write("server", "Rejected connection from {0}; mods do not match.",
|
Log.Write("server", "Rejected connection from {0}; mods do not match.",
|
||||||
newConn.socket.RemoteEndPoint);
|
newConn.socket.RemoteEndPoint);
|
||||||
@@ -297,14 +296,16 @@ namespace OpenRA.Server
|
|||||||
DropClient(newConn);
|
DropClient(newConn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Drop DEV_VERSION if it's a Dedicated
|
var validVersion = mods.Select(m => Pair.New(m.Split('@')[0], m.Split('@')[1])).All(
|
||||||
if ( lobbyInfo.GlobalSettings.Dedicated && mods.Any(m => m.Contains("{DEV_VERSION}")) )
|
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);
|
newConn.socket.RemoteEndPoint);
|
||||||
|
|
||||||
SendOrderTo(newConn, "ServerError", "DEV_VERSION is not allowed here");
|
SendOrderTo(newConn, "ServerError", "Not running the same version.");
|
||||||
DropClient(newConn);
|
DropClient(newConn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -366,8 +367,8 @@ namespace OpenRA.Server
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mods.Any(m => m.Contains("{DEV_VERSION}")))
|
if (mods.Any(m => m.Contains("{DEV_VERSION}")))
|
||||||
SendChat(newConn, "is running a development version, "+
|
SendChat(newConn, "is running a non-versioned development build, "+
|
||||||
"and may cause desync if they have any incompatible changes.");
|
"and may cause desync if it contains any incompatible changes.");
|
||||||
}
|
}
|
||||||
catch (Exception) { DropClient(newConn); }
|
catch (Exception) { DropClient(newConn); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,6 +230,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
longTickThreshold.Value = Game.Settings.Debug.LongTickThreshold;
|
longTickThreshold.Value = Game.Settings.Debug.LongTickThreshold;
|
||||||
longTickThreshold.OnChange += x => Game.Settings.Debug.LongTickThreshold = x;
|
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 = () =>
|
bg.Get<ButtonWidget>("BUTTON_CLOSE").OnClick = () =>
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|||||||
@@ -392,3 +392,9 @@ Background@SETTINGS_MENU:
|
|||||||
Ticks:25
|
Ticks:25
|
||||||
MinimumValue: 0.0001
|
MinimumValue: 0.0001
|
||||||
MaximumValue: 0.01
|
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