Fix Extra Room catalog unlock handling

This commit is contained in:
gamer147
2026-07-28 13:14:28 -04:00
parent 93d9f58758
commit f4bf78d7d1
11 changed files with 539 additions and 56 deletions

View File

@@ -7,6 +7,36 @@ public interface IAssetStore
byte[] ReadAll(AssetEntry entry);
}
/// <summary>Reports only successful catalog opens, matching AGE's profile unlock marker timing.</summary>
public sealed class CatalogTrackingAssetStore : IAssetStore
{
private readonly IAssetStore _inner;
private readonly Action<AssetEntry> _opened;
public CatalogTrackingAssetStore(IAssetStore inner, Action<AssetEntry> opened)
{
_inner = inner ?? throw new ArgumentNullException(nameof(inner));
_opened = opened ?? throw new ArgumentNullException(nameof(opened));
}
public Stream Open(AssetEntry entry)
{
Stream stream = _inner.Open(entry);
_opened(entry);
return stream;
}
public byte[] ReadAll(AssetEntry entry)
{
using Stream stream = Open(entry);
if (stream.Length > int.MaxValue)
throw new InvalidDataException($"{entry.Name}: payload is too large");
var bytes = new byte[checked((int)stream.Length)];
stream.ReadExactly(bytes);
return bytes;
}
}
/// <summary>Native base-game precedence: exact-basename loose roots first, indexed ALF range second.</summary>
public sealed class Sys4AssetStore : IAssetStore
{