Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
ExtendedInitialization.cpp
Go to the documentation of this file.
2
3#include "Display.hpp"
5#include "PlayerSelection.hpp"
6#include "Messaging.hpp"
7#include "RulesEngine.hpp"
8#include "RuntimeState.hpp"
10#include "Timers.hpp"
11#include "TimeStep.hpp"
12#include "UserInterface.hpp"
13#include "UDUtils.hpp"
14#include "UIMessages.hpp"
15
16#include <iostream>
17
19{
20 namespace
21 {
23
24 void stopGameTimer()
25 {
26 (void)timers::configure(0, 0, 0, false, 0);
28 }
29 }
30
31
33 {
34 const auto* paths = udutils::resourcePaths();
35 if (paths == nullptr)
36 {
37 std::cerr << "Resource paths have not been initialized.\n";
38 return false;
39 }
41 }
42
43
45 const data::ResourcePaths& paths, data::ResourceContext context)
46 {
47 // Userifce.cpp : DATA core puis LANG, obligatoirement avant MESS.
48 // Modern loose payloads are layered before LANG validation so the
49 // catalog and every runtime consumer observe the same logical source.
50 std::vector<data::DataSourceOverride> overrides;
51 if (const auto manifest = dataOverrideManifest())
52 {
54 if (!loaded)
55 {
56 const auto& error = loaded.error();
57 const auto utf8Path = error.path.u8string();
58 std::cerr << "DATA override loading failed ["
59 << data::dataErrorCodeName(error.code) << "] "
60 << std::string(utf8Path.begin(), utf8Path.end())
61 << ": " << error.detail << '\n';
62 return false;
63 }
64 overrides = std::move(*loaded);
65 }
66
67 auto initialized = resourceRuntime.initialize(
68 paths,
69 context,
70 {},
71 std::span<const data::DataSourceOverride>{overrides});
72 if (!initialized)
73 {
74 const auto& error = initialized.error();
75 const auto utf8Path = error.path.u8string();
76 std::cerr << "Resources initialization failed ["
77 << data::dataErrorCodeName(error.code) << "] "
78 << std::string(utf8Path.begin(), utf8Path.end())
79 << ": " << error.detail << '\n';
80 return false;
81 }
82
83 // Le miroir UI global et le marqueur de première notification sont
84 // réarmés à chaque démarrage moderne.
86
87 // ====================================================
88 // Prochaines étapes originales, encore à porter :
89 //
90 // LE_FONTS_SetFont()
91 // LE_FONTS_SetSize(10)
92 //
93 // CHAT_InitializeSystem()
94 //
95 // MESS_InitializeSystem()
96 // ====================================================
97
98
99 // ====================================================
100 // MAIN_GAME_TIMER original
101 //
102 // #define MAIN_GAME_TIMER 0
103 //
104 // LE_TimerSpeeds[0] = 2;
105 // LE_TimerRestartCount[0] = 1;
106 // LE_TimerSendUIMessage[0] = TRUE;
107 // LE_Timers[0] = 1;
108 // ====================================================
109
110 // MESS_InitializeSystem();
112 {
114 return false;
115 }
116
118
120 0, // MAIN_GAME_TIMER
121 2, // speed
122 1, // restart count
123 true, // send UI message
124 1)) // actif immédiatement
125 {
128 return false;
129 }
130
131
132 // ====================================================
133 // Etat global original
134 // ====================================================
135
137
138 // DISPLAY_initialize();
139 if (!display::initialize())
140 {
143 return false;
144 }
145
146 // RULE_InitializeSystem();
147 if (!rules::initialize())
148 {
152 return false;
153 }
154
155
156 // ====================================================
157 // MESS_StartNetworking() original se trouve ici.
158 //
159 // Application installs the optional TCP voice session after this local
160 // startup and before the first cycle. Without explicit endpoint options,
161 // MESS stays local. DirectPlay/lobby and remote player admission are absent.
162
163 // #if !USE_OPENING_MOVIES
164 //
165 // UDBOARD_SetBackdrop(DISPLAY_SCREEN_Pselect);
166 // UDPSEL_SwitchPhase(UDPSEL_PHASE_HISCORE);
167
170 );
171
174 );
175
176 // Suite exacte de la fonction originale :
177 //
178 // DISPLAY_initialize()
179 //
180 // RULE_InitializeSystem()
181 //
182 // MESS_StartNetworking(...)
183 //
184 // puis écran initial :
185 //
186 // UDBOARD_SetBackdrop(DISPLAY_SCREEN_Pselect);
187 // UDPSEL_SwitchPhase(UDPSEL_PHASE_HISCORE);
188 //
189 // Ces éléments seront portés dans cet ordre.
190 // ====================================================
191
192 return true;
193 }
194
195
197 {
199 // GameShutdown() original commence par DISPLAY_destroy(), avant de
200 // detruire les ressources auxquelles les modules UD font reference.
202
207 }
208
209
210 std::shared_ptr<const data::ResourceSnapshot> resources() noexcept
211 {
212 return resourceRuntime.snapshot();
213 }
214
215
217 {
218 resourceRuntime.shutdown();
219 }
220}
221
222
223
unsigned index
std::string error
std::string_view dataErrorCodeName(DataErrorCode code) noexcept
std::expected< std::vector< DataSourceOverride >, DataError > loadLooseDataOverrides(const std::filesystem::path &manifestPath)
void setBackdrop(Screen2D screen)
Definition Display.cpp:363
void switchPhase(display::PlayerSetupPhase phase)
data::ResourceContext resourceContext() noexcept
std::shared_ptr< const data::ResourceSnapshot > resources() noexcept
std::optional< std::filesystem::path > dataOverrideManifest()
bool configure(std::size_t index, std::uint8_t speed, std::uint16_t restartCount, bool sendUIMessage, std::uint16_t value)
Definition Timers.cpp:124
const data::ResourcePaths * resourcePaths() noexcept
Definition UDUtils.cpp:77
std::size_t discardTimerEvents(std::size_t timerIndex)