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
2 changes: 1 addition & 1 deletion FModel/ViewModels/AssetsFolderViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public AssetsFolderViewModel()

public void BulkPopulate(IReadOnlyCollection<GameFile> entries)
{
if (entries == null || entries.Count == 0)
if (entries == null)
return;

Application.Current.Dispatcher.Invoke(() =>
Expand Down
8 changes: 8 additions & 0 deletions FModel/ViewModels/BackupManagerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows;
using System.Windows.Data;
using CUE4Parse.FileProvider.Objects;
using CUE4Parse.UE4.VirtualFileSystem;
using FModel.Framework;
using FModel.Services;
using FModel.Settings;
Expand All @@ -21,6 +22,7 @@ namespace FModel.ViewModels;
public class BackupManagerViewModel : ViewModel
{
public const uint FBKP_MAGIC = 0x504B4246;
public const string FBKP_NONVFS = "nonvfs";

private ThreadWorkerViewModel _threadWorkerView => ApplicationService.ThreadWorkerView;
private ApiEndpointViewModel _apiEndpointView => ApplicationService.ApiEndpointView;
Expand Down Expand Up @@ -81,6 +83,11 @@ await _threadWorkerView.Begin(_ =>
writer.Write(asset.Size);
writer.Write(asset.IsEncrypted);
writer.Write(asset.Path);

if (asset is VfsEntry vfsAsset)
writer.Write(vfsAsset.Vfs.Name);
else
writer.Write(FBKP_NONVFS);
}

SaveCheck(fullPath, fileName, "created", "create");
Expand Down Expand Up @@ -122,6 +129,7 @@ public enum EBackupVersion : byte
BeforeVersionWasAdded = 0,
Initial,
PerfectPath, // no more leading slash and ToLower
Vfs, // added vfs name

LatestPlusOne,
Latest = LatestPlusOne - 1
Expand Down
24 changes: 18 additions & 6 deletions FModel/ViewModels/Commands/LoadCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,14 @@ private List<GameFile> ParseBackup(string path, ELoadingMode mode, CancellationT
cancellationToken.ThrowIfCancellationRequested();

archive.Position += sizeof(long) + sizeof(byte);
var fullPath = archive.ReadString();
var fullPath = archive.ReadFUtf8String(archive.Read7BitEncodedInt());
if (version < EBackupVersion.PerfectPath) fullPath = fullPath[1..];
if (version >= EBackupVersion.Vfs)
{
//readint advances Position, directly doing += overrides it
var length = archive.Read7BitEncodedInt();
archive.Position += length;
}

paths.Add(fullPath);
}
Expand Down Expand Up @@ -273,10 +279,11 @@ private List<GameFile> ParseBackup(string path, ELoadingMode mode, CancellationT

var uncompressedSize = archive.Read<long>();
var isEncrypted = archive.ReadFlag();
var fullPath = archive.ReadString();
var fullPath = archive.ReadFUtf8String(archive.Read7BitEncodedInt());
if (version < EBackupVersion.PerfectPath) fullPath = fullPath[1..];
var vfsName = version >= EBackupVersion.Vfs ? archive.ReadString() : null;

AddEntry(fullPath, uncompressedSize, isEncrypted, entries);
AddEntry(fullPath, uncompressedSize, isEncrypted, entries, vfsName);
}
}
break;
Expand All @@ -286,10 +293,15 @@ private List<GameFile> ParseBackup(string path, ELoadingMode mode, CancellationT
return entries;
}

private void AddEntry(string path, long uncompressedSize, bool isEncrypted, List<GameFile> entries)
private void AddEntry(string path, long uncompressedSize, bool isEncrypted, List<GameFile> entries, string vfsName = null)
{
if (!_applicationView.CUE4Parse.Provider.Files.TryGetValue(path, out var asset) ||
asset.IsUePackagePayload || asset.Size == uncompressedSize && asset.IsEncrypted == isEncrypted)
if (!_applicationView.CUE4Parse.Provider.Files.TryGetValues(path, out var assets))
return;

GameFile asset = vfsName is null || vfsName == BackupManagerViewModel.FBKP_NONVFS ?
assets[0] : assets.Find(x => (x as VfsEntry).Vfs.Name == vfsName);

if (asset is null || asset.IsUePackagePayload || asset.Size == uncompressedSize && asset.IsEncrypted == isEncrypted)
return;

entries.Add(asset);
Expand Down