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