start tidying ServerBrowserLogic
This commit is contained in:
@@ -129,7 +129,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
foreach (var loop in gamesWaiting)
|
foreach (var loop in gamesWaiting)
|
||||||
{
|
{
|
||||||
var game = loop;
|
var game = loop;
|
||||||
var item = ScrollItemWidget.Setup(ServerTemplate, () => currentServer == game, () => currentServer = game);
|
var item = ScrollItemWidget.Setup(ServerTemplate,
|
||||||
|
() => currentServer == game,
|
||||||
|
() => currentServer = game);
|
||||||
item.GetWidget<LabelWidget>("TITLE").GetText = () => "{0} ({1})".F(game.Name, game.Address);
|
item.GetWidget<LabelWidget>("TITLE").GetText = () => "{0} ({1})".F(game.Name, game.Address);
|
||||||
sl.AddChild(item);
|
sl.AddChild(item);
|
||||||
if (i == 0) currentServer = game;
|
if (i == 0) currentServer = game;
|
||||||
@@ -137,6 +139,14 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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. */
|
||||||
|
|
||||||
|
return a == "{DEV_VERSION}" || b == "{DEV_VERSION}" || a == b;
|
||||||
|
}
|
||||||
|
|
||||||
public static bool CanJoin(GameServer game)
|
public static bool CanJoin(GameServer game)
|
||||||
{
|
{
|
||||||
//"waiting for players"
|
//"waiting for players"
|
||||||
@@ -147,9 +157,8 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
if (Game.CurrentMods.Count != game.Mods.Count())
|
if (Game.CurrentMods.Count != game.Mods.Count())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return game.Mods.All( m => m.Contains('@')) && game.Mods.Select( m => Pair.New(m.Split('@')[0], m.Split('@')[1]))
|
return game.Mods.All( m => m.Contains('@')) && game.Mods.Select( m => Pair.New(m.Split('@')[0], m.Split('@')[1]))
|
||||||
.All(kv => Game.CurrentMods.ContainsKey(kv.First) &&
|
.All(kv => Game.CurrentMods.ContainsKey(kv.First) && AreVersionsCompatible(kv.Second, Game.CurrentMods[kv.First].Version));
|
||||||
(kv.Second == "{DEV_VERSION}" || Game.CurrentMods[kv.First].Version == "{DEV_VERSION}" || kv.Second == Game.CurrentMods[kv.First].Version));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user