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

The MCAL alpha-map and MCSH shadow-map codecs (namespace wowlib::formats::adt::detail): AlphaMapCodec and ShadowMapCodec. More...

#include <cstddef>
#include <cstdint>
#include <span>
#include <vector>
#include <wowlib/formats/adt/boundaries.hpp>
Include dependency graph for codec.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  wowlib::formats::adt::detail::TerrainMapCodec
 Shared geometry for the 64x64 terrain map codecs: the last-row/column repair the client applies to "unfixed" maps on load. More...
class  wowlib::formats::adt::detail::AlphaMapCodec
 The MCAL alpha-map codec. More...
class  wowlib::formats::adt::detail::ShadowMapCodec
 The MCSH shadow-map codec: a 512-byte 1-bit bitmap on disk, a 4096-texel 0/1 surface in memory. More...

Namespaces

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

Variables

constexpr std::size_t wowlib::formats::adt::detail::AlphaDim = 64
 The edge length of the decoded square edit surface (64).
constexpr std::size_t wowlib::formats::adt::detail::AlphaTexels = AlphaDim * AlphaDim
 The texel count of a decoded map (64 * 64 = 4096).
constexpr std::size_t wowlib::formats::adt::detail::Alpha4BitBytes = AlphaTexels / 2
 The on-disk size of a 4-bit alpha map (4096 / 2 = 2048 bytes).
constexpr std::size_t wowlib::formats::adt::detail::ShadowBytes = AlphaTexels / 8
 The on-disk size of a 1-bit shadow bitmap (4096 / 8 = 512 bytes).

Detailed Description

The MCAL alpha-map and MCSH shadow-map codecs (namespace wowlib::formats::adt::detail): AlphaMapCodec and ShadowMapCodec.

wowlib stores terrain alpha and shadow maps as a plain 64x64 8-bit / 1-byte edit surface (4096 bytes), regardless of how they sit on disk. On disk an alpha map is one of three encodings — 2048-byte 4-bit, 4096-byte 8-bit, or RLE-compressed 8-bit — chosen by the tile's AlphaFormat and the layer's compressed flag; a shadow map is a 512-byte 1-bit bitmap. Both may be stored in the "unfixed" 63x63 form the client repairs on load (MCNK flag do_not_fix_alpha clear); wowlib fixes them to the full 64x64 on read and always writes the fixed form (setting the flag), which makes the fix idempotent under a re-read — the semantic-round-trip contract.

Both codecs are classes rather than free functions: encoding a terrain map is a first-class operation with several private encoding strategies, so it earns an object with a small public decode()/encode() surface and the per-encoding routines as protected members. The on-disk bit depth (AlphaFormat) is the codec's state; the per-layer compression and edge-fix choices are call parameters.

Definition in file codec.hpp.