wowlib 0.0.0
Read & write World of Warcraft client files — a C++26 core
Loading...
Searching...
No Matches
header.hpp
Go to the documentation of this file.
1#pragma once
2
8
9#include <array>
10#include <cstdint>
11
12#include <welder/vocabulary.hpp>
13
15#include <wowlib/core/lang.hpp>
19
21 // --- MPHD -------------------------------------------------------------------
22
23 enum class [[
24 =welder::weld,
25 =welder::flags,
26 =welder::doc("Map header flag bits (SMMapHeader.flags).")
27 ]] MapHeaderFlags : std::uint32_t {
28 UsesGlobalMapObj [[=welder::doc(
29 "A WMO-only map: one global map object (MWMO/MODF), "
30 "no terrain tiles.")]] = 0x1,
31 AdtHasMccv [[=welder::doc(
32 "ADTs carry MCCV vertex colors (WotLK+); with this set "
33 "every ADT of the map must have MCCV.")]] = 0x2,
34 AdtHasBigAlpha [[=welder::doc(
35 "Terrain shader 2 (_env): 4096-byte uncompressed MCAL "
36 "alpha maps instead of 2048.")]] = 0x4,
38 [[=welder::doc("ADT MCRF/MCRD doodad references are sorted by size "
39 "category.")]] = 0x8,
40 AdtHasMclv [[=welder::doc(
41 "ADTs carry the second MCLV color layer (Cata+; deprecated "
42 "and forbidden in 8.x).")]] = 0x10,
43 AdtHasUpsideDownGround [[=welder::doc(
44 "Flip the ground upside down to create a "
45 "ceiling (Cata+).")]] = 0x20,
46 unk_0x40 [[=
47 welder::doc("Unknown (MoP+); seen on Firelands2.wdt before Legion.")]] =
48 0x40,
49 AdtHasHeightTexturing [[=welder::doc(
50 "Terrain shader 6: alpha maps are influenced by "
51 "the _h textures and MTXP (MoP+); also 4096-byte "
52 "uncompressed MCAL entries.")]] = 0x80,
54 welder::doc("Load _lod.adt (Legion+); implicitly sets 0x8000.")]] = 0x100,
55 HasMaid [[=welder::doc(
56 "The WDT carries MAID: ADTs load by FileDataID instead of "
57 "path (8.1.0.28294+).")]] = 0x200,
58 unk_0x400 [[=welder::doc("Unknown.")]] = 0x400,
59 unk_0x800 [[=welder::doc("Unknown.")]] = 0x800,
60 unk_0x1000 [[=welder::doc("Unknown.")]] = 0x1000,
61 unk_0x2000 [[=welder::doc("Unknown.")]] = 0x2000,
62 unk_0x4000 [[=welder::doc("Unknown.")]] = 0x4000,
63 unk_0x8000 [[=welder::doc(
64 "Affects _lod.adt rendering; implicitly set for the continent "
65 "maps (Legion+). Without it (or 0x100) distant map textures "
66 "and LOD do not render.")]] = 0x8000
67 };
68
69 /** The version-agnostic base of every SMMapHeader<V>, welded as
70 "WDTHeader".
72 This base exists ENTIRELY for the language bindings (Python, Lua): it
73 gives the per-version header classes a common welded supertype so
74 binding users can write version-agnostic code (isinstance,
75 WDTHeader.for_version(expansion)). It has no role in the C++ API, where
76 you use the concrete SMMapHeader<V> directly. It is an empty (elided)
77 base, so the binary specializations stay trivially copyable and 32 bytes. */
78 struct [[
79 =welder::weld,
80 =welder::weld_as("WDTHeader"),
82 =welder::doc("An MPHD map header, abstract over the client version. "
83 "Construct a concrete version with "
84 "WDTHeader.for_version(expansion).")
85 ]] WDTHeaderBase {};
86
90 namespace detail {
91 // The annotated era layouts; instantiate through the canonicalizing
92 // aliases below, never directly.
93 template <ClientVersion V>
94 struct SMMapHeader;
95
96 template <ClientVersion V> requires(V < WdtMapFdids)
97 struct [[
98 =welder::weld,
99 =welder::doc("The MPHD map header: the map-wide flags; the rest of the "
100 "record is unused before 8.1.")
102 [[=welder::doc("Map-wide flags; MapHeaderFlags bits.")]]
104
105 [[=welder::doc(
106 "A legacy value the WotLK-era client reads but does not use "
107 "meaningfully; zero in shipped files.")]]
108 std::uint32_t something = 0;
109
110 [[=welder::doc("Unused padding.")]]
111 std::array<std::uint32_t, 6> unused{};
112
113
114
115 };
116
117 template <ClientVersion V> requires(V >= WdtMapFdids)
118 struct [[
119 =welder::weld,
120 =welder::doc(
121 "The MPHD map header: the map-wide flags and the satellite-file "
122 "FileDataIDs (8.1+).")
124 [[=welder::doc("Map-wide flags; MapHeaderFlags bits.")]]
125 MapHeaderFlags flags{};
126
127 [[=welder::doc("FileDataID of the _lgt.wdt lights satellite, or 0.")]]
128 std::uint32_t lgtFdid = 0;
130 [[=welder::doc("FileDataID of the _occ.wdt occlusion satellite, or 0.")]]
131 std::uint32_t occFdid = 0;
132
133 [[=welder::doc(
134 "FileDataID of the _fogs.wdt volumetric-fog satellite, or 0.")]]
135 std::uint32_t fogsFdid = 0;
136
137 [[=welder::doc(
138 "FileDataID of the _mpv.wdt particulate-volume satellite, or 0.")]]
139 std::uint32_t mpvFdid = 0;
140
141 [[=welder::doc("FileDataID of the _tex.wdt texture-list satellite, or 0.")
142 ]]
143 std::uint32_t texFdid = 0;
144
145 [[=welder::doc(
146 "FileDataID of the map's .wdl low-resolution heightmap, or 0.")]]
147 std::uint32_t wdlFdid = 0;
148
149 [[=welder::doc("FileDataID of the map's .pd4 file, or 0.")]]
150 std::uint32_t pd4Fdid = 0;
151
152
154 };
155 }
160 template <ClientVersion V>
163 static_assert(sizeof(SMMapHeader<versions::Wotlk>) == 32);
164 static_assert(sizeof(SMMapHeader<versions::Shadowlands>) == 32);
165
166 // --- MAIN -------------------------------------------------------------------
167
168 enum class [[
169 =welder::weld,
170 =welder::flags,
171 =welder::doc("Tile table flag bits (SMAreaInfo.flags).")
172 ]] AreaInfoFlags : std::uint32_t {
173 HasAdt [[=welder::doc("The tile has an ADT.")]] = 0x1,
174 AllWater [[=welder::doc(
175 "The whole tile is \"fake water\" (Cataclysm+; pre-Cata "
176 "clients read this bit as their loaded flag).")]] = 0x2,
177 Loaded [[=welder::doc("Runtime-only loaded marker; zero in files.")]] = 0x4
178 };
179
180 struct [[
181 =welder::weld,
182 =welder::doc(R"(
183 One MAIN tile table entry (SMAreaInfo). The table holds 64 x 64 of
184 them in row-major order (y outer, x inner).)")
185 ]] SMAreaInfo {
186 [[=welder::doc("Tile flags; AreaInfoFlags bits.")]]
187 AreaInfoFlags flags{};
188
189 [[=welder::doc("Runtime-only async load id; zero in files.")]]
190 std::uint32_t asyncId = 0;
191 };
192
193 static_assert(sizeof(SMAreaInfo) == 8);
194
195 // --- MAID -------------------------------------------------------------------
196
197 struct [[
198 =welder::weld,
199 =welder::doc(R"(
200 One MAID per-tile FileDataID record (8.1.0.28294+): every file
201 belonging to one map tile. The table holds 64 x 64 of them in
202 row-major order (y outer, x inner); absent files are 0.)")
203 ]] MapFileDataIDs {
204 [[=welder::doc("FileDataID of mapname_xx_yy.adt (the root ADT).")]]
205 std::uint32_t rootAdt = 0;
206
207 [[=welder::doc("FileDataID of mapname_xx_yy_obj0.adt.")]]
208 std::uint32_t obj0Adt = 0;
209
210 [[=welder::doc("FileDataID of mapname_xx_yy_obj1.adt.")]]
211 std::uint32_t obj1Adt = 0;
212
213 [[=welder::doc("FileDataID of mapname_xx_yy_tex0.adt.")]]
214 std::uint32_t tex0Adt = 0;
215
216 [[=welder::doc("FileDataID of mapname_xx_yy_lod.adt.")]]
217 std::uint32_t lodAdt = 0;
218
219 [[=welder::doc("FileDataID of the mapname_xx_yy.blp map texture.")]]
220 std::uint32_t mapTexture = 0;
221
222 [[=welder::doc("FileDataID of the mapname_xx_yy_n.blp normal map texture.")]
223 ]
224 std::uint32_t mapTextureN = 0;
225
226 [[=welder::doc("FileDataID of the mapxx_yy.blp minimap texture.")]]
227 std::uint32_t minimapTexture = 0;
228 };
229
230 static_assert(sizeof(MapFileDataIDs) == 32);
231}
Client version identity, the flavor axis that separates a client's CONTENT version from the engine ge...
Flag-testing convenience for the binary formats' bit-mask enums.
Binding-language identities welder's core does not name.
#define WOWLIB_CS_FAMILY_SURFACE
The C# rod's family-surface opt-in, spellable in every build.
Definition lang.hpp:44
The 32-byte MPHD map header.
Definition header.hpp:61
WDT main-file chunk binary structs (the MPHD map header, MAIN tile table, MAID FileDataIDs) and their...
Definition header.hpp:20
MapHeaderFlags
Map header flag bits (SMMapHeader.flags).
Definition header.hpp:24
@ AdtHasUpsideDownGround
Flip the ground upside down to create a ceiling (Cata+).
Definition header.hpp:30
@ unk_0x8000
Affects _lod.adt rendering; implicitly set for the continent maps (Legion+).
Definition header.hpp:41
@ UsesGlobalMapObj
A WMO-only map: one global map object (MWMO/MODF), no terrain tiles.
Definition header.hpp:25
@ unk_0x40
Unknown (MoP+); seen on Firelands2.wdt before Legion.
Definition header.hpp:31
@ AdtHasBigAlpha
Terrain shader 2 (_env): 4096-byte uncompressed MCAL alpha maps instead of 2048.
Definition header.hpp:27
@ HasMaid
The WDT carries MAID: ADTs load by FileDataID instead of path (8.1.0.28294+).
Definition header.hpp:35
@ AdtHasMclv
ADTs carry the second MCLV color layer (Cata+; deprecated and forbidden in 8.x).
Definition header.hpp:29
@ AdtHasMccv
ADTs carry MCCV vertex colors (WotLK+); with this set every ADT of the map must have MCCV.
Definition header.hpp:26
@ LoadLodAdt
Load _lod.adt (Legion+); implicitly sets 0x8000.
Definition header.hpp:34
@ AdtHasHeightTexturing
Terrain shader 6: alpha maps are influenced by the _h textures and MTXP (MoP+); also 4096-byte uncomp...
Definition header.hpp:33
@ AdtHasDoodadrefsSortedBySizeCat
ADT MCRF/MCRD doodad references are sorted by size category.
Definition header.hpp:28
AreaInfoFlags
Tile table flag bits (SMAreaInfo.flags).
Definition header.hpp:127
@ AllWater
The whole tile is "fake water" (Cataclysm+; pre-Cata clients read this bit as their loaded flag).
Definition header.hpp:129
@ Loaded
Runtime-only loaded marker; zero in files.
Definition header.hpp:130
detail::SMMapHeader< canonicalVersion(V, WdtHeaderPivots, WdtVersions)> SMMapHeader
The MPHD header — the canonicalizing face of detail::SMMapHeader (WdtHeaderPivots: the FileDataID rel...
Definition header.hpp:119
constexpr std::array WdtHeaderPivots
SMMapHeader: the MPHD FileDataID relayout.
constexpr std::array WdtVersions
The versions WDT is instantiated (and welded) for: every targeted last-minor-of-major release,...
constexpr ClientVersion WdtMapFdids
8.1.0.28294: the MPHD unused tail becomes the satellite FileDataIDs and MAID arrives — the namehash-r...
constexpr ClientVersion canonicalVersion(ClientVersion v, std::span< const ClientVersion > pivots, std::span< const ClientVersion > grid)
The canonical version v collapses to: the FIRST grid version in v's range.
std::uint32_t tex0Adt
FileDataID of mapname_xx_yy_tex0.adt.
Definition header.hpp:156
std::uint32_t obj1Adt
FileDataID of mapname_xx_yy_obj1.adt.
Definition header.hpp:153
std::uint32_t lodAdt
FileDataID of mapname_xx_yy_lod.adt.
Definition header.hpp:159
std::uint32_t obj0Adt
FileDataID of mapname_xx_yy_obj0.adt.
Definition header.hpp:150
std::uint32_t mapTexture
FileDataID of the mapname_xx_yy.blp map texture.
Definition header.hpp:162
std::uint32_t rootAdt
FileDataID of mapname_xx_yy.adt (the root ADT).
Definition header.hpp:147
AreaInfoFlags flags
Tile flags; AreaInfoFlags bits.
Definition header.hpp:135
std::uint32_t asyncId
Runtime-only async load id; zero in files.
Definition header.hpp:138
The version-agnostic base of every SMMapHeader<V>, welded as "WDTHeader".
Definition header.hpp:56
std::uint32_t occFdid
FileDataID of the _occ.wdt occlusion satellite, or 0.
Definition header.hpp:93
std::uint32_t wdlFdid
FileDataID of the map's .wdl low-resolution heightmap, or 0.
Definition header.hpp:105
std::uint32_t fogsFdid
FileDataID of the _fogs.wdt volumetric-fog satellite, or 0.
Definition header.hpp:96
std::uint32_t texFdid
FileDataID of the _tex.wdt texture-list satellite, or 0.
Definition header.hpp:102
std::uint32_t something
A legacy value the WotLK-era client reads but does not use meaningfully; zero in shipped files.
Definition header.hpp:74
std::uint32_t pd4Fdid
FileDataID of the map's .pd4 file, or 0.
Definition header.hpp:108
std::array< std::uint32_t, 6 > unused
Unused padding.
Definition header.hpp:77
MapHeaderFlags flags
Map-wide flags; MapHeaderFlags bits.
Definition header.hpp:71
std::uint32_t mpvFdid
FileDataID of the _mpv.wdt particulate-volume satellite, or 0.
Definition header.hpp:99
std::uint32_t lgtFdid
FileDataID of the _lgt.wdt lights satellite, or 0.
Definition header.hpp:90
The binary-level math and color primitives shared across WoW file formats (wowdev....
#define WOWLIB_EMPTY_BASES
Empty-base optimization for a binary struct that carries a (welded, empty) facade base: gcc/clang alw...
Definition types.hpp:24
WDT version grids and per-family canonicalization pivots.