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