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