LeviLamina
Loading...
Searching...
No Matches
ServerInstance.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/application/AppPlatformListener.h"
7#include "mc/deps/application/LowMemorySeverity.h"
8#include "mc/deps/core/file/LevelStorageState.h"
9#include "mc/deps/core/file/StorageAreaStateListener.h"
10#include "mc/deps/core/threading/Async.h"
11#include "mc/deps/core/utility/EnableNonOwnerReferences.h"
12#include "mc/deps/core/utility/NonOwnerPointer.h"
13#include "mc/deps/core/utility/ServiceRegistrationToken.h"
14#include "mc/deps/core/utility/UniqueOwnerPointer.h"
15#include "mc/deps/ecs/gamerefs_entity/EntityContext.h"
16#include "mc/deps/game_refs/OwnerPtr.h"
17#include "mc/network/ConnectionDefinition.h"
18#include "mc/network/connection/DisconnectFailReason.h"
19#include "mc/platform/brstd/move_only_function.h"
20#include "mc/server/ServerGraphicsSettings.h"
21#include "mc/server/ServerInstanceInitArguments.h"
22#include "mc/server/commands/CommandsRegistryConfiguration.h"
23#include "mc/world/GameCallbacks.h"
24#include "mc/world/level/LevelSettings.h"
25#include "mc/world/level/storage/Experiments.h"
26
27// auto generated forward declare list
28// clang-format off
29class AppPlatform;
30class CDNConfig;
34class ILevel;
37class ItemRegistry;
38class KeyManager;
39class LevelData;
40class LevelStorage;
44class Minecraft;
46class Scheduler;
49class ServerLevel;
54class Timer;
63namespace Core { class FileStorageArea; }
64namespace Editor { class IEditorManager; }
65namespace Scripting { class RegistryManager; }
66namespace ServerInitialization { class IServerInitializer; }
67namespace ServerInitialization { struct ServerInitResult; }
68namespace ServerInstanceMessenger { class IMessenger; }
69namespace br::worldgen { class StructureSetRegistry; }
70namespace cereal { struct ReflectionCtx; }
71// clang-format on
72
73class ServerInstance : public ::Bedrock::EnableNonOwnerReferences,
75 public ::GameCallbacks,
77public:
78 // ServerInstance inner types declare
79 // clang-format off
82 struct PostLevelArgs;
83 struct LevelInitArgs;
84 // clang-format on
85
86 // ServerInstance inner types define
87 enum class InstanceState : int {
88 Running = 0,
89 Suspended = 1,
90 WaitingLeaveGame = 2,
91 Stopped = 3,
92 NotStarted = 4,
93 };
94
95 struct CreateServerLevelOps {
96 public:
97 // CreateServerLevelOps inner types define
98 using CreateDimensionFactoryCallback =
100 ::Bedrock::NotNullNonOwnerPtr<::ILevel>,
102 ) const>;
103
104 public:
105 // member variables
106 // NOLINTBEGIN
107 ::ll::TypedStorage<8, 8, ::ServerInstance&> mInstance;
108 ::ll::TypedStorage<1, 1, bool> mServerAuthSound;
109 ::ll::TypedStorage<8, 8, ::IMinecraftEventing&> mEventing;
110 ::ll::TypedStorage<8, 8, ::ResourcePackManager&> mClientResourcePackManager;
111 ::ll::TypedStorage<
112 8,
113 64,
115 ::Bedrock::NotNullNonOwnerPtr<::ILevel>,
117 ) const>>
118 mCreateDimensionFactoryAndManager;
119 // NOLINTEND
120
121 public:
122 // prevent constructor by default
123 CreateServerLevelOps& operator=(CreateServerLevelOps const&);
124 CreateServerLevelOps(CreateServerLevelOps const&);
125 CreateServerLevelOps();
126 };
127
128 struct NetworkToggleOptions {
129 public:
130 // member variables
131 // NOLINTBEGIN
132 ::ll::TypedStorage<8, 8, ::AppPlatform const&> mPlatform;
133 ::ll::TypedStorage<1, 1, bool> mDisableLanSignaling;
134 ::ll::TypedStorage<1, 1, bool> mIsServerVisibleToLanDiscovery;
135 ::ll::TypedStorage<1, 1, bool> mEnablePacketRateLimiting;
136 ::ll::TypedStorage<8, 8, ::ConnectionDefinition const&> mConnectionDefinition;
137 // NOLINTEND
138
139 public:
140 // prevent constructor by default
141 NetworkToggleOptions& operator=(NetworkToggleOptions const&);
142 NetworkToggleOptions(NetworkToggleOptions const&);
143 NetworkToggleOptions();
144 };
145
146 struct PostLevelArgs {
147 public:
148 // member variables
149 // NOLINTBEGIN
150 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerLevel>> mLevel;
151 ::ll::TypedStorage<8, 72, ::Experiments> mExperiments;
152 ::ll::TypedStorage<8, 1344, ::LevelSettings> mLevelSettings;
153 ::ll::TypedStorage<8, 8, ::ResourcePackManager&> mClientResourcePackManager;
154 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository>> mResourcePackRepository;
155 ::ll::TypedStorage<8, 104, ::std::optional<::CommandsRegistryConfiguration const>>
156 mCommandsRegistryConfiguration;
157 ::ll::TypedStorage<4, 20, ::ConnectionDefinition> mConnectionDefinition;
158 ::ll::TypedStorage<8, 32, ::OwnerPtr<::EntityContext>> mLevelEntityContext;
159 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ScriptPackSettingsCache>> mPackSettingsCache;
160 ::ll::TypedStorage<1, 1, bool> mEnableItemStackNetManager;
161 ::ll::TypedStorage<
162 8,
163 64,
165 mHostMultiplayer;
166 // NOLINTEND
167
168 public:
169 // prevent constructor by default
170 PostLevelArgs& operator=(PostLevelArgs const&);
171 PostLevelArgs(PostLevelArgs const&);
172 PostLevelArgs();
173 };
174
176 public:
177 // member variables
178 // NOLINTBEGIN
179 ::ll::TypedStorage<8, 32, ::std::string> mLevelName;
180 ::ll::TypedStorage<
181 8,
182 64,
183 ::std::unordered_map<::std::string, ::std::unique_ptr<::BiomeJsonDocumentGlueResolvedBiomeData>>>
184 mBiomeIdToResolvedData;
185 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ServerInstance::PostLevelArgs>> mPost;
186 // NOLINTEND
187 };
188
189public:
190 // member variables
191 // NOLINTBEGIN
192 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastSyncTime;
193 ::ll::TypedStorage<1, 1, bool const> mIsDedicatedServer;
194 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Minecraft>> mMinecraft;
195 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ServerNetworkSystem>> mNetwork;
196 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LoopbackPacketSender>> mPacketSender;
197 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Timer>> mSimTimer;
198 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Timer>> mRealTimer;
199 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scheduler>> mScheduler;
200 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::EducationOptions>> mEducationOptions;
201 ::ll::TypedStorage<8, 8, ::LevelStorage*> mStorage;
202 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mInUpdate;
203 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mWriteRefCounter;
204 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mThreadShouldJoin;
205 ::ll::TypedStorage<8, 80, ::std::mutex> mMutexDestruction;
206 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::ServerInstanceEventCoordinator>> mEventCoordinator;
207 ::ll::TypedStorage<4, 4, ::std::atomic<::ServerInstance::InstanceState>> mInstanceState;
208 ::ll::TypedStorage<8, 16, ::std::thread> mServerInstanceThread;
209 ::ll::TypedStorage<8, 80, ::std::mutex> mResumeMutex;
210 ::ll::TypedStorage<8, 72, ::std::condition_variable> mResumeSignal;
211 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scripting::RegistryManager>> mScriptRegistryManager;
212 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerScriptManager>> mServerScriptManager;
213 ::ll::TypedStorage<8, 64, ::std::function<void(char const*)>> mScriptWatchdogCriticalErrorCallback;
214 ::ll::TypedStorage<8, 64, ::std::function<void(::Connection::DisconnectFailReason, char const*)>>
215 mUnrecoverableErrorCallback;
216 ::ll::TypedStorage<1, 1, bool> mHandledLevelCorruption;
217 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TextFilteringProcessor>> mTextFilteringProcessor;
218 ::ll::TypedStorage<8, 8, ::std::chrono::microseconds> mWakeupInterval;
219 ::ll::TypedStorage<8, 32, ::std::string> mLevelId;
220 ::ll::TypedStorage<8, 32, ::std::string> mServerName;
221 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::WorldSessionEndPoint>> mWorldSessionEndPoint;
222 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FileStorageArea>> mStorageAreaForLevel;
223 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ItemRegistry>> mServerItemRegistry;
224 ::ll::TypedStorage<1, 1, bool> mEnableItemStackNetManager;
225 ::ll::TypedStorage<1, 1, bool> mEnableRealmsStories;
226 ::ll::TypedStorage<1, 1, bool> mbFlaggedForEarlyDestruction;
227 ::ll::TypedStorage<8, 8, ::ServiceRegistrationToken<::ServerInstance>> mServiceRegistrationToken;
228 ::ll::TypedStorage<1, 1, bool> mHasScheduledLeaveGame;
229 ::ll::TypedStorage<1, 1, bool> mCriticalDiskErrorTelemetrySent;
230 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Editor::IEditorManager>> mEditorManager;
231 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::CDNConfig>> mCDNConfig;
232 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ServerTextSettings>> mServerTextSettings;
233 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::cereal::ReflectionCtx>> mCerealContext;
234 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LinkedAssetValidator>> mLinkedAssetValidator;
235 ::ll::TypedStorage<1, 1, ::ServerGraphicsSettings> mGraphicsSettings;
236 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::ServerInstanceMessenger::IMessenger>>> mMessenger;
237 ::ll::TypedStorage<8, 64, ::brstd::move_only_function<bool() const>> mShouldDisableNetworkOnSuspend;
238 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ChatLoggingEventListener>> mChatLoggingEventListener;
239 ::ll::TypedStorage<8, 16, ::Bedrock::UniqueOwnerPointer<::LocalProfilerControlBroker>> mLocalProfilerControlBroker;
240 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerInitialization::IServerInitializer>> mInitializer;
241 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::DebuggerDiagnostics>> mDebuggerDiagnostics;
242 ::ll::TypedStorage<8, 8, ::ServiceRegistrationToken<::DebuggerDiagnostics>> mDebuggerDiagnosticsToken;
243 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerPerformanceData>> mServerPerformanceData;
244 ::ll::TypedStorage<8, 8, ::ServiceRegistrationToken<::ServerPerformanceData>>
245 mServerPerformanceDataRegistrationToken;
246 // NOLINTEND
247
248public:
249 // prevent constructor by default
250 ServerInstance();
251
252public:
253 // virtual functions
254 // NOLINTBEGIN
255 virtual ~ServerInstance() /*override*/ = default;
256
257 virtual void onLowMemory(::LowMemorySeverity) /*override*/;
258
259 virtual void onLevelCorrupt() /*override*/;
260
261 virtual void onGameModeChanged() /*override*/;
262
263 virtual void onTick(int nTick, int maxTick) /*override*/;
264
265 virtual void onInternetUpdate() /*override*/;
266
267 virtual void onGameSessionReset() /*override*/;
268
269 virtual void onLevelExit() /*override*/;
270
271 virtual void onRequestResourceReload() /*override*/;
272
273 virtual void onLowDiskSpace(bool const bSet, uint64) /*override*/;
274
275 virtual void onOutOfDiskSpace(bool const bSet, uint64) /*override*/;
276
277 virtual void onCriticalDiskError(bool const bSet, ::Core::LevelStorageState const& errorCode) /*override*/;
278
279 virtual void onAppSuspended() /*override*/;
280
281 virtual void onAppResumed() /*override*/;
282
283 virtual void updateScreens() /*override*/;
284 // NOLINTEND
285
286public:
287 // member functions
288 // NOLINTBEGIN
289 MCAPI explicit ServerInstance(::ServerInstanceArguments&& args);
290
291 MCAPI ::Bedrock::Threading::Async<bool> _postLevelInitialization(::ServerInstance::PostLevelArgs&& args);
292
293 MCAPI void _resetServerScriptManager();
294
295#ifdef LL_PLAT_C
296 MCAPI void finishLoadingLinkedAssets(::ResourcePackManager& rpm);
297#endif
298
299 MCAPI ::Bedrock::NonOwnerPointer<::Editor::IEditorManager> getEditorManager() const;
300
301#ifdef LL_PLAT_C
302 MCAPI ::std::string getLevelId() const;
303#endif
304
305 MCAPI ::ServerInitialization::ServerInitResult initializeServer(::ServerInstanceInitArguments&& args);
306
307 MCAPI void leaveGameSync();
308
309 MCAPI void onCriticalScriptError(::Connection::DisconnectFailReason clientReason, char const* logMessage);
310
311 MCAPI void queueForServerThread(::std::function<void()> command);
312
313#ifdef LL_PLAT_C
314 MCAPI bool requestInGamePause(bool status);
315#endif
316
317 MCAPI void startLeaveGame();
318
319 MCAPI void startServerThread();
320 // NOLINTEND
321
322public:
323 // static functions
324 // NOLINTBEGIN
325 MCAPI static bool _useClientSideChunkGeneration(::LevelData* levelData);
326
327 MCAPI static ::brstd::move_only_function<bool(::ServerInstanceInitArguments::HostMultiplayerArguments&&) const>
328 createHostMultiplayerCallback(
329 ::ServerInstance& instance,
330 ::NetworkServerConfig networkServerConfig,
331 ::KeyManager hostPublicKey,
332 int maxChunkRadius,
333 bool shouldAnnounce,
334 ::ServerNetworkHandlerDependencies serverNetworkOptions
335 );
336
337 MCAPI static ::brstd::move_only_function<
338 ::std::unique_ptr<::ServerLevel>(::ServerInstanceInitArguments::CreateLevelArguments&&) const>
339 createServerLevelCallback(::ServerInstance::CreateServerLevelOps&& ops);
340
341#ifdef LL_PLAT_S
342 MCAPI static bool forceOffClientChunkGeneration(::LevelData& levelData);
343#endif
344 // NOLINTEND
345
346public:
347 // static variables
348 // NOLINTBEGIN
349 MCAPI static ::std::string const& ASSET_EXTRACTION_ERROR();
350
351 MCAPI static ::std::string const& ENTITY_REGISTRY_CREATION_ERROR();
352
353 MCAPI static ::std::string const& FINAL_LEVEL_STORAGE_STATE_ERROR();
354
355 MCAPI static ::std::string const& HOST_MULTIPLAYER_ERROR();
356
357 MCAPI static ::std::string const& INITIAL_LEVEL_STORAGE_STATE_ERROR();
358
359 MCAPI static ::std::string const& LEVEL_STORAGE_CREATION_ERROR();
360
361 MCAPI static ::std::string const& PACK_SOURCE_LOADING_ERROR();
362
363#ifdef LL_PLAT_C
364 MCAPI static ::std::string const& POST_INIT_ERROR();
365#endif
366 // NOLINTEND
367
368public:
369 // constructor thunks
370 // NOLINTBEGIN
371 MCAPI void* $ctor(::ServerInstanceArguments&& args);
372 // NOLINTEND
373
374public:
375 // virtual function thunks
376 // NOLINTBEGIN
377 MCAPI void $onLowMemory(::LowMemorySeverity);
378
379 MCAPI void $onLevelCorrupt();
380
381 MCFOLD void $onGameModeChanged();
382
383 MCFOLD void $onTick(int nTick, int maxTick);
384
385 MCFOLD void $onInternetUpdate();
386
387 MCFOLD void $onGameSessionReset();
388
389 MCFOLD void $onLevelExit();
390
391 MCAPI void $onRequestResourceReload();
392
393 MCAPI void $onLowDiskSpace(bool const bSet, uint64);
394
395 MCAPI void $onOutOfDiskSpace(bool const bSet, uint64);
396
397 MCAPI void $onCriticalDiskError(bool const bSet, ::Core::LevelStorageState const& errorCode);
398
399 MCAPI void $onAppSuspended();
400
401 MCAPI void $onAppResumed();
402
403 MCFOLD void $updateScreens();
404
405
406 // NOLINTEND
407};
Definition AppPlatformListener.h:16
Definition AppPlatform.h:78
Definition EnableNonOwnerReferences.h:7
Definition CDNConfig.h:9
Definition ChatLoggingEventListener.h:34
Definition FileStorageArea.h:30
Definition StorageAreaStateListener.h:15
Definition DebuggerDiagnostics.h:14
Definition IEditorManager.h:25
Definition EducationOptions.h:15
Definition GameCallbacks.h:5
Definition ILevel.h:221
Definition IMinecraftEventing.h:147
Definition IResourcePackRepository.h:35
Definition ItemRegistry.h:43
Definition KeyManager.h:8
Definition LevelData.h:55
Definition LevelStorage.h:25
Definition LinkedAssetValidator.h:8
Definition LocalProfilerControlBroker.h:11
Definition LoopbackPacketSender.h:21
Definition Minecraft.h:59
Definition ResourcePackManager.h:36
Definition Scheduler.h:14
Definition ScriptPackSettingsCache.h:16
Definition RegistryManager.h:12
Definition IServerInitializer.h:18
Definition ServerInstanceEventCoordinator.h:14
Definition IMessenger.h:13
Definition ServerLevel.h:57
Definition ServerNetworkSystem.h:34
Definition ServerScriptManager.h:78
Definition ServerTextSettings.h:8
Definition ServiceRegistrationToken.h:6
Definition TextFilteringProcessor.h:19
Definition Timer.h:5
Definition WorldSessionEndPoint.h:10
Definition StructureSetRegistry.h:12
Definition move_only_function.h:9
STL namespace.
Definition BiomeJsonDocumentGlueResolvedBiomeData.h:11
Definition DimensionFactoryAndManager.h:14
Definition NetworkServerConfig.h:9
Definition ServerInitResult.h:7
Definition ServerInstanceArguments.h:5
Definition ServerInstanceInitArguments.h:81
Definition ServerInstanceInitArguments.h:16
Definition ServerInstance.h:95
Definition ServerInstance.h:175
Definition ServerInstance.h:128
Definition ServerInstance.h:146
Definition ServerNetworkHandlerDependencies.h:5
Definition ServerPerformanceData.h:16
Definition ReflectionCtx.h:11