diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 0fd72c93de..a239dae2f1 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -153,14 +153,20 @@ namespace OpenRA var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods); Timer.Time( "manifest: {0}" ); + if (!Game.AvailableMaps.ContainsKey(mapName)) + throw new InvalidDataException("Cannot find map with Uid {0}".F(mapName)); + + var map = new Map( Game.AvailableMaps[mapName].Package ); + + viewport = new Viewport(clientSize, map.TopLeft, map.BottomRight, renderer); world = null; // trying to access the old world will NRE, rather than silently doing it wrong. ChromeProvider.Initialize(manifest.Chrome); - world = new World(manifest,mapName); + Timer.Time( "viewport, ChromeProvider: {0}" ); + world = new World(manifest,map); Timer.Time( "world: {0}" ); SequenceProvider.Initialize(manifest.Sequences); - viewport = new Viewport(clientSize, Game.world.Map.TopLeft, Game.world.Map.BottomRight, renderer); - Timer.Time( "ChromeProv, SeqProv, viewport: {0}" ); + Timer.Time( "ChromeProv, SeqProv: {0}" ); chrome = new Chrome(renderer, manifest); Timer.Time( "chrome: {0}" ); diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index cd593b54c9..f48bd91521 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -75,16 +75,11 @@ namespace OpenRA public readonly WorldRenderer WorldRenderer; internal readonly Minimap Minimap; - public World(Manifest manifest, string mapUid) + public World(Manifest manifest, Map map) { Timer.Time( "----World.ctor" ); - - if (!Game.AvailableMaps.ContainsKey(mapUid)) - throw new InvalidDataException("Cannot find map with Uid {0}".F(mapUid)); - - Map = new Map( Game.AvailableMaps[mapUid].Package ); + Map = map; - customTerrain = new ICustomTerrain[Map.MapSize.X, Map.MapSize.Y]; Timer.Time( "new Map: {0}" ); diff --git a/OpenRA.Mods.RA/DefaultShellmapScript.cs b/OpenRA.Mods.RA/DefaultShellmapScript.cs index 8a28cad365..040144efe8 100644 --- a/OpenRA.Mods.RA/DefaultShellmapScript.cs +++ b/OpenRA.Mods.RA/DefaultShellmapScript.cs @@ -29,16 +29,19 @@ namespace OpenRA.Mods.RA public object Create(Actor self) { return new DefaultShellmapScript(); } } - class DefaultShellmapScript : ITick + class DefaultShellmapScript : ITick, ILoadWorldHook { + public void WorldLoaded(World w) + { + // Set the viewport location + Game.MoveViewport(new int2(85,65)); + } + // Rude hack around the multiple-creation bug: // wait long enough for the transient copies to die before starting int initialDelay = 20; public void Tick(Actor self) { - // Another rude hack - Game.MoveViewport(new int2(85,65)); - if (initialDelay > 0 && --initialDelay == 0) Sound.PlayMusic("hell226m.aud"); }