give GameServer some UsefulMods so we have the remote mod version in the ServerBrowser.

This commit is contained in:
alzeih
2011-03-07 20:50:10 +13:00
committed by Chris Forbes
parent 900e55900a
commit 22aa1308ce
2 changed files with 11 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.Text; using System.Text;
using System.Threading; using System.Threading;
using System.Collections.Generic;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -78,5 +79,11 @@ namespace OpenRA.Server
public readonly string Map = null; public readonly string Map = null;
public readonly string[] Mods = { }; public readonly string[] Mods = { };
public readonly int TTL = 0; 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]);
}
}
} }
} }

View File

@@ -105,11 +105,10 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
string GenerateModsLabel() string GenerateModsLabel()
{ {
return string.Join("\n", currentServer.Mods return string.Join("\n", currentServer.UsefulMods
.Select( m => m.Split('@')[0] )
.Select(m => .Select(m =>
Mod.AllMods.ContainsKey(m) ? string.Format("{0} ({1})", Mod.AllMods[m].Title, Mod.AllMods[m].Version) Mod.AllMods.ContainsKey(m.Key) ? string.Format("{0} ({1})", Mod.AllMods[m.Key].Title, m.Value)
: string.Format("Unknown Mod: {0}",m)).ToArray()); : string.Format("Unknown Mod: {0}",m.Key)).ToArray());
} }
void RefreshServerList(IEnumerable<GameServer> games) void RefreshServerList(IEnumerable<GameServer> games)