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
5
6#include <array>
7#include <cstdint>
8#include <utility>
9
10#include <welder/vocabulary.hpp>
11
13#include <wowlib/core/lang.hpp>
17
19 // --- MOGP header ------------------------------------------------------------
20
21 enum class [[
22 =welder::weld,
23 =welder::flags,
24 =welder::doc("Group flag bits (MOGP and MOGI flags).")
25 ]] GroupFlags : std::uint32_t {
26 HasBsp [[=welder::doc("Has a collision BSP tree (MOBN/MOBR).")]] = 0x1,
28 welder::doc("Has a light map (v14 legacy; unused since vanilla).")]] =
29 0x2,
30 HasVertexColors [[=welder::doc("Has vertex colors (MOCV).")]] = 0x4,
31 Exterior [[=welder::doc("Outdoor group (SMOGroup::EXTERIOR).")]] = 0x8,
32 ExteriorLit [[=welder::doc("Use exterior lighting; no local diffuse.")]] = 0x40,
33 Unreachable [[=welder::doc("Unreachable (SMOGroup::UNREACHABLE).")]] = 0x80,
35 welder::doc("Show the exterior sky inside this interior group.")]] =
36 0x100,
37 HasLights [[=welder::doc("Has light references (MOLR).")]] = 0x200,
38 Lod [[=
39 welder::doc(
40 "Legion+: an LOD group. Pre-Cata: marked the unused MPB* chunks.")]] =
41 0x400,
42 HasDoodads [[=welder::doc("Has doodad references (MODR).")]] = 0x800,
44 welder::doc("Has liquid (MLIQ), or an implicitly full volume.")]] =
45 0x1000,
46 Interior [[=welder::doc("Indoor group (SMOGroup::INTERIOR).")]] = 0x2000,
48 welder::doc("Pre-WotLK: whether mount queries are allowed.")]] = 0x8000,
49 AlwaysDraw [[=
50 welder::doc("Always draw (clears exterior after group creation).")]] =
51 0x10000,
52 HasTriangleStrips [[=welder::doc("Has triangle-strip data (MORI/MORB).")]] = 0x20000,
53 ShowSkybox [[=
54 welder::doc("Show the skybox; unset automatically when MOSB is absent.")]]
55 = 0x40000,
57 welder::doc("The liquid is ocean, not water (LiquidType handling).")]] =
58 0x80000,
59 MountAllowed [[=welder::doc("Mounting is allowed in this group.")]] = 0x200000,
61 welder::doc("Has a second MOCV layer; only its alpha is used.")]] =
62 0x1000000,
64 welder::doc("Has two MOTV texcoord sets (SMOGroup::TVERTS2).")]] =
65 0x2000000,
66 Antiportal [[=
67 welder::doc("An antiportal occluder group (SMOGroup::ANTIPORTAL).")]] =
68 0x4000000,
69 ExteriorCull [[=
70 welder::doc("Exterior culling (SMOGroup::EXTERIOR_CULL, Legion+).")]] =
71 0x20000000,
72 HasThreeMotv [[=welder::doc(
73 "Has three MOTV texcoord sets, e.g. for shader 18.")]] = 0x40000000
74 };
75
76 enum class [[
77 =welder::weld,
78 =welder::flags,
79 =welder::doc("Extended group flag bits (MOGP.flags2 and MGI2).")
80 ]] GroupFlags2 : std::uint32_t {
82 welder::doc("Has terrain-cutting portal planes (MOPL, WoD+).")]] = 0x1,
83 IsSplitGroupParent [[=welder::doc("Parent of a split group (9.2+).")]] = 0x40,
84 IsSplitGroupChild [[=welder::doc("Child of a split group (9.2+).")]] = 0x80,
85 AttachmentMesh [[=welder::doc("An attachment mesh (9.2 - 11.0).")]] = 0x100
86 };
91 This base exists ENTIRELY for the language bindings (Python, Lua): it gives
92 the per-version WMOGroupHeader* classes a common welded supertype so binding
93 users can write version-agnostic code (isinstance,
94 WMOGroupHeader.for_version(expansion)). It has no role in the C++ API, where
95 you use the concrete SMOGroupHeader<V> directly. It is an empty (elided)
96 base, so the binary specializations stay trivially copyable and 0x44 bytes. */
97 struct [[
98 =welder::weld,
99 =welder::weld_as("WMOGroupHeader"),
101 =welder::doc("A MOGP group header, abstract over the client version. "
102 "Construct a concrete version with "
103 "WMOGroupHeader.for_version(expansion).")
104 ]] WMOGroupHeaderBase {};
108 namespace detail {
109 // The annotated era layouts; instantiate through the canonicalizing
110 // aliases below, never directly.
111 template <ClientVersion V>
112 struct SMOGroupHeader;
113
114 template <ClientVersion V> requires(V < WmoSplitGroups)
115 struct [[
116 =welder::weld,
117 =welder::doc(
118 "The MOGP group header: names, flags, bounds, portal and batch "
119 "ranges, fog and liquid.")
121 [[=welder::doc("Byte offset of the group name in MOGN.")]]
122 std::uint32_t groupName = 0;
124 [[=welder::doc("Byte offset of the descriptive name in MOGN.")]]
125 std::uint32_t descriptiveGroupName = 0;
127 [[=welder::doc("Group flags; GroupFlags bits.")]]
130 [[=welder::doc("Group bounding box.")]]
133 [[=welder::doc("First portal reference in MOPR.")]]
134 std::uint16_t portalStart = 0;
136 [[=welder::doc("Portal reference count.")]]
137 std::uint16_t portalCount = 0;
138
139 [[=welder::doc("Transition batch count (MOBA prefix).")]]
140 std::uint16_t transBatchCount = 0;
141
142 [[=welder::doc("Interior batch count.")]]
143 std::uint16_t intBatchCount = 0;
144
145 [[=welder::doc("Exterior batch count.")]]
146 std::uint16_t extBatchCount = 0;
147
148 [[=welder::doc("The fourth batch-count slot; unused by clients.")]]
149 std::uint16_t batchTypeD = 0;
150
151 [[=welder::doc("Fog indices into MFOG.")]]
152 std::array<std::uint8_t, 4> fogIds{};
153
154 [[=welder::doc("Group liquid type; interpretation depends on the root "
155 "use_liquid_type_dbc_id flag.")]]
156 std::uint32_t groupLiquid = 0;
157
158 [[=welder::doc("Foreign key into WMOAreaTable (m_WMOGroupID).")]]
159 std::uint32_t uniqueId = 0;
160
161 [[=welder::doc("Extended flags (Cataclysm+); GroupFlags2 bits.")]]
162 GroupFlags2 flags2{};
163
164 [[=welder::doc(
165 "Unused up to 9.1.5 (becomes the split-group indices in 9.2+).")]]
166 std::uint32_t unused = 0;
167
168
169
170 };
171
172 template <ClientVersion V> requires(V >= WmoSplitGroups)
173 struct [[
174 =welder::weld,
175 =welder::doc(
176 "The MOGP group header: names, flags, bounds, portal and batch "
177 "ranges, fog, liquid and split-group links (9.2+).")
179 [[=welder::doc("Byte offset of the group name in MOGN.")]]
180 std::uint32_t groupName = 0;
181
182 [[=welder::doc("Byte offset of the descriptive name in MOGN.")]]
183 std::uint32_t descriptiveGroupName = 0;
184
185 [[=welder::doc("Group flags; GroupFlags bits.")]]
186 GroupFlags flags{};
188 [[=welder::doc("Group bounding box.")]]
191 [[=welder::doc("First portal reference in MOPR.")]]
192 std::uint16_t portalStart = 0;
193
194 [[=welder::doc("Portal reference count.")]]
195 std::uint16_t portalCount = 0;
196
197 [[=welder::doc("Transition batch count (MOBA prefix).")]]
198 std::uint16_t transBatchCount = 0;
199
200 [[=welder::doc("Interior batch count.")]]
201 std::uint16_t intBatchCount = 0;
202
203 [[=welder::doc("Exterior batch count.")]]
204 std::uint16_t extBatchCount = 0;
205
206 [[=welder::doc("The fourth batch-count slot; unused by clients.")]]
207 std::uint16_t batchTypeD = 0;
208
209 [[=welder::doc("Fog indices into MFOG.")]]
210 std::array<std::uint8_t, 4> fogIds{};
211
212 [[=welder::doc("Group liquid type; interpretation depends on the root "
213 "use_liquid_type_dbc_id flag.")]]
214 std::uint32_t groupLiquid = 0;
215
216 [[=welder::doc("Foreign key into WMOAreaTable (m_WMOGroupID).")]]
217 std::uint32_t uniqueId = 0;
218
219 [[=welder::doc("Extended flags (Cataclysm+); GroupFlags2 bits.")]]
220 GroupFlags2 flags2{};
221
222 [[=welder::doc(
223 "Parent split group, or the first child (9.2+ split groups).")]]
224 std::int16_t parentOrFirstChildSplitGroupIndex = -1;
225
226 [[=welder::doc("Next sibling in the split-group chain.")]]
227 std::int16_t nextSplitChildGroupIndex = -1;
228
229
230
231 };
232 }
233
237 template <ClientVersion V>
238 using SMOGroupHeader = detail::SMOGroupHeader<canonicalVersion(V, WmoGroupHeaderPivots, WmoVersions)>;
239
240
241 static_assert(sizeof(SMOGroupHeader<versions::Wotlk>) == 0x44);
242 static_assert(sizeof(SMOGroupHeader<versions::Shadowlands>) == 0x44);
243}
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
WMO group-file chunk binary structs (the MOGP header, render batches, BSP nodes, group lights) and th...
Definition geometry.hpp:18
GroupFlags
Group flag bits (MOGP and MOGI flags).
Definition header.hpp:22
@ MountAllowed
Mounting is allowed in this group.
Definition header.hpp:47
@ Antiportal
An antiportal occluder group (SMOGroup::ANTIPORTAL).
Definition header.hpp:52
@ HasTwoMotv
Has two MOTV texcoord sets (SMOGroup::TVERTS2).
Definition header.hpp:50
@ ShowExteriorSky
Show the exterior sky inside this interior group.
Definition header.hpp:30
@ HasTriangleStrips
Has triangle-strip data (MORI/MORB).
Definition header.hpp:42
@ ExteriorCull
Exterior culling (SMOGroup::EXTERIOR_CULL, Legion+).
Definition header.hpp:54
@ HasTwoMocv
Has a second MOCV layer; only its alpha is used.
Definition header.hpp:48
@ Unreachable
Unreachable (SMOGroup::UNREACHABLE).
Definition header.hpp:29
@ AlwaysDraw
Always draw (clears exterior after group creation).
Definition header.hpp:40
@ HasBsp
Has a collision BSP tree (MOBN/MOBR).
Definition header.hpp:23
@ HasLightMap
Has a light map (v14 legacy; unused since vanilla).
Definition header.hpp:24
@ ShowSkybox
Show the skybox; unset automatically when MOSB is absent.
Definition header.hpp:43
@ HasLiquid
Has liquid (MLIQ), or an implicitly full volume.
Definition header.hpp:36
@ HasVertexColors
Has vertex colors (MOCV).
Definition header.hpp:26
@ HasLights
Has light references (MOLR).
Definition header.hpp:32
@ HasThreeMotv
Has three MOTV texcoord sets, e.g.
Definition header.hpp:56
@ Exterior
Outdoor group (SMOGroup::EXTERIOR).
Definition header.hpp:27
@ HasDoodads
Has doodad references (MODR).
Definition header.hpp:35
@ ExteriorLit
Use exterior lighting; no local diffuse.
Definition header.hpp:28
@ Interior
Indoor group (SMOGroup::INTERIOR).
Definition header.hpp:38
@ QueryMountAllowed
Pre-WotLK: whether mount queries are allowed.
Definition header.hpp:39
@ Ocean
The liquid is ocean, not water (LiquidType handling).
Definition header.hpp:45
detail::SMOGroupHeader< canonicalVersion(V, WmoGroupHeaderPivots, WmoVersions)> SMOGroupHeader
The MOGP header — the canonicalizing face of detail::SMOGroupHeader (WmoGroupHeaderPivots: the split-...
Definition header.hpp:201
GroupFlags2
Extended group flag bits (MOGP.flags2 and MGI2).
Definition header.hpp:60
@ IsSplitGroupParent
Parent of a split group (9.2+).
Definition header.hpp:62
@ AttachmentMesh
An attachment mesh (9.2 - 11.0).
Definition header.hpp:64
@ IsSplitGroupChild
Child of a split group (9.2+).
Definition header.hpp:63
@ CanCutTerrain
Has terrain-cutting portal planes (MOPL, WoD+).
Definition header.hpp:61
constexpr ClientVersion WmoSplitGroups
9.2.0.42423: the unused u32 at MOGP+0x40 becomes the two split-group indices.
constexpr std::array WmoGroupHeaderPivots
SMOGroupHeader: the split-group indices replacing the unused u32.
constexpr std::array WmoVersions
The versions WMO is instantiated (and welded) for: every targeted last-minor-of-major release,...
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.
An axis-aligned bounding box: minimum and maximum corners.
Definition types.hpp:134
The version-agnostic base of every SMOGroupHeader<V>, welded as "WMOGroupHeader".
Definition header.hpp:79
std::int16_t parentOrFirstChildSplitGroupIndex
Parent split group, or the first child (9.2+ split groups).
Definition header.hpp:187
std::uint32_t uniqueId
Foreign key into WMOAreaTable (m_WMOGroupID).
Definition header.hpp:129
GroupFlags2 flags2
Extended flags (Cataclysm+); GroupFlags2 bits.
Definition header.hpp:132
std::int16_t nextSplitChildGroupIndex
Next sibling in the split-group chain.
Definition header.hpp:190
GroupFlags flags
Group flags; GroupFlags bits.
Definition header.hpp:99
std::uint32_t groupName
Byte offset of the group name in MOGN.
Definition header.hpp:93
std::uint32_t unused
Unused up to 9.1.5 (becomes the split-group indices in 9.2+).
Definition header.hpp:135
std::uint16_t transBatchCount
Transition batch count (MOBA prefix).
Definition header.hpp:111
std::uint32_t descriptiveGroupName
Byte offset of the descriptive name in MOGN.
Definition header.hpp:96
std::array< std::uint8_t, 4 > fogIds
Fog indices into MFOG.
Definition header.hpp:123
std::uint32_t groupLiquid
Group liquid type; interpretation depends on the root use_liquid_type_dbc_id flag.
Definition header.hpp:126
std::uint16_t portalStart
First portal reference in MOPR.
Definition header.hpp:105
std::uint16_t batchTypeD
The fourth batch-count slot; unused by clients.
Definition header.hpp:120
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
WMO version pivots that change a binary-struct layout (not just chunk presence).