wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
map_chunk.hpp File Reference

The per-chunk terrain entity (namespace wowlib::formats::adt): MapChunk<V>, one of the 256 MCNK terrain chunks of a tile, fully decoded. More...

#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <format>
#include <meta>
#include <optional>
#include <ranges>
#include <span>
#include <tuple>
#include <vector>
#include <welder/vocabulary.hpp>
#include <wowlib/core/buffer.hpp>
#include <wowlib/core/client_builds.hpp>
#include <wowlib/core/client_version.hpp>
#include <wowlib/core/error.hpp>
#include <wowlib/core/lang.hpp>
#include <wowlib/formats/adt/boundaries.hpp>
#include <wowlib/formats/adt/chunks/header.hpp>
#include <wowlib/formats/adt/chunks/liquid.hpp>
#include <wowlib/formats/adt/chunks/object.hpp>
#include <wowlib/formats/adt/chunks/texture.hpp>
#include <wowlib/formats/adt/codec.hpp>
#include <wowlib/formats/adt/liquid.hpp>
#include <wowlib/formats/common/annotations.hpp>
#include <wowlib/formats/common/chunked_file.hpp>
#include <wowlib/formats/common/flags.hpp>
#include <wowlib/formats/common/fourcc.hpp>
#include <wowlib/formats/common/types.hpp>
#include <wowlib/formats/common/version_range.hpp>
#include <wowlib/formats/common/version_slot.hpp>
Include dependency graph for map_chunk.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wowlib::formats::adt::detail::InFileSpec
 Stored form of an inFile annotation: a binary chunk's physical-file group. More...
struct  wowlib::formats::adt::detail::SerializerSpec
 Stored form of a serializedBy annotation: the reflection of a codec type handling a sub-chunk that a plain readValue/writeValue cannot (external length, a transform, or a companion member). More...
struct  wowlib::formats::adt::MapChunkBase
 The version-agnostic base of every MapChunk<V> (welded as "MapChunk"): the language bindings attach for_version here and give the per-version chunks a common welded supertype. More...
struct  wowlib::formats::adt::detail::MapChunkReadCtx
 Context a sub-chunk codec needs to read one MCNK sub-chunk: the (already parsed) header, the sibling texture layers (MCAL indexes them), the tile alpha bit depth and whether to repair the 63x63 "unfixed" edge form. More...
struct  wowlib::formats::adt::detail::MapChunkWriteCtx
 Context a sub-chunk codec needs to write one MCNK sub-chunk. More...
struct  wowlib::formats::adt::detail::NormalCodec
 MCNR codec: 145 XZY normal triples followed by 13 undeclared padding bytes (a near-constant client pattern preserved for the semantic round-trip). More...
struct  wowlib::formats::adt::detail::LayerCodec
 MCLY codec: the texture layers, plus sizing alphaMaps to the layer count (MCAL may be absent on Cata+ when empty, so alphaMaps must be sized here to keep it aligned with layers). More...
struct  wowlib::formats::adt::detail::AlphaCodec
 MCAL codec: decode/encode the per-layer 64x64 alpha maps through AlphaMapCodec, indexing the sibling layers' flags + offsetInMcal. More...
struct  wowlib::formats::adt::detail::ShadowCodec
 MCSH codec: the 64x64 shadow map through ShadowMapCodec. More...
