wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
wowlib::formats::wdl::detail::WDL< V > Struct Template Reference

A WDL low-resolution heightmap file for one client version. More...

#include <wowlib/formats/wdl/wdl.hpp>

Inheritance diagram for wowlib::formats::wdl::detail::WDL< V >:

Public Member Functions

std::vector< std::uint32_t > oceanMaskTiles () const
 The heightmap ordinal each ocean mask belongs to (parallel to oceanMasks): derived from the stored journal's interleave, or the identity pairing for fresh entities.
void validateExtra (ValidationReport &report) const
 Validation hook (see formats::detail::validateValue): the tile-table pairing invariants — the MAOF table's shape, and the ordinal pairing that makes the i-th nonzero slot own the i-th heightmap.
Result< std::optional< std::vector< JournalEntry > > > resequencedJournal () const
 Serializer hook (see writeEntity): once the stored journal no longer matches the tile data (tiles added/removed, or a fresh entity), rebuild the emission order — every non-tile chunk in canonical order, then each tile's MARE/(MAOC/MAOE)/MAHO interleaved after MAOF, preserved unknown chunks last.
Result< void > patchFile (std::span< std::byte > image) const
 Serializer hook (see writeEntity): stamp the MAOF table in the finished image — the i-th nonzero slot receives the i-th MARE chunk's absolute offset.
Result< void > read (fs::FileSystem &fs, const FileKey &key)
 Load the WDL from a client filesystem, replacing this entity's contents.
Result< void > write (fs::FileSystem &fs, const FileKey &key) const
 Serialize and store the WDL through the filesystem's project overlay.
Public Member Functions inherited from wowlib::formats::ChunkedFile< WDL< V > >
Result< void > read (std::span< const std::byte > data)
 Deserialize file bytes into this entity, replacing its contents.
Result< FileBuffer > write () const
 Serialize this entity.
ValidationReport validate () const
Result< void > ensureValid () const
 Validate and raise on the first error instead of returning a report — the assert-style face of validate().
bool operator== (const ChunkedFile &) const=default
Public Member Functions inherited from wowlib::formats::ChunkExtras
bool operator== (const ChunkExtras &) const =default

Public Attributes

std::uint32_t mver = WdlVersion18
 The WDL format version; 18 for every supported client.
StringBlock wmoFilenames
std::vector< std::uint32_t > wmoFilenameOffsets
 MWMO filename start offsets (MWID), one per name.
std::vector< SMMapObjDef > wmoPlacements
 WMO silhouette placements (MODF), one per MWMO name; the same 64-byte record the WDT and ADT use.
std::vector< std::uint32_t > tileOffsets
std::vector< TileHeights > heightmaps
Public Attributes inherited from wowlib::formats::ChunkExtras
std::vector< JournalEntry > journal
std::vector< UnknownChunk > unknown
std::vector< std::byte > trailing

Static Public Attributes

static constexpr ClientVersion Version = V
static constexpr std::array ChunkOrder
 The canonical chunk-stream order the serializer emits a fresh entity in (see writeOrder); the per-tile interleave is produced by resequencedJournal(), not this table.

Detailed Description

template<ClientVersion V>
struct wowlib::formats::wdl::detail::WDL< V >

A WDL low-resolution heightmap file for one client version.

Instantiate through the canonicalizing wdl::WDL alias, never directly.

The tile chunks pair by ordinal: the i-th heightmap belongs to the i-th nonzero tileOffsets slot (row-major), and the i-th hole mask to the i-th heightmap. The MAOF offsets themselves are DERIVED — stamped from the finished layout on every write — so only the nonzero pattern is authored data; toggle a slot nonzero (any value) and give it a heightmap to add a tile.

Template Parameters
Vthe client version this layout targets.
See also
https://wowdev.wiki/WDL

Definition at line 160 of file wdl.hpp.

Member Function Documentation

◆ oceanMaskTiles()

template<ClientVersion V>
std::vector< std::uint32_t > wowlib::formats::wdl::detail::WDL< V >::oceanMaskTiles ( ) const

The heightmap ordinal each ocean mask belongs to (parallel to oceanMasks): derived from the stored journal's interleave, or the identity pairing for fresh entities.

Empty for versions without MAOE.

Returns
one heightmap ordinal per ocean mask

Definition at line 285 of file wdl.hpp.

References wowlib::formats::detail::chunkMemberIndex(), wowlib::formats::fourcc(), heightmaps, and wowlib::formats::ChunkExtras::journal.

◆ patchFile()

template<ClientVersion V>
Result< void > wowlib::formats::wdl::detail::WDL< V >::patchFile ( std::span< std::byte > image) const

Serializer hook (see writeEntity): stamp the MAOF table in the finished image — the i-th nonzero slot receives the i-th MARE chunk's absolute offset.

Parameters
imagethis entity's complete serialized image.
Returns
nothing, or the pairing-mismatch error.

Definition at line 447 of file wdl.hpp.

References wowlib::formats::fourcc(), wowlib::InvalidEntityState, wowlib::makeError(), and wowlib::formats::wdl::WdlTileSlots.

◆ read()

template<ClientVersion V>
Result< void > wowlib::formats::wdl::detail::WDL< V >::read ( fs::FileSystem & fs,
const FileKey & key )

Load the WDL from a client filesystem, replacing this entity's contents.

Parameters
fsthe filesystem gateway
keythe file identity (path and/or FileDataID)

Definition at line 498 of file wdl.hpp.

