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