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