DA2/DAI support

This commit is contained in:
Timothy Baldridge 2021-01-08 06:42:58 -07:00
parent eb63b1fefc
commit 1ed06fb79d
3 changed files with 78 additions and 13 deletions

View File

@ -3,7 +3,7 @@
#### Version - 2.4.0.0 - ???
* Wabbajack is now based on .NET 5.0 (does not require a runtime download by users)
* Origin is now supported as a game source
* Basic (mostly untested) support for Dragon Age : Origins
* Basic (mostly untested) support for Dragon Age : Origins, Dragon Age 2, and Dragon Age: Inquisition
* Replace RocksDB with SQLite should result in less process contention when running the UI and the CLI at the same time
* Fixed Regression with CloudFront IPS4 sites not requesting logins before installation
* Fixed regression that caused us to spam the Nexus with verify calls

View File

@ -42,7 +42,9 @@ namespace Wabbajack.Common
KingdomComeDeliverance,
MechWarrior5Mercenaries,
NoMansSky,
DragonAgeOrigins
DragonAgeOrigins,
DragonAge2,
DragonAgeInquisition
}
public static class GameExtensions
@ -579,6 +581,38 @@ namespace Wabbajack.Common
},
MainExecutable = @"bin_ship\daorigins.exe"
}
},
{
Game.DragonAge2, new GameMetaData
{
Game = Game.DragonAge2,
NexusName = "dragonage2",
NexusGameId = 141,
MO2Name = "Dragon Age 2", // Probably wrong
SteamIDs = new List<int>{1238040},
OriginIDs = new List<string>{"OFB-EAST:59474"},
RequiredFiles = new List<string>
{
@"bin_ship\DragonAge2.exe"
},
MainExecutable = @"bin_ship\DragonAge2.exe"
}
},
{
Game.DragonAgeInquisition, new GameMetaData
{
Game = Game.DragonAgeInquisition,
NexusName = "dragonageinquisition",
NexusGameId = 728,
MO2Name = "Dragon Age: Inquisition", // Probably wrong
SteamIDs = new List<int>{1222690},
OriginIDs = new List<string>{"OFB-EAST:51937"},
RequiredFiles = new List<string>
{
@"DragonAgeInquisition.exe"
},
MainExecutable = @"DragonAgeInquisition.exe"
}
}
};

View File

@ -14,6 +14,8 @@ namespace Wabbajack.Common.StoreHandlers
private HashSet<string> KnownMFSTs = new();
public override StoreType Type { get; internal set; } = StoreType.Origin;
private static Regex SplitRegex = new Regex("[0-9]+");
public override bool Init()
{
try
@ -24,8 +26,35 @@ namespace Wabbajack.Common.StoreHandlers
KnownMFSTs = OriginDataPath.EnumerateFiles()
.Where(f => f.Extension == MFSTExtension)
.Select(f => f.FileNameWithoutExtension.ToString())
.Select(f =>
{
var result = SplitRegex.Match(f);
if (result == null) return default;
var a = f.Substring(0, result.Index);
var b = f.Substring(result.Index);
return a + ":" + b;
})
.Where(t => t != default)
.Select(t => t!)
.Where(t => !t.Contains("."))
.ToHashSet();
foreach (var known in KnownMFSTs)
{
try
{
var resp = OriginGame.GetAndCacheManifestResponse(known)
.FromJsonString<OriginGame.GameLocalDataResponse>();
Utils.Log($"Found Origin Content {resp.localizableAttributes!.displayName} ({known})");
}
catch (Exception ex)
{
Utils.Log($"Origin got {ex.Message} when loading info for {known}");
continue;
}
}
Utils.Log($"Found MFSTs from Origin: {string.Join(", ", KnownMFSTs)}");
return true;
@ -41,6 +70,8 @@ namespace Wabbajack.Common.StoreHandlers
{
try
{
foreach (var game in GameRegistry.Games)
{
var mfst = game.Value.OriginIDs.FirstOrDefault(g => KnownMFSTs.Contains(g.Replace(":", "")));
@ -48,7 +79,6 @@ namespace Wabbajack.Common.StoreHandlers
continue;
var ogame = new OriginGame(mfst, game.Key, game.Value);
ogame.GetAndCacheManifestResponse();
Games.Add(ogame);
}
@ -91,7 +121,7 @@ namespace Wabbajack.Common.StoreHandlers
private AbsolutePath GetGamePath()
{
var manifestData = GetAndCacheManifestResponse().FromJsonString<GameLocalDataResponse>();
var manifestData = GetAndCacheManifestResponse(this._mfst).FromJsonString<GameLocalDataResponse>();
var platform = manifestData!.publishing!.softwareList!.software!.FirstOrDefault(a => a.softwarePlatform == "PCWIN");
var installPath = GetPathFromPlatformPath(platform!.fulfillmentAttributes!.installCheckOverride!);
@ -151,21 +181,22 @@ namespace Wabbajack.Common.StoreHandlers
return resultPath;
}
private AbsolutePath ManifestCacheLocation =>
Consts.LocalAppDataPath.Combine("OriginManifestCache", _mfst.Replace(":", ""));
private static AbsolutePath ManifestCacheLocation(string mfst) =>
Consts.LocalAppDataPath.Combine("OriginManifestCache", mfst.Replace(":", ""));
internal string GetAndCacheManifestResponse()
internal static string GetAndCacheManifestResponse(string mfst)
{
if (ManifestCacheLocation.Exists)
var location = ManifestCacheLocation(mfst);
if (location.Exists)
{
return ManifestCacheLocation.ReadAllText();
return location.ReadAllText();
}
Utils.Log($"Getting Origin Manifest info for {_mfst}");
Utils.Log($"Getting Origin Manifest info for {mfst}");
var client = new HttpClient();
var data = client.GetStringAsync($"https://api1.origin.com/ecommerce2/public/{_mfst}/en_US").Result;
ManifestCacheLocation.Parent.CreateDirectory();
ManifestCacheLocation.WriteAllTextAsync(data).Wait();
var data = client.GetStringAsync($"https://api1.origin.com/ecommerce2/public/{mfst}/en_US").Result;
location.Parent.CreateDirectory();
location.WriteAllTextAsync(data).Wait();
return data;
}