Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion BanjoBotAssets/AssetExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using Microsoft.Extensions.Options;
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace BanjoBotAssets
{
Expand Down Expand Up @@ -198,7 +199,7 @@ private async Task LoadMappingsAsync(CancellationToken cancellationToken)
{
logger.LogInformation(Resources.Status_LoadingMappings);

if (provider.InternalGameName.Equals("FortniteGame", StringComparison.OrdinalIgnoreCase))
if (provider.ProjectName.Equals("FortniteGame", StringComparison.OrdinalIgnoreCase))
{
provider.MappingsContainer = typeMappingsProviderFactory.Create();
}
Expand Down Expand Up @@ -351,6 +352,9 @@ private void OfferFileListToExporters()

private void LoadLocalization(CancellationToken cancellationToken)
{
//intended to be used to validate encryption keys, but now also prepares localisation dictionary (???)
provider.PostMount();

logger.LogInformation(Resources.Status_LoadingLocalization, languageProvider.Language.ToString());
provider.LoadLocalization(languageProvider.Language, cancellationToken);
}
Expand Down
12 changes: 6 additions & 6 deletions BanjoBotAssets/CachingFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,26 +98,26 @@ private void WriteToAssetLog(string line)
}
}

public override Task<IPackage> LoadPackageAsync(GameFile file)
public override IPackage LoadPackage(GameFile file)
{
Interlocked.Increment(ref cacheRequests);

return cache.Cache.GetOrAddAsync(
return cache.Cache.GetOrAdd(
file.Path,
async _ =>
_ =>
{
Interlocked.Increment(ref cacheMisses);

cacheMissesByPath.AddOrUpdate(file.Path, 1, (_, i) => i + 1);
logger.LogDebug(Resources.Status_CacheMiss, file.Path, file.Size);

WriteToAssetLog(file.Path);
return await base.LoadPackageAsync(file);
return base.LoadPackage(file);
},
new MemoryCacheEntryOptions { Size = file.Size });
}

public override Task<IPackage?> TryLoadPackageAsync(GameFile file)
public override Task<IPackage> LoadPackageAsync(GameFile file)
{
Interlocked.Increment(ref cacheRequests);

Expand All @@ -131,7 +131,7 @@ public override Task<IPackage> LoadPackageAsync(GameFile file)
logger.LogDebug(Resources.Status_CacheMiss, file.Path, file.Size);

WriteToAssetLog(file.Path);
return await base.TryLoadPackageAsync(file);
return await base.LoadPackageAsync(file);
},
new MemoryCacheEntryOptions { Size = file.Size });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public static IServiceCollection AddGameFileProvider(this IServiceCollection ser
directory: gameDirectory,
searchOption: SearchOption.TopDirectoryOnly,
isCaseInsensitive: true,
versions: new VersionContainer(EGame.GAME_UE5_4),
versions: new VersionContainer(EGame.GAME_UE5_6),
assetLogPath: perfOptions.Value.AssetLogPath);

provider.Initialize();
Expand Down
2 changes: 1 addition & 1 deletion BanjoBotAssets/Exporters/BaseExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void CountAssetLoaded()

var file = provider[path];
CountAssetLoaded();
return await provider.LoadObjectAsync<UDataTable>(file.PathWithoutExtension);
return await provider.SafeLoadPackageObjectAsync<UDataTable>(file.PathWithoutExtension);
}

