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

A terrain tile for one client version. More...

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

Inheritance diagram for wowlib::formats::adt::detail::ADT< V >:

Public Member Functions

Result< void > read (fs::FileSystem &fs, const FileKey &key, AlphaFormat alpha)
 Load the tile — every split file present — from a client filesystem, replacing this entity's contents.
Result< void > write (fs::FileSystem &fs, const FileKey &key, AlphaFormat alpha) const
 Serialize the tile (and, Cata+, every split file) through the filesystem's project overlay; the file names derive from the key, which must resolve to a path.
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().
Result< void > parseFile (std::span< const std::byte > data, FileKind kind)
 Parse one split file's chunk stream into this entity (merging), by reflecting over the chunk()-annotated members.
Result< FileBuffer > writeFile (FileKind kind, AlphaFormat alpha) const
 Serialize one physical file of the tile (monolithic pre-Cata, or one of root/_tex0/_obj0), routing each chunk()-annotated member by its inFile group and stamping the derived MHDR/MCIN tables.

Public Attributes

std::uint32_t mver = AdtVersion18
 The ADT format version (MVER); 18 for every supported client.
MHDRData header {}
 The tile header (MHDR): flags; the chunk offsets are derived.
StringBlock textures
 The tileset texture filenames (MTEX): the paths MapChunk layers index.
StringBlock modelFilenames
 The M2 model filenames (MMDX) placements reference by MMID index.
std::vector< std::uint32_t > modelNameOffsets
 Byte offsets into model_filenames (MMID): a doodad placement's name_id indexes this list.
StringBlock wmoFilenames
 The WMO filenames (MWMO) placements reference by MWID index.
std::vector< std::uint32_t > wmoNameOffsets
 Byte offsets into wmo_filenames (MWID): a WMO placement's name_id indexes this list.
std::vector< common::SMDoodadDef > doodadPlacements
 Doodad (M2) placements on this tile (MDDF).
std::vector< common::SMMapObjDef > wmoPlacements
 WMO placements on this tile (MODF).
std::vector< adt::MapChunk< V > > chunks
 The 256 terrain chunks (MCNK), row-major (index = y * 16 + x).
AlphaFormat alphaFormat = AlphaFormat::Lowres4Bit
 How this tile's alpha maps were laid out on disk, recorded from the AlphaFormat passed to read(); write() takes its own explicit argument.

Static Public Attributes

static constexpr ClientVersion Version = V
static constexpr std::array ChunkOrder
 The canonical top-level chunk order (a superset; each physical file emits the subset routed to it, in this order — see writeFile).

Detailed Description

template<ClientVersion V>
struct wowlib::formats::adt::detail::ADT< V >

A terrain tile for one client version.

Instantiate through the canonicalizing adt::ADT alias, never directly.

Definition at line 150 of file adt.hpp.

Member Function Documentation

◆ ensureValid()

template<ClientVersion V>
Result< void > wowlib::formats::adt::detail::ADT< V >::ensureValid ( ) const
nodiscard

Validate and raise on the first error instead of returning a report — the assert-style face of validate().

Returns
nothing; raises when validate() finds any error

Definition at line 409 of file adt.hpp.

References validate().

◆ parseFile()

template<ClientVersion V>
Result< void > wowlib::formats::adt::detail::ADT< V >::parseFile ( std::span< const std::byte > data,
FileKind kind )

Parse one split file's chunk stream into this entity (merging), by reflecting over the chunk()-annotated members.

Parameters
datathe file bytes.
kindwhich split file it is.
Returns
a structural error or success.

Definition at line 414 of file adt.hpp.

References alphaFormat, wowlib::formats::detail::annotation(), chunks, wowlib::ChunkTruncated, wowlib::formats::fourcc(), wowlib::formats::fourccToString(), wowlib::makeError(), wowlib::formats::detail::membersOf(), and wowlib::formats::detail::readValue().

Referenced by read().

◆ read()

template<ClientVersion V>
Result< void > wowlib::formats::adt::detail::ADT< V >::read ( fs::FileSystem & fs,
const FileKey & key,
AlphaFormat alpha )

Load the tile — every split file present — from a client filesystem, replacing this entity's contents.

