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