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 <algorithm>
7#include <array>
8#include <cstdint>
9#include <string_view>
10#include <utility>
11
12#include <welder/vocabulary.hpp>
13
16
18 // --- MOHD -------------------------------------------------------------------
19
20 enum class [[
21 =welder::weld,
22 =welder::flags,
23 =welder::doc("Root header flag bits (SMOHeader.flags).")
24 ]] HeaderFlags : std::uint16_t {
26 welder::doc("Do not attenuate vertices based on portal distance.")]] =
27 0x1,
29 welder::doc("Attenuate on portal exit (unified render path).")]] = 0x2,
31 welder::doc("MLIQ ids are LiquidType foreign keys, not the legacy set.")]]
32 = 0x4,
34 welder::doc("Skip the vertex-color alpha fixup (FixColorVertexAlpha).")]]
35 = 0x8,
36 Lod [[=welder::doc("The WMO has LOD group files (Legion+).")]] = 0x10,
37 DefaultMaxLod [[=welder::doc(
38 "num_lod is defaulted, implying 3 LOD levels (BfA+).")]] = 0x20
39 };
40
41 struct [[
42 =welder::weld,
43 =welder::doc(
44 "The MOHD root header: entity counts, ambient color, bounds and "
45 "root-wide flags.")
46 ]] SMOHeader {
47 // Three of the seven counts are DERIVED binary fields: WMORoot::patchChunk
48 // stamps nGroups/nPortals/nDoodadSets from the owning tables on write
49 // and the bindings hide them — the containers are the single source of
50 // truth (surveyed across both test clients: every file agrees). The other
51 // four counts are NOT derivable — real client files store legacy values
52 // their containers do not reproduce — so they stay ordinary stored
53 // fields, preserved verbatim for the byte-perfect round-trip.
54
55 [[=welder::doc("Number of textures. NOT derived: hundreds of client files "
56 "store more than the MOTX entry count (exporter-era "
57 "duplicates), and 8.3+ FileDataID-era files keep a legacy "
58 "value with no MOTX at all; preserved as stored.")]]
59 std::uint32_t nTextures = 0;
60
61 [[=welder::mark::exclude,
62 =welder::doc("Number of group files; derived from the MOGI group-info "
63 "table on write and hidden from bindings.")]]
64 std::uint32_t nGroups = 0;
66 [[=welder::mark::exclude,
67 =welder::doc("Number of portals; derived from the MOPT table on write "
68 "and hidden from bindings.")]]
69 std::uint32_t nPortals = 0;
70
71 [[=welder::doc("Number of lights (MOLT). NOT derived: a handful of 8.x "
72 "files store a different count (extra non-MOLT lights); "
73 "preserved as stored.")]]
74 std::uint32_t nLights = 0;
75
76 [[=welder::doc("Number of doodad filenames. Matches the MODN entry count "
77 "pre-8.3, but FileDataID-era files keep a legacy value "
78 "unrelated to MODI's length; preserved as stored.")]]
79 std::uint32_t nDoodadNames = 0;
80
81 [[=welder::doc("Number of doodad placements (MODD). NOT derived: many "
82 "client files store an inflated legacy count; preserved "
83 "as stored.")]]
84 std::uint32_t nDoodadDefs = 0;
85
86 [[=welder::mark::exclude,
87 =welder::doc("Number of doodad sets; derived from the MODS table on "
88 "write and hidden from bindings.")]]
89 std::uint32_t nDoodadSets = 0;
90
91 [[=welder::doc("Base ambient color.")]]
93
94 [[=welder::doc("Foreign key into WMOAreaTable (m_WMOID).")]]
95 std::uint32_t wmoId = 0;
96
97 [[=welder::doc("Bounding box of the whole object in model space.")]]
98 CAaBox boundingBox{};
99
100 [[=welder::doc("Root-wide flags; HeaderFlags bits.")]]
101 HeaderFlags flags{};
102
103 [[=welder::doc(
104 "Number of LOD levels including the base (Legion+; zero before).")]]
105 std::uint16_t numLod = 0;
106 };
107
108 static_assert(sizeof(SMOHeader) == 0x40);
109}
Flag-testing convenience for the binary formats' bit-mask enums.
WMO root-file chunk binary structs (MOHD, MOMT, lights, doodads, fog, ambient volumes) and their flag...
Definition doodad.hpp:17
HeaderFlags
Root header flag bits (SMOHeader.flags).
Definition header.hpp:21
@ DoNotAttenuateVertices
Do not attenuate vertices based on portal distance.
Definition header.hpp:22
@ UseUnifiedRenderPath
Attenuate on portal exit (unified render path).
Definition header.hpp:24
@ Lod
The WMO has LOD group files (Legion+).
Definition header.hpp:29
@ DoNotFixVertexColorAlpha
Skip the vertex-color alpha fixup (FixColorVertexAlpha).
Definition header.hpp:27
@ DefaultMaxLod
num_lod is defaulted, implying 3 LOD levels (BfA+).
Definition header.hpp:30
@ UseLiquidTypeDbcId
MLIQ ids are LiquidType foreign keys, not the legacy set.
Definition header.hpp:25
An axis-aligned bounding box: minimum and maximum corners.
Definition types.hpp:134
A color stored as r, g, b, a bytes.
Definition types.hpp:164
The MOHD root header: entity counts, ambient color, bounds and root-wide flags.
Definition header.hpp:34
CArgb ambientColor
Base ambient color.
Definition header.hpp:65
std::uint32_t nTextures
Number of textures.
Definition header.hpp:44
std::uint32_t nDoodadDefs
Number of doodad placements (MODD).
Definition header.hpp:59
HeaderFlags flags
Root-wide flags; HeaderFlags bits.
Definition header.hpp:74
std::uint32_t nDoodadNames
Number of doodad filenames.
Definition header.hpp:56
std::uint16_t numLod
Number of LOD levels including the base (Legion+; zero before).
Definition header.hpp:77
std::uint32_t nDoodadSets
Number of doodad sets; derived from the MODS table on write and hidden from bindings.
Definition header.hpp:62
std::uint32_t nGroups
Number of group files; derived from the MOGI group-info table on write and hidden from bindings.
Definition header.hpp:47
std::uint32_t nPortals
Number of portals; derived from the MOPT table on write and hidden from bindings.
Definition header.hpp:50
std::uint32_t wmoId
Foreign key into WMOAreaTable (m_WMOID).
Definition header.hpp:68
std::uint32_t nLights
Number of lights (MOLT).
Definition header.hpp:53
CAaBox boundingBox
Bounding box of the whole object in model space.
Definition header.hpp:71
The binary-level math and color primitives shared across WoW file formats (wowdev....