Move mod asset validation from BlankLoadScreen.StartGame() to Game.InitializeMod()
This fixes a crash that happens when you try to launch a mod directly while its assets aren't installed. Additionally should reduce the overhead for dedicated servers (in theory).
This commit is contained in:
@@ -281,14 +281,30 @@ namespace OpenRA
|
|||||||
Sound.Initialize();
|
Sound.Initialize();
|
||||||
|
|
||||||
ModData = new ModData(mod, !Settings.Server.Dedicated);
|
ModData = new ModData(mod, !Settings.Server.Dedicated);
|
||||||
ModData.MountFiles();
|
|
||||||
ModData.InitializeLoaders();
|
|
||||||
if (!Settings.Server.Dedicated)
|
|
||||||
Renderer.InitializeFonts(ModData.Manifest);
|
|
||||||
|
|
||||||
using (new PerfTimer("LoadMaps"))
|
using (new PerfTimer("LoadMaps"))
|
||||||
ModData.MapCache.LoadMaps();
|
ModData.MapCache.LoadMaps();
|
||||||
|
|
||||||
|
if (Settings.Server.Dedicated)
|
||||||
|
{
|
||||||
|
RunDedicatedServer();
|
||||||
|
Environment.Exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
var installData = ModData.Manifest.Get<ContentInstaller>();
|
||||||
|
var isModContentInstalled = installData.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)));
|
||||||
|
|
||||||
|
// Mod assets are missing!
|
||||||
|
if (!isModContentInstalled)
|
||||||
|
{
|
||||||
|
InitializeMod("modchooser", new Arguments());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ModData.MountFiles();
|
||||||
|
ModData.InitializeLoaders();
|
||||||
|
Renderer.InitializeFonts(ModData.Manifest);
|
||||||
|
|
||||||
if (Cursor != null)
|
if (Cursor != null)
|
||||||
Cursor.Dispose();
|
Cursor.Dispose();
|
||||||
|
|
||||||
@@ -320,39 +336,38 @@ namespace OpenRA
|
|||||||
|
|
||||||
JoinLocal();
|
JoinLocal();
|
||||||
|
|
||||||
if (Settings.Server.Dedicated)
|
ModData.LoadScreen.StartGame(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RunDedicatedServer()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
|
Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
|
||||||
|
Settings.Save();
|
||||||
|
CreateServer(new ServerSettings(Settings.Server));
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
Settings.Server.Map = WidgetUtils.ChooseInitialMap(Settings.Server.Map);
|
Thread.Sleep(100);
|
||||||
Settings.Save();
|
|
||||||
CreateServer(new ServerSettings(Settings.Server));
|
if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
|
||||||
while (true)
|
|
||||||
{
|
{
|
||||||
Thread.Sleep(100);
|
Console.WriteLine("No one is playing, shutting down...");
|
||||||
|
server.Shutdown();
|
||||||
if (server.State == Server.ServerState.GameStarted && server.Conns.Count < 1)
|
break;
|
||||||
{
|
|
||||||
Console.WriteLine("No one is playing, shutting down...");
|
|
||||||
server.Shutdown();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings.Server.DedicatedLoop)
|
|
||||||
{
|
|
||||||
Console.WriteLine("Starting a new server instance...");
|
|
||||||
ModData.MapCache.LoadMaps();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Environment.Exit(0);
|
if (Settings.Server.DedicatedLoop)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Starting a new server instance...");
|
||||||
|
ModData.MapCache.LoadMaps();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
ModData.LoadScreen.StartGame(args);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void LoadEditor(string mapUid)
|
public static void LoadEditor(string mapUid)
|
||||||
|
|||||||
@@ -41,16 +41,6 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
Ui.ResetAll();
|
Ui.ResetAll();
|
||||||
Game.Settings.Save();
|
Game.Settings.Save();
|
||||||
|
|
||||||
var installData = Game.ModData.Manifest.Get<ContentInstaller>();
|
|
||||||
var isModContentInstalled = installData.TestFiles.All(f => GlobalFileSystem.Exists(Path.GetFileName(f)));
|
|
||||||
|
|
||||||
// Mod assets are missing!
|
|
||||||
if (!isModContentInstalled)
|
|
||||||
{
|
|
||||||
Game.InitializeMod("modchooser", new Arguments());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Join a server directly
|
// Join a server directly
|
||||||
var connect = Launch.GetConnectAddress();
|
var connect = Launch.GetConnectAddress();
|
||||||
if (!string.IsNullOrEmpty(connect))
|
if (!string.IsNullOrEmpty(connect))
|
||||||
|
|||||||
Reference in New Issue
Block a user