public abstract Task ExportAssetsAsync(IProgress<ExportProgress> progress, IAssetOutput output, CancellationToken cancellationToken);
Expand Down
2 changes: 1 addition & 1 deletion BanjoBotAssets/Exporters/DifficultyExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public override async Task ExportAssetsAsync(IProgress<ExportProgress> progress,
var file = provider[growthBoundsPath];

Interlocked.Increment(ref assetsLoaded);
var dataTable = await provider.LoadObjectAsync<UDataTable>(file.PathWithoutExtension);
var dataTable = await provider.SafeLoadPackageObjectAsync<UDataTable>(file.PathWithoutExtension);

if (dataTable == null)
{
Expand Down
2 changes: 1 addition & 1 deletion BanjoBotAssets/Exporters/ExpeditionCriteriaExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override async Task ExportAssetsAsync(IProgress<ExportProgress> progress,
var file = provider[criteriaPath];

Interlocked.Increment(ref assetsLoaded);
var dataTable = await provider.LoadObjectAsync<UDataTable>(file.PathWithoutExtension);
var dataTable = await provider.SafeLoadPackageObjectAsync<UDataTable>(file.PathWithoutExtension);

if (dataTable == null)
{
Expand Down
2 changes: 1 addition & 1 deletion BanjoBotAssets/Exporters/Groups/GroupExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ await Parallel.ForEachAsync(assetsToProcess, opts, async (grouping, _) =>

Report(progress, file.PathWithoutExtension);

var asset = await provider.LoadObjectAsync<TAsset>(file.PathWithoutExtension);
var asset = await provider.SafeLoadPackageObjectAsync<TAsset>(file.PathWithoutExtension);

if (asset == null)
{
Expand Down
7 changes: 5 additions & 2 deletions BanjoBotAssets/Exporters/Groups/HeroExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public override async Task ExportAssetsAsync(IProgress<ExportProgress> progress,
{
if (itemToQuestPath != null && questRewardsPath != null)
{
var itemToQuestTask = provider.LoadObjectAsync<UDataTable>(provider.Files[itemToQuestPath].PathWithoutExtension);
var questRewardsTask = provider.LoadObjectAsync<UDataTable>(provider.Files[questRewardsPath].PathWithoutExtension);
var itemToQuestTask = provider.SafeLoadPackageObjectAsync<UDataTable>(provider.Files[itemToQuestPath].PathWithoutExtension);
var questRewardsTask = provider.SafeLoadPackageObjectAsync<UDataTable>(provider.Files[questRewardsPath].PathWithoutExtension);

var itemToQuestTable = await itemToQuestTask;
var questRewardsTable = await questRewardsTask;
Expand All @@ -179,6 +179,9 @@ public override async Task ExportAssetsAsync(IProgress<ExportProgress> progress,

private void InitHeroToTeamPerkMapping(UDataTable itemToQuestTable, UDataTable questRewardsTable)
{
if (questRewardsTable is null)
return;

var questToTeamPerk = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

foreach (var entry in questRewardsTable.RowMap.Values)
Expand Down
4 changes: 2 additions & 2 deletions BanjoBotAssets/Exporters/Groups/SchematicExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public override async Task ExportAssetsAsync(IProgress<ExportProgress> progress,
}
var widOrTidFile = provider[widOrTidPath];
Interlocked.Increment(ref assetsLoaded);
return await provider.LoadObjectAsync<UFortItemDefinition>(widOrTidFile.PathWithoutExtension);
return await provider.SafeLoadPackageObjectAsync<UFortItemDefinition>(widOrTidFile.PathWithoutExtension);
}

protected override async Task<SchematicItemGroupFields> ExtractCommonFieldsAsync(UObject asset, IGrouping<string?, string> grouping)
Expand Down Expand Up @@ -347,7 +347,7 @@ private static (string category, string subType) CategoryAndSubTypeFromTags(FGam

return await cachedAmmoTypesFromPaths.GetOrAdd(ammoDataPath.AssetPathName.Text, static async (path, provider) =>
{
var asset = await provider.LoadObjectAsync<UFortAmmoItemDefinition>(path);
var asset = await provider.SafeLoadPackageObjectAsync<UFortAmmoItemDefinition>(path);
if (asset.ItemName?.Text is string str)
{
var i = str.IndexOf(':');
Expand Down
4 changes: 2 additions & 2 deletions BanjoBotAssets/Exporters/ItemRatingExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private async Task ExportDefaultItemRatingsAsync(IAssetOutput output)
var file = provider[baseItemRatingPath];

Interlocked.Increment(ref assetsLoaded);
var curveTable = await provider.LoadObjectAsync<UCurveTable>(file.PathWithoutExtension);
var curveTable = await provider.SafeLoadPackageObjectAsync<UCurveTable>(file.PathWithoutExtension);

if (curveTable == null)
{
Expand All @@ -71,7 +71,7 @@ private async Task ExportSurvivorItemRatingsAsync(IAssetOutput output)
var file = provider[survivorItemRatingPath];

Interlocked.Increment(ref assetsLoaded);
var curveTable = await provider.LoadObjectAsync<UCurveTable>(file.PathWithoutExtension);
var curveTable = await provider.SafeLoadPackageObjectAsync<UCurveTable>(file.PathWithoutExtension);

if (curveTable == null)
{
Expand Down
2 changes: 1 addition & 1 deletion BanjoBotAssets/Exporters/QuestMapExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public override async Task ExportAssetsAsync(IProgress<ExportProgress> progress,

var file = provider[assetPaths[0]];
Interlocked.Increment(ref assetsLoaded);
var mapData = await provider.LoadObjectAsync(file.PathWithoutExtension);
var mapData = await provider.SafeLoadPackageObjectAsync(file.PathWithoutExtension);

cancellationToken.ThrowIfCancellationRequested();

Expand Down
1 change: 1 addition & 0 deletions BanjoBotAssets/Exporters/UObjects/AbilityExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using BanjoBotAssets.UExports;
using CUE4Parse.FN.Structs.GA;
using CUE4Parse.UE4.Objects.Engine;
using CUE4Parse.Utilities;
using System.Data;

namespace BanjoBotAssets.Exporters.UObjects
Expand Down
12 changes: 11 additions & 1 deletion BanjoBotAssets/Exporters/UObjects/UObjectExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
using CUE4Parse.FN.Enums.FortniteGame;
using System.Collections.Concurrent;
using CUE4Parse.Utilities;

namespace BanjoBotAssets.Exporters.UObjects
{
Expand Down Expand Up @@ -85,7 +86,16 @@ await Parallel.ForEachAsync(assetsToProcess, opts, async (path, _) =>
TAsset? uobject;
if (IgnoreLoadFailures)
{
var pkg = await provider.TryLoadPackageAsync(file);
IPackage? pkg = null;

try
{
pkg = await provider.LoadPackageAsync(file);
}
catch
{
return;
}

cancellationToken.ThrowIfCancellationRequested();

Expand Down
6 changes: 3 additions & 3 deletions BanjoBotAssets/Exporters/VenturesSeasonExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public override async Task ExportAssetsAsync(IProgress<ExportProgress> progress,
return;
}

var levelRewardsTask = provider.LoadObjectAsync<UDataTable>(provider[levelRewardsPath].PathWithoutExtension);
var pastLevelRewardsTask = provider.LoadObjectAsync<UDataTable>(provider[pastLevelRewardsPath].PathWithoutExtension);
var defaultGameDataTask = provider.LoadObjectAsync<UObject>(provider[defaultGameDataPath].PathWithoutExtension);
var levelRewardsTask = provider.SafeLoadPackageObjectAsync<UDataTable>(provider[levelRewardsPath].PathWithoutExtension);
var pastLevelRewardsTask = provider.SafeLoadPackageObjectAsync<UDataTable>(provider[pastLevelRewardsPath].PathWithoutExtension);
var defaultGameDataTask = provider.SafeLoadPackageObjectAsync<UObject>(provider[defaultGameDataPath].PathWithoutExtension);

ExportLevelRewards(await levelRewardsTask, output, cancellationToken);
ExportPastLevelRewards(await pastLevelRewardsTask, output, cancellationToken);
Expand Down
13 changes: 9 additions & 4 deletions BanjoBotAssets/PostExporters/ImageFilesPostExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using BanjoBotAssets.Config;
using CUE4Parse.UE4.Assets.Exports.Texture;
using CUE4Parse_Conversion.Textures;
using CUE4Parse_Conversion.Textures.BC;
using Microsoft.Extensions.Options;

namespace BanjoBotAssets.PostExporters
Expand All @@ -44,6 +45,8 @@ public async Task ProcessExportsAsync(ExportedAssets exportedAssets, IList<Expor

Directory.CreateDirectory(options.Value.OutputDirectory);

DetexHelper.Initialize("../external/CUE4Parse/CUE4Parse-Conversion/Resources/Detex.dll");

foreach (var (imageType, wantExport) in options.Value.Type)
{
if (wantExport == WantImageExport.Yes)
Expand All @@ -70,19 +73,21 @@ public async Task ProcessExportsAsync(ExportedAssets exportedAssets, IList<Expor
continue;
}

var asset = await provider.LoadObjectAsync<UTexture2D>(imagePath);
using var bitmap = asset.Decode();
var asset = await provider.SafeLoadPackageObjectAsync<UTexture2D>(imagePath);
var bitmap = asset?.Decode();
if (bitmap == null)
{
logger.LogError(Resources.Error_CannotDecodeTexture, imagePath);
continue;
}

await using var stream = new FileStream(exportedPath, FileMode.Create, FileAccess.Write);
if (!bitmap.Encode(stream, SkiaSharp.SKEncodedImageFormat.Png, 100))
var bytes = bitmap.Encode(ETextureFormat.Png, out var ext);
if (ext != "png")
{
logger.LogError(Resources.Error_CannotEncodeTexture, imagePath);
}
await using var stream = new FileStream(exportedPath, FileMode.Create, FileAccess.Write);
stream.Write(bytes, 0, bytes.Length);
filesWritten++;
}
}
Expand Down
2 changes: 1 addition & 1 deletion external/CUE4Parse
Submodule CUE4Parse updated 455 files
Loading