Allow maps to be loaded directly, bypassing the MapCache.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
e186dc428e
commit
fceb8a479d
@@ -181,7 +181,16 @@ namespace OpenRA
|
||||
|
||||
public static event Action BeforeGameStart = () => { };
|
||||
public static event Action AfterGameStart = () => { };
|
||||
internal static void StartGame(string mapUID, WorldType type)
|
||||
internal static void StartGame(string uid, WorldType type)
|
||||
{
|
||||
var preview = ModData.MapCache[uid];
|
||||
if (preview.Status != MapStatus.Available)
|
||||
throw new InvalidDataException($"Invalid map uid: {uid}");
|
||||
|
||||
StartGame(preview.ToMap(), type);
|
||||
}
|
||||
|
||||
internal static void StartGame(Map map, WorldType type)
|
||||
{
|
||||
// Dispose of the old world before creating a new one.
|
||||
worldRenderer?.Dispose();
|
||||
@@ -190,7 +199,10 @@ namespace OpenRA
|
||||
BeforeGameStart();
|
||||
|
||||
using (new PerfTimer("NewWorld"))
|
||||
OrderManager.World = new World(mapUID, ModData, OrderManager, type);
|
||||
{
|
||||
ModData.PrepareMap(map);
|
||||
OrderManager.World = new World(map, ModData, OrderManager, type);
|
||||
}
|
||||
|
||||
OrderManager.World.GameOver += FinishBenchmark;
|
||||
|
||||
@@ -507,10 +519,16 @@ namespace OpenRA
|
||||
ModData.LoadScreen.StartGame(args);
|
||||
}
|
||||
|
||||
public static void LoadEditor(string mapUid)
|
||||
public static void LoadEditor(string uid)
|
||||
{
|
||||
JoinLocal();
|
||||
StartGame(mapUid, WorldType.Editor);
|
||||
StartGame(uid, WorldType.Editor);
|
||||
}
|
||||
|
||||
public static void LoadEditor(Map map)
|
||||
{
|
||||
JoinLocal();
|
||||
StartGame(map, WorldType.Editor);
|
||||
}
|
||||
|
||||
public static void LoadShellMap()
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Graphics;
|
||||
@@ -141,15 +140,11 @@ namespace OpenRA
|
||||
|
||||
public IEnumerable<string> Languages { get; }
|
||||
|
||||
public Map PrepareMap(string uid)
|
||||
public void PrepareMap(Map map)
|
||||
{
|
||||
LoadScreen?.Display();
|
||||
|
||||
if (MapCache[uid].Status != MapStatus.Available)
|
||||
throw new InvalidDataException($"Invalid map uid: {uid}");
|
||||
|
||||
// Reinitialize all our assets
|
||||
var map = MapCache[uid].ToMap();
|
||||
InitializeLoaders(map);
|
||||
map.Sequences.LoadSprites();
|
||||
|
||||
@@ -157,8 +152,6 @@ namespace OpenRA
|
||||
using (new Support.PerfTimer("Map.Music"))
|
||||
foreach (var entry in map.Rules.Music)
|
||||
entry.Value.Load(map);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
public List<MiniYamlNode>[] GetRulesYaml()
|
||||
|
||||
@@ -188,13 +188,12 @@ namespace OpenRA
|
||||
|
||||
bool wasLoadingGameSave;
|
||||
|
||||
internal World(string mapUID, ModData modData, OrderManager orderManager, WorldType type)
|
||||
internal World(Map map, ModData modData, OrderManager orderManager, WorldType type)
|
||||
{
|
||||
this.modData = modData;
|
||||
Type = type;
|
||||
OrderManager = orderManager;
|
||||
using (new PerfTimer("PrepareMap"))
|
||||
Map = modData.PrepareMap(mapUID);
|
||||
Map = map;
|
||||
|
||||
if (string.IsNullOrEmpty(modData.Manifest.DefaultOrderGenerator))
|
||||
throw new InvalidDataException("mod.yaml must define a DefaultOrderGenerator");
|
||||
|
||||
Reference in New Issue
Block a user