mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
GameMetaData.TryGetGameLocation()
Added choice of nullable return or not
This commit is contained in:
parent
86641d01df
commit
5a38f40a66
@ -21,12 +21,12 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
||||
Utils.Log($"Indexing game files");
|
||||
var states = GameRegistry.Games.Values
|
||||
.Where(game => game.GameLocation() != null && game.MainExecutable != null)
|
||||
.SelectMany(game => game.GameLocation().Value.EnumerateFiles()
|
||||
.SelectMany(game => game.GameLocation().EnumerateFiles()
|
||||
.Select(file => new GameFileSourceDownloader.State
|
||||
{
|
||||
Game = game.Game,
|
||||
GameVersion = game.InstalledVersion,
|
||||
GameFile = file.RelativeTo(game.GameLocation().Value),
|
||||
GameFile = file.RelativeTo(game.GameLocation()),
|
||||
}))
|
||||
.ToList();
|
||||
|
||||
@ -40,7 +40,7 @@ namespace Wabbajack.BuildServer.Models.Jobs
|
||||
|
||||
await states.PMap(queue, async state =>
|
||||
{
|
||||
var path = state.Game.MetaData().GameLocation().Value.Combine(state.GameFile);
|
||||
var path = state.Game.MetaData().GameLocation().Combine(state.GameFile);
|
||||
Utils.Log($"Hashing Game file {path}");
|
||||
try
|
||||
{
|
||||
|
@ -99,9 +99,16 @@ namespace Wabbajack.Common
|
||||
|
||||
public string? MainExecutable { get; internal set; }
|
||||
|
||||
public AbsolutePath? GameLocation()
|
||||
public AbsolutePath? TryGetGameLocation()
|
||||
{
|
||||
return Consts.TestMode ? AbsolutePath.GetCurrentDirectory() : StoreHandler.Instance.GetGamePath(Game);
|
||||
return Consts.TestMode ? AbsolutePath.GetCurrentDirectory() : StoreHandler.Instance.TryGetGamePath(Game);
|
||||
}
|
||||
|
||||
public AbsolutePath GameLocation()
|
||||
{
|
||||
var ret = TryGetGameLocation();
|
||||
if (ret == null) throw new ArgumentNullException();
|
||||
return ret.Value;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace Wabbajack.Common.StoreHandlers
|
||||
}
|
||||
}
|
||||
|
||||
public AbsolutePath? GetGamePath(Game game)
|
||||
public AbsolutePath? TryGetGamePath(Game game)
|
||||
{
|
||||
return StoreGames.FirstOrDefault(g => g.Game == game)?.Path;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public static async Task<BethesdaNetData> Login(Game game)
|
||||
{
|
||||
var metadata = game.MetaData();
|
||||
var gamePath = metadata.GameLocation()?.Combine(metadata.MainExecutable);
|
||||
var gamePath = metadata.GameLocation().Combine(metadata.MainExecutable);
|
||||
var info = new ProcessStartInfo
|
||||
{
|
||||
FileName = @"Downloaders\BethesdaNet\bethnetlogin.exe",
|
||||
|
@ -20,10 +20,9 @@ namespace Wabbajack.Lib.Downloaders
|
||||
var game = GameRegistry.GetByFuzzyName(gameName);
|
||||
if (game == null) return null;
|
||||
|
||||
var path = game.GameLocation();
|
||||
var path = game.TryGetGameLocation();
|
||||
var filePath = path?.Combine(gameFile);
|
||||
|
||||
|
||||
if (!filePath?.Exists ?? false)
|
||||
return null;
|
||||
|
||||
@ -52,7 +51,7 @@ namespace Wabbajack.Lib.Downloaders
|
||||
public string GameVersion { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
internal AbsolutePath SourcePath => Game.MetaData().GameLocation().Value.Combine(GameFile);
|
||||
internal AbsolutePath SourcePath => Game.MetaData().GameLocation().Combine(GameFile);
|
||||
|
||||
[JsonIgnore]
|
||||
public override object[] PrimaryKey { get => new object[] {Game, GameVersion, GameFile}; }
|
||||
|
@ -415,7 +415,7 @@ namespace Wabbajack.Test
|
||||
await converted.Download(new Archive { Name = "Update.esm" }, filename.Path);
|
||||
|
||||
Assert.Equal(Hash.FromBase64("/DLG/LjdGXI="), await Utils.FileHashAsync(filename.Path));
|
||||
Assert.Equal(await filename.Path.ReadAllBytesAsync(), await Game.SkyrimSpecialEdition.MetaData().GameLocation()?.Combine("Data/Update.esm").ReadAllBytesAsync());
|
||||
Assert.Equal(await filename.Path.ReadAllBytesAsync(), await Game.SkyrimSpecialEdition.MetaData().GameLocation().Combine("Data/Update.esm").ReadAllBytesAsync());
|
||||
Consts.TestMode = true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user