Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
DataBanks.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <cstdint>
6#include <string_view>
7
8namespace monopoly::data
9{
10 using DataId = std::uint32_t;
11 using DataTag = std::uint16_t;
12
13 inline constexpr DataId EmptyDataId = 0;
14
15
16 // Valeurs de groupes utilisées par Source/monopoly/GameInc.h.
17 enum class LegacyGroupId : std::uint16_t
18 {
19 Main = 2,
20 Patterns = 3,
22 Board = 6,
23 Board2 = 7,
24 ThreeD = 8,
25 LanguageText = 9,
27 };
28
29
30 [[nodiscard]] constexpr std::uint16_t legacyGroupValue(
31 LegacyGroupId group) noexcept
32 {
33 return static_cast<std::uint16_t>(group);
34 }
35
36
37 // Contrat LE_DATA_IdFromTag : groupe sur les 16 bits hauts,
38 // tag de l'item sur les 16 bits bas.
40 std::uint16_t group,
41 DataTag tag) noexcept
42 {
43 return
44 (static_cast<DataId>(group) << 16U) |
45 static_cast<DataId>(tag);
46 }
47
48
51 DataTag tag) noexcept
52 {
53 return packDataId(legacyGroupValue(group), tag);
54 }
55
56
57 [[nodiscard]] constexpr std::uint16_t dataGroup(
58 DataId id) noexcept
59 {
60 return static_cast<std::uint16_t>(id >> 16U);
61 }
62
63
64 [[nodiscard]] constexpr DataTag dataTag(
65 DataId id) noexcept
66 {
67 return static_cast<DataTag>(id & 0xFFFFU);
68 }
69
70
71 // Contrat LE_DATA_IdWithFileFromParent : conserve le tag de l'enfant,
72 // mais resout son groupe dans le meme fichier que le parent. Ce helper
73 // est notamment utilise par le sequenceur historique pour ses references
74 // indirectes.
77 DataId parent) noexcept
78 {
79 return packDataId(dataGroup(parent), dataTag(child));
80 }
81
82
83 [[nodiscard]] constexpr bool isEmptyDataId(
84 DataId id) noexcept
85 {
86 return id == EmptyDataId;
87 }
88
89
90 enum class BoardEdition
91 {
92 Usa,
93 Europe
94 };
95
96
97 enum class BankId
98 {
99 Main,
100 Patterns,
101 Board,
102 Board2,
103 ThreeD,
107 };
108
109
111 {
114 std::string_view legacyPath;
115 };
116
117
118 inline constexpr std::size_t CoreBankCount = 5;
120 std::array<BankDefinition, CoreBankCount>;
121
122
124 BoardEdition edition) noexcept;
125
126 // Alias conservé pour le caller actuel, qui représente le build
127 // historique USA_VERSION = 1.
129
130
132 {
133 EnglishUs = 1,
134 EnglishUk = 2,
135 French = 3,
136 German = 4,
137 Spanish = 5,
138 Dutch = 6,
139 Swedish = 7,
140 Finnish = 8,
141 Danish = 9,
142 Norwegian = 10
143 };
144
145
153
154
155 inline constexpr std::size_t LanguageCount = 10;
157 std::array<LanguageBankTriplet, LanguageCount>;
158
159
162
165}
std::uint16_t group
unsigned index
std::uint32_t DataId
Definition DataBanks.hpp:10
constexpr DataId EmptyDataId
Definition DataBanks.hpp:13
constexpr DataTag dataTag(DataId id) noexcept
Definition DataBanks.hpp:64
std::uint16_t DataTag
Definition DataBanks.hpp:11
constexpr std::uint16_t legacyGroupValue(LegacyGroupId group) noexcept
Definition DataBanks.hpp:30
constexpr std::size_t LanguageCount
constexpr bool isEmptyDataId(DataId id) noexcept
Definition DataBanks.hpp:83
const LanguageBankTriplet * findLanguageBankTriplet(LanguageId language) noexcept
constexpr DataId idWithGroupFromParent(DataId child, DataId parent) noexcept
Definition DataBanks.hpp:75
std::array< BankDefinition, CoreBankCount > CoreBankDefinitions
std::array< LanguageBankTriplet, LanguageCount > LanguageBankTriplets
constexpr std::size_t CoreBankCount
const LanguageBankTriplets & languageBankTriplets() noexcept
const CoreBankDefinitions & legacyBanks() noexcept
constexpr DataId packDataId(std::uint16_t group, DataTag tag) noexcept
Definition DataBanks.hpp:39
const CoreBankDefinitions & coreBanks(BoardEdition edition) noexcept
constexpr std::uint16_t dataGroup(DataId id) noexcept
Definition DataBanks.hpp:57