|
wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
|
A terrain chunk (MCNK) for one client version. More...
#include <wowlib/formats/adt/map_chunk.hpp>
Public Member Functions | |
| void | validateExtra (ValidationReport &report) const |
| Validation hook (see formats::detail::validateValue): the terrain chunk's contracts the annotations cannot express — the decoded alpha surfaces' fixed size and the layer/alpha relationship. | |
| Result< void > | readFrom (std::span< const std::byte > payload, FileKind kind, AlphaFormat af) |
| Decode one physical file's portion of this terrain chunk into the accumulating entity, reflecting over the chunk()-annotated members. | |
| Result< void > | writeTo (FileBuffer &out, FileKind kind, AlphaFormat af) const |
| Append this chunk's portion for kind to out (the MCNK payload; the caller wraps the fourcc+size). | |
| bool | operator== (const MapChunk &) const =default |
Public Attributes | |
| SMChunk | header {} |
| The chunk header (flags, grid position, area, holes, origin). | |
| std::vector< float > | heights |
| The 9x9 + 8x8 = 145 terrain heights (MCVT), relative to the chunk origin, in the interleaved outer/inner row order. | |
| std::vector< MCNREntry > | normals |
| The 145 terrain normals (MCNR), X Z Y signed bytes. | |
| std::vector< SMLayer > | layers |
| The texture layers (MCLY); layer 0 is opaque, later layers blend through their alpha map. | |
| std::vector< std::vector< std::uint8_t > > | alphaMaps |
| One decoded 64x64 (4096-byte) alpha map per layer, aligned with layers (layer 0's is empty); 0 = base texture, 255 = this layer. | |
| std::vector< std::uint8_t > | shadowMap |
| The decoded 64x64 (4096-byte) shadow map (MCSH), 0/1 per texel; empty when the chunk casts no baked shadow. | |
| std::vector< std::uint32_t > | doodadRefs |
| Doodad references (MCRF doodad part pre-Cata, MCRD Cata+): indices into the tile's MDDF placements drawn in this chunk. | |
| std::vector< std::uint32_t > | objectRefs |
| Object references (MCRF object part pre-Cata, MCRW Cata+): indices into the tile's MODF placements drawn in this chunk. | |
| std::vector< std::conditional_t<(V< builds::WotLK), CWSoundEmitterVanilla, CWSoundEmitter > > | soundEmitters |
| Sound emitters placed in this chunk (MCSE): pre-WotLK versions carry the full 52-byte inline emitter (CWSoundEmitterVanilla), WotLK+ the 28-byte SoundEntriesAdvanced reference (CWSoundEmitter). | |
| ChunkBlob | mcseRaw |
| A malformed MCSE payload (not a whole number of entries), preserved verbatim — see detail::SoundEmitterCodec; empty whenever soundEmitters parsed. | |
| std::array< std::uint8_t, 13 > | mcnrPadding {} |
| The 13 undeclared trailing bytes after the MCNR normals (a near-constant client pattern, not derived from the normals); preserved for the semantic round-trip. | |
Static Public Attributes | |
| static constexpr ClientVersion | Version = V |
| static constexpr std::array | SubChunkOrder |
| The canonical sub-chunk write order (excluding the references, which are the MCRF-vs-MCRD/MCRW special case, emitted last). | |
A terrain chunk (MCNK) for one client version.
Instantiate through the canonicalizing adt::MapChunk alias.
Definition at line 374 of file map_chunk.hpp.
|
default |
| Result< void > wowlib::formats::adt::detail::MapChunk< V >::readFrom | ( | std::span< const std::byte > | payload, |
| FileKind | kind, | ||
| AlphaFormat | af ) |
Decode one physical file's portion of this terrain chunk into the accumulating entity, reflecting over the chunk()-annotated members.
| payload | the MCNK chunk payload from this file. |
| kind | which physical file the portion came from. |
| af | the tile's alpha-map bit depth (supplied externally). |
Definition at line 680 of file map_chunk.hpp.
References wowlib::formats::detail::annotation(), wowlib::ChunkTruncated, wowlib::formats::adt::chunks::DoNotFixAlphaMap, wowlib::formats::adt::fileHasHeader(), wowlib::formats::fourcc(), wowlib::formats::fourccToString(), wowlib::formats::hasFlag(), header, layers, wowlib::makeError(), wowlib::formats::detail::membersOf(), and wowlib::formats::detail::readValue().
|
inline |
Validation hook (see formats::detail::validateValue): the terrain chunk's contracts the annotations cannot express — the decoded alpha surfaces' fixed size and the layer/alpha relationship.
Contracts reaching into the TILE (layer texture ids, doodad and object references) belong to the ADT's validate(), which is where the texture and placement tables live.
| report | the report findings land in. |
Definition at line 449 of file map_chunk.hpp.
| Result< void > wowlib::formats::adt::detail::MapChunk< V >::writeTo | ( | FileBuffer & | out, |
| FileKind | kind, | ||
| AlphaFormat | af ) const |
Append this chunk's portion for kind to out (the MCNK payload; the caller wraps the fourcc+size).
Header-bearing files emit the 128-byte header with every offset/size/count field freshly stamped.
| out | the destination buffer. |
| kind | which physical file's portion to write. |
| af | the tile's alpha-map bit depth (supplied externally). |
Definition at line 749 of file map_chunk.hpp.
References wowlib::formats::detail::annotation(), wowlib::formats::adt::detail::appendBytes(), wowlib::formats::adt::fileHasHeader(), header, wowlib::formats::detail::membersOf(), wowlib::formats::adt::Obj, wowlib::formats::adt::detail::AlphaCodec::prepare(), wowlib::formats::adt::routesTo(), SubChunkOrder, wowlib::formats::adt::Tex, and wowlib::formats::detail::writeValue().
| std::vector<std::vector<std::uint8_t> > wowlib::formats::adt::detail::MapChunk< V >::alphaMaps |
One decoded 64x64 (4096-byte) alpha map per layer, aligned with layers (layer 0's is empty); 0 = base texture, 255 = this layer.
Definition at line 414 of file map_chunk.hpp.
| std::vector<std::uint32_t> wowlib::formats::adt::detail::MapChunk< V >::doodadRefs |
Doodad references (MCRF doodad part pre-Cata, MCRD Cata+): indices into the tile's MDDF placements drawn in this chunk.
Definition at line 422 of file map_chunk.hpp.
| SMChunk wowlib::formats::adt::detail::MapChunk< V >::header {} |
The chunk header (flags, grid position, area, holes, origin).
Definition at line 398 of file map_chunk.hpp.
Referenced by readFrom(), and writeTo().
| std::vector<float> wowlib::formats::adt::detail::MapChunk< V >::heights |
The 9x9 + 8x8 = 145 terrain heights (MCVT), relative to the chunk origin, in the interleaved outer/inner row order.
Definition at line 402 of file map_chunk.hpp.
| std::vector<SMLayer> wowlib::formats::adt::detail::MapChunk< V >::layers |
The texture layers (MCLY); layer 0 is opaque, later layers blend through their alpha map.
Definition at line 410 of file map_chunk.hpp.
Referenced by readFrom().
| std::array<std::uint8_t, 13> wowlib::formats::adt::detail::MapChunk< V >::mcnrPadding {} |
The 13 undeclared trailing bytes after the MCNR normals (a near-constant client pattern, not derived from the normals); preserved for the semantic round-trip.
Read/written as part of MCNR by NormalCodec.
Definition at line 440 of file map_chunk.hpp.
| ChunkBlob wowlib::formats::adt::detail::MapChunk< V >::mcseRaw |
A malformed MCSE payload (not a whole number of entries), preserved verbatim — see detail::SoundEmitterCodec; empty whenever soundEmitters parsed.
Definition at line 435 of file map_chunk.hpp.
| std::vector<MCNREntry> wowlib::formats::adt::detail::MapChunk< V >::normals |
The 145 terrain normals (MCNR), X Z Y signed bytes.
Definition at line 406 of file map_chunk.hpp.
| std::vector<std::uint32_t> wowlib::formats::adt::detail::MapChunk< V >::objectRefs |
Object references (MCRF object part pre-Cata, MCRW Cata+): indices into the tile's MODF placements drawn in this chunk.
Definition at line 426 of file map_chunk.hpp.
| std::vector<std::uint8_t> wowlib::formats::adt::detail::MapChunk< V >::shadowMap |
The decoded 64x64 (4096-byte) shadow map (MCSH), 0/1 per texel; empty when the chunk casts no baked shadow.
Definition at line 418 of file map_chunk.hpp.
| std::vector<std::conditional_t<(V < builds::WotLK), CWSoundEmitterVanilla, CWSoundEmitter> > wowlib::formats::adt::detail::MapChunk< V >::soundEmitters |
Sound emitters placed in this chunk (MCSE): pre-WotLK versions carry the full 52-byte inline emitter (CWSoundEmitterVanilla), WotLK+ the 28-byte SoundEntriesAdvanced reference (CWSoundEmitter).
Definition at line 430 of file map_chunk.hpp.
|
staticconstexpr |
The canonical sub-chunk write order (excluding the references, which are the MCRF-vs-MCRD/MCRW special case, emitted last).
Each physical file emits the subset routed to it, in this order — see writeTo.
Definition at line 384 of file map_chunk.hpp.
Referenced by writeTo().
|
staticconstexpr |
Definition at line 379 of file map_chunk.hpp.