struct  wowlib::formats::adt::detail::SoundEmitterCodec
 MCSE codec: typed emitter records — the era picks the entry (pre-WotLK 52-byte CWSoundEmitterVanilla, 28-byte CWSoundEmitter after; the member's value_type carries the choice). More...
struct  wowlib::formats::adt::detail::MapChunkColor
 Vertex colors (MCCV), WotLK+. More...
struct  wowlib::formats::adt::detail::MapChunkCata
 Vertex lighting (MCLV) and terrain materials (MCMT), Cata+. More...
struct  wowlib::formats::adt::detail::MapChunkLegacyLiquid
 Legacy liquid (MCLQ). More...
struct  wowlib::formats::adt::detail::MapChunk< V >
 A terrain chunk (MCNK) for one client version. More...

Namespaces

namespace  wowlib
namespace  wowlib::formats
namespace  wowlib::formats::adt
namespace  wowlib::formats::adt::detail

Typedefs

template<ClientVersion V>
using wowlib::formats::adt::MapChunk = detail::MapChunk<canonicalVersion(V, MapChunkPivots, AdtVersions)>
 A terrain chunk — the canonicalizing face of detail::MapChunk: every client version collapses to its range's first grid version (MapChunkPivots).

Enumerations

enum class  wowlib::formats::adt::FileKind : std::uint8_t {
  wowlib::formats::adt::Monolithic = 0 , wowlib::formats::adt::Root = 1 , wowlib::formats::adt::Tex0 = 2 , wowlib::formats::adt::Obj0 = 3 ,
  wowlib::formats::adt::Obj1 = 4 , wowlib::formats::adt::Lod = 5
}
 Which physical ADT file a chunk's portion belongs to. More...
enum class  wowlib::formats::adt::InFile : std::uint8_t { wowlib::formats::adt::Root , wowlib::formats::adt::Tex , wowlib::formats::adt::Obj }
 The physical-file group a binary chunk (tile-level or MCNK sub-chunk) is routed to on write; the monolithic file carries every group. More...

Functions

consteval detail::InFileSpec wowlib::formats::adt::inFile (InFile file)
 Annotate a binary chunk member with the physical file it is routed to on write (the monolithic file carries every group).
consteval detail::SerializerSpec wowlib::formats::adt::serializedBy (std::meta::info codec)
 Annotate a sub-chunk member with a MapChunk-context codec (a struct with static read(self, span, ReadCtx) / write(self, out, WriteCtx) / engaged(self, WriteCtx) templates) instead of the default uniform transfer.
constexpr bool wowlib::formats::adt::routesTo (InFile file, FileKind kind)
 Whether a member routed to file participates in physical file kind: the monolithic file carries every group, each split file only its own.
constexpr bool wowlib::formats::adt::fileHasHeader (FileKind kind)
 Whether a given physical file carries the 128-byte MCNK header (the root or the pre-Cata monolithic file).
void wowlib::formats::adt::detail::appendBytes (FileBuffer &out, const void *p, std::size_t n)
 Append n raw bytes at p to out (a byte-copy primitive).

Variables

constexpr std::size_t wowlib::formats::adt::detail::McvtCount = 145
 The 9x9 + 8x8 = 145 vertices of the MCVT height / MCNR normal grid.

Detailed Description

The per-chunk terrain entity (namespace wowlib::formats::adt): MapChunk<V>, one of the 256 MCNK terrain chunks of a tile, fully decoded.

MapChunk is NOT a generic ChunkedFile: the MCNK payload has a 128-byte header of derived offsets/sizes, sub-chunks whose lengths the header (not their own size field) governs (MCAL/MCLQ/MCSH), a pre-Cata MCNR trailer of 13 undeclared padding bytes, and alpha maps in three on-disk encodings. Because a Cata+ tile splits one terrain chunk across the root, _tex0 and _obj0 split ADT files, the reader/writer work on one physical FILE at a time (readFrom / writeTo), accumulating into the same MapChunk across files; a pre-Cata tile is one monolithic file carrying every sub-chunk.

Its sub-chunk members still carry the same chunk() + inFile() annotations the tile-level ADT chunks do, so readFrom/writeTo are REFLECTION-DRIVEN: a template for over the members matches the fourcc and routes by physical file. The UNIFORM sub-chunks (plain vectors / the SelfSerializing MCLQ) transfer through the chunk engine's readValue/writeValue; the ones that break the member mapping (MCNR padding, MCLY, MCAL codec, MCSH codec) carry a serializedBy<Codec>() annotation naming a MapChunk-context codec. MCRF (one chunk, two members) and the derived 128-byte header are the only hand-written cases — the MCNK analogue of ADT's MCNK/MHDR.

Version-gated members live in conditionally-inherited trait bases (adt::detail): vertex colors since WotLK, vertex lighting / terrain materials since Cata, the legacy MCLQ liquid until Cata (it survives through WotLK — Outland tiles still ship it).

Definition in file map_chunk.hpp.