Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
LegacySequence.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "LegacyChunk.hpp"
4
5#include <cstddef>
6#include <cstdint>
7#include <array>
8#include <expected>
9#include <optional>
10#include <span>
11#include <string>
12#include <string_view>
13#include <variant>
14#include <vector>
15
16namespace monopoly::data
17{
31
33 {
35 std::size_t offset{};
36 std::string detail;
37 std::optional<ChunkError> chunkError;
38 };
39
40 [[nodiscard]] std::string_view sequenceErrorCodeName(
41 SequenceErrorCode code) noexcept;
42
43 inline constexpr std::size_t LegacySequenceHeaderSize = 12;
44
45 // Representation decodee de LE_SEQNCR_SequenceChunkHeaderRecord.
46 // Ce contrat de lecture ne certifie pas qu'une sequence est executable :
47 // endTime=0 (infini), timeMultiple=0, endingAction 0..7 et reserved sont
48 // conserves tels quels. Le runtime source peut remplacer cadence/action.
49 // Aucun bitfield C++ ni layout natif n'est utilise pour lire le disque.
51 {
52 std::int32_t parentStartTime{};
53 std::uint8_t priority{};
54 std::int32_t endTime{};
55 std::uint8_t timeMultiple{};
56 bool dropFrames{};
57 bool lastUse{};
58 std::uint8_t endingAction{};
61 std::uint32_t reserved{};
62 };
63
64 [[nodiscard]] std::expected<LegacySequenceHeader, SequenceError>
65 decodeLegacySequenceHeader(std::span<const std::byte> bytes);
66
78 {
79 bool drawSolid{};
81 std::uint8_t alphaLevel{};
86 std::int8_t saturation{};
87 std::int8_t brightness{};
88 std::int8_t contrast{};
89 };
91 {
93 float farClipPlaneDistance{5000.0F};
94 std::uint8_t cameraLabel{};
95 };
98 struct SequenceTweekerData { std::uint8_t interpolationType{}; };
99
100 using LegacySequenceData = std::variant<
111
119
120 // Immutable values of the private positioning subchunks. These preserve
121 // the packed Win32 representation field-by-field; matrix composition is
122 // a runtime responsibility in SequenceTransforms.
125 { ChunkInfo chunk; std::int32_t x{}; std::int32_t y{}; };
127 { ChunkInfo chunk; std::array<float, 9> values{}; };
135 { ChunkInfo chunk; float x{}, y{}, z{}; };
137 { ChunkInfo chunk; std::array<float, 16> values{}; };
147 {
149 std::int32_t left{}, top{}, right{}, bottom{};
150 };
152 {
154 std::array<std::array<float, 3>, 8> points{};
155 };
174 {
176 std::uint8_t index{};
177 std::string fileName;
178 };
180
181 using LegacySequenceAttribute = std::variant<
200
202 {
203 std::vector<LegacySequenceAttribute> values;
204 // First StartupSequence scan stops at the first direct child. The
205 // second scan still consumes all following direct attributes.
206 // nullopt means no child was encountered (also for value-only fixtures).
207 std::optional<std::size_t> firstChildAttributeIndex;
208 };
209
210 // Reads all direct private attributes, skipping each child sequence's
211 // contents while preserving the first-child dimensionality boundary.
212 // The supplied reader is not mutated. Unknown attributes remain explicit so
213 // an execution layer cannot silently claim their effects are supported.
214 [[nodiscard]] std::expected<LegacySequenceAttributes, SequenceError>
216 std::size_t maximumAttributes = 256);
217
218 // Descend au prochain chunk et decode uniquement sa partie fixe prouvee :
219 // grouping(1), indirect(2), bitmap(3), model(4), sound(5), video(6),
220 // camera(7), preloader(8), mesh(9), tweeker(10).
221 // En succes, le reader reste dans ce chunk au debut des sous-chunks.
222 // En erreur, position/niveau/ownership du reader sont inchanges.
223 // Le resultat contient des valeurs, sans vue empruntee. La possession du
224 // payload reste celle du LegacyChunkReader (span ou SharedDataBytes).
225 // Les sous-chunks et l'execution/timing ne sont pas valides ici. Video,
226 // preloader et tout autre ID non liste sont explicitement refuses.
227 [[nodiscard]] std::expected<LegacySequenceRecord, SequenceError>
229
230 // Semantique du loader L_Seqncr : references relatives a l'item DAT qui
231 // contient ce record, et non a un numero de groupe fixe. Conserver aussi
232 // le DataID brut : sound notamment teste le zero AVANT ce remappage pour
233 // choisir un fichier externe (L_Seqncr.cpp:4471-4489).
238 {
239 return header.absoluteDataIds ? rawId :
241 }
242}
const char * header
std::vector< std::byte > bytes
unsigned index
std::uint32_t DataId
Definition DataBanks.hpp:10
std::expected< LegacySequenceAttributes, SequenceError > readLegacySequenceAttributes(const LegacyChunkReader &reader, std::size_t maximumAttributes)
std::variant< SequenceGroupingData, SequenceIndirectData, SequenceBitmapData, SequenceModelData, SequenceSoundData, SequenceVideoData, SequenceCameraData, SequencePreloaderData, SequenceMeshData, SequenceTweekerData > LegacySequenceData
std::expected< LegacySequenceHeader, SequenceError > decodeLegacySequenceHeader(std::span< const std::byte > bytes)
constexpr std::size_t LegacySequenceHeaderSize
std::expected< LegacySequenceRecord, SequenceError > readLegacySequenceRecord(LegacyChunkReader &reader)
constexpr DataId idWithGroupFromParent(DataId child, DataId parent) noexcept
Definition DataBanks.hpp:75
std::string_view sequenceErrorCodeName(SequenceErrorCode code) noexcept
std::variant< SequenceDimensionalityAttribute, Sequence2DOffsetAttribute, Sequence2DMatrixAttribute, Sequence2DOriginScaleRotateOffsetAttribute, Sequence3DOffsetAttribute, Sequence3DMatrixAttribute, Sequence3DOriginScaleRotateOffsetAttribute, Sequence2DBoundingBoxAttribute, Sequence3DBoundingBoxAttribute, Sequence3DBoundingSphereAttribute, Sequence3DMeshChoiceAttribute, SequenceLabelAttribute, SequenceSoundPitchAttribute, SequenceSoundVolumeAttribute, SequenceSoundPanningAttribute, SequenceCameraFieldOfViewAttribute, SequenceFileNameAttribute, SequenceUnsupportedAttribute > LegacySequenceAttribute
constexpr DataId resolveSequenceDataId(const LegacySequenceHeader &header, DataId rawId, DataId containingSequenceId) noexcept
std::optional< std::size_t > firstChildAttributeIndex
std::vector< LegacySequenceAttribute > values
std::array< std::array< float, 3 >, 8 > points
std::optional< ChunkError > chunkError