Don't crash when joining a game after asset installation.

This commit is contained in:
Matthias Mailänder
2022-04-13 13:18:22 +02:00
committed by Pavel Penev
parent 0f90713aba
commit 648c56bca1
9 changed files with 12 additions and 36 deletions

View File

@@ -36,6 +36,7 @@ namespace OpenRA
public readonly IModelSequenceLoader ModelSequenceLoader;
public readonly IVideoLoader[] VideoLoaders;
public readonly HotkeyManager Hotkeys;
public readonly Translation Translation;
public ILoadScreen LoadScreen { get; private set; }
public CursorProvider CursorProvider { get; private set; }
public FS ModFiles;
@@ -95,7 +96,7 @@ namespace OpenRA
var modelFormat = Manifest.Get<ModelSequenceFormat>();
var modelLoader = ObjectCreator.FindType(modelFormat.Type + "Loader");
var modelCtor = modelLoader != null ? modelLoader.GetConstructor(new[] { typeof(ModData) }) : null;
var modelCtor = modelLoader?.GetConstructor(new[] { typeof(ModData) });
if (modelLoader == null || !modelLoader.GetInterfaces().Contains(typeof(IModelSequenceLoader)) || modelCtor == null)
throw new InvalidOperationException($"Unable to find a model loader for type '{modelFormat.Type}'.");
@@ -104,6 +105,8 @@ namespace OpenRA
Hotkeys = new HotkeyManager(ModFiles, Game.Settings.Keys, Manifest);
Translation = new Translation(Game.Settings.Player.Language, Manifest.Translations, DefaultFileSystem);
defaultRules = Exts.Lazy(() => Ruleset.LoadDefaults(this));
defaultTerrainInfo = Exts.Lazy(() =>
{