Skip to content

Preserve SurfaceTexture metadata during DAT unpacking - #4518

Open
KT053374 wants to merge 2 commits into
ACEmulator:masterfrom
KT053374:feature/datloader-surfacetexture-metadata
Open

KT053374 wants to merge 2 commits into
ACEmulator:masterfrom
KT053374:feature/datloader-surfacetexture-metadata

Conversation

@KT053374

Copy link
Copy Markdown
Contributor

Summary

Updates ACE.DatLoader.FileTypes.SurfaceTexture to preserve resource metadata identified through analysis of the original Asheron's Call client serialization format.

The existing parser reads the resource identifier and texture references but does not expose the DataCategory and TextureType fields present in the serialized record.

This change makes those fields available to DAT consumers while retaining the existing texture-reference parsing behavior.

Problem

The original client identifies ImgTex as SURFACETEXTURE (DB type 0x0B).

Analysis of the original serialization implementation established the following layout:

  1. Resource ID (UInt32)
  2. DataCategory (UInt32)
  3. TextureType (Byte)
  4. Texture references (List<UInt32>)

Without exposing this metadata, applications consuming SurfaceTexture resources cannot inspect the full decoded resource header.

Changes

  • Added a DataCategory property using UInt32 to preserve the original serialized value.
  • Added a TextureType property using the existing TextureType enumeration.
  • Updated SurfaceTexture.Unpack() to populate both properties.
  • Preserved existing texture-reference handling.
  • Added four self-contained regression tests.

The implementation follows the established field layout already represented by RenderTexture.

Validation

Added SurfaceTextureTests.cs with four regression scenarios:

  1. Two texture references: Validates resource ID, metadata values, and texture-reference ordering.
  2. Unsigned category preservation: Confirms that category values containing high-order bits are preserved without truncation or sign conversion.
  3. Zero texture references: Verifies correct handling of an empty texture-reference collection.
  4. RenderTexture compatibility: Confirms that SurfaceTexture and the independently implemented RenderTexture parser interpret the same binary record consistently.

Each test verifies that the parser consumes exactly the expected number of bytes.

Tests construct binary records in memory and do not require installed DAT archives or initialization of the DatManager singleton.

All examined retail SurfaceTexture resources contained DataCategory = 0. The synthetic tests additionally verify nonzero values to protect the parser against potential variations.

Impact

This is a focused DAT metadata preservation change.

It does not modify resource identifiers, texture references, rendering behavior, game-server functionality, or the underlying DAT format.

The additional metadata may benefit downstream consumers such as ACViewer, DAT inspection utilities, and future content-editing applications requiring access to original resource properties.

Scope

Limited to:

  • ACE.DatLoader/FileTypes/SurfaceTexture.cs
  • ACE.DatLoader.Tests/SurfaceTextureTests.cs

No gameplay or rendering changes are intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant