Skip to content

Identify Texture DataCategory from original client serialization - #4519

Open
KT053374 wants to merge 1 commit into
ACEmulator:masterfrom
KT053374:feature/datloader-texture-category
Open

KT053374 wants to merge 1 commit into
ACEmulator:masterfrom
KT053374:feature/datloader-texture-category

Conversation

@KT053374

Copy link
Copy Markdown
Contributor

Summary

Updates ACE.DatLoader.FileTypes.Texture to expose and preserve the DataCategory field serialized by the original Asheron's Call client.

Analysis of the original client implementation identified this field as inherited metadata associated with RenderSurface resources.

The change preserves the original unsigned 32-bit value and adds regression coverage to verify that subsequent texture fields remain correctly aligned and decoded.

Problem

The original client serializes m_dataCategory as part of the resource metadata inherited from DBObj.

Although this value is present in the serialized texture record, the existing Texture implementation does not expose it to consumers of ACE.DatLoader.

The identified binary layout is:

  1. Resource ID (UInt32)
  2. DataCategory (UInt32)
  3. Width (Int32)
  4. Height (Int32)
  5. Pixel format (UInt32)
  6. Image data length (Int32)
  7. Image data
  8. Optional palette identifier for applicable pixel formats

The meaning of individual category values has not yet been established. Consequently, the implementation preserves the raw value without assigning unverified semantics.

Changes

  • Added a public DataCategory property using UInt32.
  • Updated Texture.Unpack() to populate the property immediately after reading the resource ID.
  • Preserved existing width, height, pixel format, image data, and palette decoding.
  • Added two self-contained regression tests covering category preservation and texture field alignment.

No changes were made to texture decompression, bitmap generation, or image export functionality.

Validation

Added TextureDataCategoryTests.cs with two regression scenarios:

1. DataCategory preservation and field alignment

Tests the following values:

  • 0
  • 7
  • 0x80000000
  • UInt32.MaxValue

Verifies that the parser preserves the category value and correctly decodes the following fields:

  • Resource ID
  • Width and height
  • Pixel format
  • Image data length
  • Pixel data
  • Absence of an optional palette identifier

2. Palettized texture compatibility

Uses a PFID_P8 texture record with DataCategory = 10.

Verifies:

  • Correct category preservation
  • Correct image dimensions and pixel format
  • Correct pixel-data extraction
  • Correct optional palette identifier decoding
  • Complete consumption of the serialized record

Both tests construct their records in memory and do not require retail DAT archives.

Each test verifies that the parser reaches the exact end of the supplied binary record.

Impact

This change improves the completeness of the decoded Texture resource representation.

Preserving DataCategory provides downstream applications access to metadata present in the original client format without requiring those applications to perform additional binary parsing.

Potential consumers include ACViewer, DAT inspection utilities, texture analysis tools, and future world or content customization applications.

Existing texture decoding and rendering-related functionality remains unchanged.

Scope

Limited to:

  • ACE.DatLoader/FileTypes/Texture.cs
  • ACE.DatLoader.Tests/TextureDataCategoryTests.cs

This is a metadata preservation and regression-coverage change only.

No gameplay, rendering, or DAT format 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