Update PAP records.

This commit is contained in:
Ottermandias 2025-03-29 18:03:50 +01:00
parent cb0214ca2f
commit 2dd6dd201c
2 changed files with 30 additions and 2 deletions

View file

@ -56,6 +56,26 @@ internal unsafe struct Record
Crc64 = 0,
};
public static Record CreateRequest(CiByteString path, bool sync, FullPath fullPath, ResolveData resolve)
=> new()
{
Time = DateTime.UtcNow,
Path = fullPath.InternalName.IsOwned ? fullPath.InternalName : fullPath.InternalName.Clone(),
OriginalPath = path.IsOwned ? path : path.Clone(),
Collection = resolve.Valid ? resolve.ModCollection : null,
Handle = null,
ResourceType = ResourceExtensions.Type(path).ToFlag(),
Category = ResourceExtensions.Category(path).ToFlag(),
RefCount = 0,
RecordType = RecordType.Request,
Synchronously = sync,
ReturnValue = OptionalBool.Null,
CustomLoad = fullPath.InternalName != path,
AssociatedGameObject = string.Empty,
LoadState = LoadState.None,
Crc64 = fullPath.Crc64,
};
public static Record CreateDefaultLoad(CiByteString path, ResourceHandle* handle, ModCollection collection, string associatedGameObject)
{
path = path.IsOwned ? path : path.Clone();

View file

@ -58,12 +58,19 @@ public sealed class ResourceWatcher : IDisposable, ITab, IUiService
private void OnPapRequested(Utf8GamePath original, FullPath? _1, ResolveData _2)
{
if (_ephemeral.EnableResourceLogging && FilterMatch(original.Path, out var match))
{
Penumbra.Log.Information($"[ResourceLoader] [REQ] {match} was requested asynchronously.");
if (_1.HasValue)
Penumbra.Log.Information(
$"[ResourceLoader] [LOAD] Resolved {_1.Value.FullName} for {match} from collection {_2.ModCollection} for object 0x{_2.AssociatedGameObject:X}.");
}
if (!_ephemeral.EnableResourceWatcher)
return;
var record = Record.CreateRequest(original.Path, false);
var record = _1.HasValue
? Record.CreateRequest(original.Path, false, _1.Value, _2)
: Record.CreateRequest(original.Path, false);
if (!_ephemeral.OnlyAddMatchingResources || _table.WouldBeVisible(record))
_newRecords.Enqueue(record);
}
@ -257,7 +264,8 @@ public sealed class ResourceWatcher : IDisposable, ITab, IUiService
_newRecords.Enqueue(record);
}
private unsafe void OnResourceComplete(ResourceHandle* resource, CiByteString path, Utf8GamePath original, ReadOnlySpan<byte> additionalData, bool isAsync)
private unsafe void OnResourceComplete(ResourceHandle* resource, CiByteString path, Utf8GamePath original,
ReadOnlySpan<byte> additionalData, bool isAsync)
{
if (!isAsync)
return;