References wowlib::FormatVersionMismatch, wowlib::makeError(), mver, wowlib::formats::ChunkedFile< Derived >::read(), and wowlib::formats::wdl::WdlVersion18.

◆ resequencedJournal()

template<ClientVersion V>
Result< std::optional< std::vector< JournalEntry > > > wowlib::formats::wdl::detail::WDL< V >::resequencedJournal ( ) const

Serializer hook (see writeEntity): once the stored journal no longer matches the tile data (tiles added/removed, or a fresh entity), rebuild the emission order — every non-tile chunk in canonical order, then each tile's MARE/(MAOC/MAOE)/MAHO interleaved after MAOF, preserved unknown chunks last.

Requires the tile-table pairing invariants (validateExtra) to hold.

Returns
nullopt to replay the stored journal, the rebuilt journal otherwise, or the validation error.

Definition at line 345 of file wdl.hpp.

References wowlib::formats::detail::chunkMemberIndex(), wowlib::formats::fourcc(), wowlib::formats::detail::freshJournal(), heightmaps, wowlib::formats::ChunkExtras::journal, wowlib::formats::JournalEntry::member, and validateExtra().

◆ validateExtra()

template<ClientVersion V>
void wowlib::formats::wdl::detail::WDL< V >::validateExtra ( ValidationReport & report) const

Validation hook (see formats::detail::validateValue): the tile-table pairing invariants — the MAOF table's shape, and the ordinal pairing that makes the i-th nonzero slot own the i-th heightmap.

These are the SAME contracts the write path must hold to lay out a rebuilt journal, so write() checks them through this hook rather than restating them (see resequencedJournal).

Parameters
reportthe report findings land in.

Definition at line 310 of file wdl.hpp.

References wowlib::formats::ValidationReport::addError(), heightmaps, tileOffsets, and wowlib::formats::wdl::WdlTileSlots.

Referenced by resequencedJournal().

◆ write()

template<ClientVersion V>
Result< void > wowlib::formats::wdl::detail::WDL< V >::write ( fs::FileSystem & fs,
const FileKey & key ) const

Serialize and store the WDL through the filesystem's project overlay.

Parameters
fsthe filesystem gateway
keythe file identity; must resolve to a path

Definition at line 510 of file wdl.hpp.

References wowlib::makeError(), wowlib::FileKey::path, wowlib::PathNotResolvable, and wowlib::formats::ChunkedFile< Derived >::write().

Member Data Documentation

◆ ChunkOrder

template<ClientVersion V>
std::array wowlib::formats::wdl::detail::WDL< V >::ChunkOrder
staticconstexpr
Initial value:
= {
fourcc("MVER"),
fourcc("MWMO"),
fourcc("MWID"),
fourcc("MODF"),
fourcc("MLDD"),
fourcc("MLDX"),
fourcc("MLDF"),
fourcc("MLDL"),
fourcc("MLDB"),
fourcc("MLMD"),
fourcc("MLMX"),
fourcc("MLMB"),
fourcc("MSSN"),
fourcc("MSSC"),
fourcc("MSSO"),
fourcc("MSSF"),
fourcc("MSLD"),
fourcc("MSLI"),
fourcc("MAOF"),
fourcc("MARE"),
fourcc("MAOC"),
fourcc("MAOE"),
fourcc("MAHO"),
}
constexpr std::uint32_t fourcc(const char(&cc)[5], FourCCEndian endian=FourCCEndian::Reversed)
The host integer a scanned chunk id compares equal to for code cc.
Definition fourcc.hpp:33

The canonical chunk-stream order the serializer emits a fresh entity in (see writeOrder); the per-tile interleave is produced by resequencedJournal(), not this table.

Lists every chunk member exactly once.

Definition at line 196 of file wdl.hpp.

◆ heightmaps

template<ClientVersion V>
std::vector<TileHeights> wowlib::formats::wdl::detail::WDL< V >::heightmaps

Definition at line 190 of file wdl.hpp.

Referenced by oceanMaskTiles(), resequencedJournal(), and validateExtra().

◆ mver

template<ClientVersion V>
std::uint32_t wowlib::formats::wdl::detail::WDL< V >::mver = WdlVersion18

The WDL format version; 18 for every supported client.

Definition at line 173 of file wdl.hpp.

Referenced by read().

◆ tileOffsets

template<ClientVersion V>
std::vector<std::uint32_t> wowlib::formats::wdl::detail::WDL< V >::tileOffsets

Definition at line 187 of file wdl.hpp.

Referenced by validateExtra().

◆ Version

template<ClientVersion V>
ClientVersion wowlib::formats::wdl::detail::WDL< V >::Version = V
staticconstexpr

Definition at line 169 of file wdl.hpp.

◆ wmoFilenameOffsets

template<ClientVersion V>
std::vector<std::uint32_t> wowlib::formats::wdl::detail::WDL< V >::wmoFilenameOffsets

MWMO filename start offsets (MWID), one per name.

Definition at line 180 of file wdl.hpp.

◆ wmoFilenames

Definition at line 176 of file wdl.hpp.

◆ wmoPlacements

template<ClientVersion V>
std::vector<SMMapObjDef> wowlib::formats::wdl::detail::WDL< V >::wmoPlacements

WMO silhouette placements (MODF), one per MWMO name; the same 64-byte record the WDT and ADT use.

Definition at line 184 of file wdl.hpp.


The documentation for this struct was generated from the following file: