diff --git a/OpenRa.FileFormats/Map.cs b/OpenRa.FileFormats/Map.cs index c888d97df8..0827a6a71c 100644 --- a/OpenRa.FileFormats/Map.cs +++ b/OpenRa.FileFormats/Map.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text; +using IjwFramework.Types; namespace OpenRa.FileFormats { @@ -21,6 +23,8 @@ namespace OpenRa.FileFormats public readonly TileReference[ , ] MapTiles = new TileReference[ 128, 128 ]; public readonly List Trees = new List(); + public readonly IEnumerable SpawnPoints; + static string Truncate( string s, int maxLength ) { return s.Length <= maxLength ? s : s.Substring(0,maxLength ); @@ -49,6 +53,12 @@ namespace OpenRa.FileFormats UnpackTileData(ReadPackedSection(file.GetSection("MapPack"))); UnpackOverlayData(ReadPackedSection(file.GetSection("OverlayPack"))); ReadTrees(file); + + SpawnPoints = file.GetSection("Waypoints") + .Select(kv => Pair.New(int.Parse(kv.Key), new int2(int.Parse(kv.Value) % 128, int.Parse(kv.Value) / 128))) + .Where(a => a.First < 8) + .Select(a => a.Second) + .ToArray(); } static MemoryStream ReadPackedSection(IniSection mapPackSection) diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index d5191f3ac8..225e8ded86 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -47,7 +47,6 @@ namespace OpenRa static HardwarePalette palette; static string mapName; internal static Session LobbyInfo = new Session(); - internal static int2[] SpawnPoints; static bool changePending; public static void ChangeMap(string mapName) @@ -87,12 +86,6 @@ namespace OpenRa skipMakeAnims = false; chrome = new Chrome(renderer); - - SpawnPoints = Rules.AllRules.GetSection("Waypoints") - .Select(kv => Pair.New(int.Parse(kv.Key), new int2(int.Parse(kv.Value) % 128, int.Parse(kv.Value) / 128))) - .Where(a => a.First < 8) - .Select(a => a.Second) - .ToArray(); } internal static void Initialize(string mapName, Renderer renderer, int2 clientSize, @@ -251,7 +244,7 @@ namespace OpenRa public static void StartGame() { - var available = SpawnPoints.ToList(); + var available = world.Map.SpawnPoints.ToList(); var taken = new List(); foreach (var client in LobbyInfo.Clients)