The alpha-map bit depth (from the map's WDT) is supplied by the caller.

Parameters
fsthe filesystem gateway
keythe tile identity (root .adt path and/or FileDataID)
alphathe on-disk alpha-map bit depth for this tile's map (from its WDT MPHD flags)

Definition at line 573 of file adt.hpp.

References alphaFormat, wowlib::builds::Cata, chunks, wowlib::makeError(), wowlib::formats::adt::Monolithic, wowlib::formats::adt::Obj0, parseFile(), wowlib::FileKey::path, wowlib::PathNotResolvable, wowlib::formats::adt::Root, and wowlib::formats::adt::Tex0.

◆ validate()

◆ write()

template<ClientVersion V>
Result< void > wowlib::formats::adt::detail::ADT< V >::write ( fs::FileSystem & fs,
const FileKey & key,
AlphaFormat alpha ) const

Serialize the tile (and, Cata+, every split file) through the filesystem's project overlay; the file names derive from the key, which must resolve to a path.

The alpha-map bit depth to encode is supplied by the caller.

Parameters
fsthe filesystem gateway
keythe tile identity; must resolve to a path
alphathe on-disk alpha-map bit depth to encode

Definition at line 634 of file adt.hpp.

References wowlib::builds::Cata, wowlib::makeError(), wowlib::formats::adt::Monolithic, wowlib::formats::adt::Obj0, wowlib::FileKey::path, wowlib::PathNotResolvable, wowlib::formats::adt::Root, wowlib::formats::adt::Tex0, and writeFile().

◆ writeFile()

Member Data Documentation

◆ alphaFormat

How this tile's alpha maps were laid out on disk, recorded from the AlphaFormat passed to read(); write() takes its own explicit argument.

wowlib always presents decoded 64x64 maps.

Definition at line 222 of file adt.hpp.

Referenced by parseFile(), and read().

◆ ChunkOrder

template<ClientVersion V>
std::array wowlib::formats::adt::detail::ADT< V >::ChunkOrder
staticconstexpr
Initial value:
{
fourcc("MVER"),
fourcc("MHDR"),
fourcc("MCIN"),
fourcc("MAMP"),
fourcc("MTEX"),
fourcc("MDID"),
fourcc("MHID"),
fourcc("MMDX"),
fourcc("MMID"),
fourcc("MWMO"),
fourcc("MWID"),
fourcc("MDDF"),
fourcc("MODF"),
fourcc("MH2O"),
fourcc("MCNK"),
fourcc("MFBO"),
fourcc("MTXF"),
fourcc("MTXP")
}
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 top-level chunk order (a superset; each physical file emits the subset routed to it, in this order — see writeFile).

MCIN and MCNK are positional placeholders the writer fills specially.

Definition at line 161 of file adt.hpp.

Referenced by writeFile().

◆ chunks

template<ClientVersion V>
std::vector<adt::MapChunk<V> > wowlib::formats::adt::detail::ADT< V >::chunks

The 256 terrain chunks (MCNK), row-major (index = y * 16 + x).

Definition at line 219 of file adt.hpp.

Referenced by parseFile(), read(), validate(), and writeFile().

◆ doodadPlacements

template<ClientVersion V>
std::vector<common::SMDoodadDef> wowlib::formats::adt::detail::ADT< V >::doodadPlacements

Doodad (M2) placements on this tile (MDDF).

Definition at line 212 of file adt.hpp.

Referenced by validate().

◆ header

The tile header (MHDR): flags; the chunk offsets are derived.

Definition at line 188 of file adt.hpp.

Referenced by writeFile().

◆ modelFilenames

The M2 model filenames (MMDX) placements reference by MMID index.

Definition at line 196 of file adt.hpp.

◆ modelNameOffsets

template<ClientVersion V>
std::vector<std::uint32_t> wowlib::formats::adt::detail::ADT< V >::modelNameOffsets

Byte offsets into model_filenames (MMID): a doodad placement's name_id indexes this list.

Definition at line 200 of file adt.hpp.

Referenced by validate().

◆ mver

template<ClientVersion V>
std::uint32_t wowlib::formats::adt::detail::ADT< V >::mver = AdtVersion18

The ADT format version (MVER); 18 for every supported client.

Definition at line 184 of file adt.hpp.

◆ textures

The tileset texture filenames (MTEX): the paths MapChunk layers index.

Present unless the tile uses MDID/MHID FileDataIDs (8.1+ height-texturing maps).

Definition at line 192 of file adt.hpp.

Referenced by validate().

◆ Version

template<ClientVersion V>
ClientVersion wowlib::formats::adt::detail::ADT< V >::Version = V
staticconstexpr

Definition at line 156 of file adt.hpp.

◆ wmoFilenames

The WMO filenames (MWMO) placements reference by MWID index.

Definition at line 204 of file adt.hpp.

◆ wmoNameOffsets

template<ClientVersion V>
std::vector<std::uint32_t> wowlib::formats::adt::detail::ADT< V >::wmoNameOffsets

Byte offsets into wmo_filenames (MWID): a WMO placement's name_id indexes this list.

Definition at line 208 of file adt.hpp.

Referenced by validate().

◆ wmoPlacements

template<ClientVersion V>
std::vector<common::SMMapObjDef> wowlib::formats::adt::detail::ADT< V >::wmoPlacements

WMO placements on this tile (MODF).

Definition at line 216 of file adt.hpp.

Referenced by validate().


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