Five small post-cleanup items from T7 code review:
I1: Removed dead `datDir` parameter from WbMeshAdapter ctor (parameter
was unused after _wbDats removal; ArgumentNullException.ThrowIfNull
was misleading). Updated call sites in GameWindow.cs and
WbMeshAdapterTests.cs.
I2: Updated stale GameWindow.cs comment that still described
WbMeshAdapter as opening its own dat handles. Now reflects Phase O
state: shared DatCollection via DatCollectionAdapter.
I3: Documented thread-safety contract on RenderStateCache (render-thread
only — required for the mutable-static GL sentinel pattern).
M1: Added comment on IDatReaderWriter's write-path methods noting they
are preserved for verbatim compatibility but unused in acdream.
M3: Added comment on Chorizite.Core PackageReference in Core.csproj
explaining the previously-transitive dependency.
Also excluded SplitFormulaDivergenceTest.cs from the test build via
<Compile Remove>: this N.5b one-time data-collection test referenced
WorldBuilder.Shared types directly; after Phase O-T7 dropped that
project reference it no longer compiles. The sweep data it produced
already informed the N.5b Path-C decision and the file is retained
in the tree for historical reference.
Build green; tests green (1146 + 8 pre-existing failures baseline
maintained).
Spec: docs/superpowers/specs/2026-05-21-phase-o-dat-path-unification-design.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
116 lines
3.9 KiB
C#
116 lines
3.9 KiB
C#
using DatReaderWriter;
|
|
using DatReaderWriter.Enums;
|
|
using DatReaderWriter.Lib.IO;
|
|
using System.Collections.ObjectModel;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
|
|
// Phase O-T7: verbatim copy of WorldBuilder.Shared.Services.IDatReaderWriter +
|
|
// IDatDatabase into the AcDream.App.Rendering.Wb namespace so the
|
|
// WorldBuilder.Shared project reference can be dropped.
|
|
// The only consumer of IDatReaderWriter in acdream is DatCollectionAdapter +
|
|
// ObjectMeshManager, both already in this namespace.
|
|
|
|
namespace AcDream.App.Rendering.Wb;
|
|
|
|
/// <summary>
|
|
/// Interface for the dat reader/writer
|
|
/// </summary>
|
|
public interface IDatReaderWriter : IDisposable {
|
|
/// <summary>
|
|
/// Gets the source directory of the DAT files.
|
|
/// </summary>
|
|
string SourceDirectory { get; }
|
|
|
|
/// <summary>
|
|
/// Tries to get the raw bytes of a file from a specific region database.
|
|
/// </summary>
|
|
bool TryGetFileBytes(uint regionId, uint fileId, ref byte[] bytes, out int bytesRead);
|
|
|
|
/// <summary>
|
|
/// The portal database
|
|
/// </summary>
|
|
IDatDatabase Portal { get; }
|
|
|
|
/// <summary>
|
|
/// The cell region databases. Each key is a cell region ID
|
|
/// </summary>
|
|
ReadOnlyDictionary<uint, IDatDatabase> CellRegions { get; }
|
|
|
|
/// <summary>
|
|
/// The high res database
|
|
/// </summary>
|
|
IDatDatabase HighRes { get; }
|
|
|
|
/// <summary>
|
|
/// The language database
|
|
/// </summary>
|
|
IDatDatabase Language { get; }
|
|
|
|
/// <summary>
|
|
/// A mapping of region ids to region dat file entry ids. key: region id, value: region dat file entry
|
|
/// </summary>
|
|
ReadOnlyDictionary<uint, uint> RegionFileMap { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the current portal iteration.
|
|
/// </summary>
|
|
int PortalIteration { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the current cell iteration (from the first cell region).
|
|
/// </summary>
|
|
int CellIteration { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the current high res iteration.
|
|
/// </summary>
|
|
int HighResIteration { get; }
|
|
|
|
/// <summary>
|
|
/// Gets the current language iteration.
|
|
/// </summary>
|
|
int LanguageIteration { get; }
|
|
|
|
// Write-path methods — preserved from WB's interface for verbatim
|
|
// compatibility but not exercised by ObjectMeshManager in acdream.
|
|
/// <summary>Attempts to save a database object to the appropriate DAT.</summary>
|
|
bool TrySave<T>(T obj, int iteration = 0) where T : IDBObj;
|
|
|
|
/// <summary>Attempts to save a database object to the appropriate DAT for a specific region.</summary>
|
|
bool TrySave<T>(uint regionId, T obj, int iteration = 0) where T : IDBObj;
|
|
|
|
/// <summary>
|
|
/// Resolution of a data ID to a database and type
|
|
/// </summary>
|
|
public record IdResolution(IDatDatabase Database, DBObjType Type);
|
|
|
|
/// <summary>
|
|
/// Resolves a data ID to all possible databases and types.
|
|
/// </summary>
|
|
public IEnumerable<IdResolution> ResolveId(uint id);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Interface for a dat database, providing methods to retrieve files and objects.
|
|
/// </summary>
|
|
public interface IDatDatabase : IDisposable {
|
|
DatDatabase Db { get; }
|
|
|
|
/// <summary>Retrieves the current iteration of the database.</summary>
|
|
int Iteration { get; }
|
|
|
|
/// <summary>Retrieves all file IDs of a specific type.</summary>
|
|
public IEnumerable<uint> GetAllIdsOfType<T>() where T : IDBObj;
|
|
|
|
/// <summary>Attempts to retrieve a database object by its file ID.</summary>
|
|
public bool TryGet<T>(uint fileId, [MaybeNullWhen(false)] out T value) where T : IDBObj;
|
|
|
|
/// <summary>Attempts to retrieve the raw bytes of a file by its ID.</summary>
|
|
bool TryGetFileBytes(uint fileId, [MaybeNullWhen(false)] out byte[] value);
|
|
|
|
/// <summary>Attempts to retrieve the raw bytes of a file by its ID into a provided buffer.</summary>
|
|
bool TryGetFileBytes(uint fileId, ref byte[] bytes, out int bytesRead);
|
|
|
|
/// <summary>Attempts to save a database object.</summary>
|
|
bool TrySave<T>(T obj, int iteration = 0) where T : IDBObj;
|
|
}
|