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/deps/nether_net/LogSeverity.h"
15#include "mc/network/PacketGroupDefinition.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/world/GameCallbacks.h"
20#include "mc/world/level/ForceBlockNetworkIdsAreHashes.h"
21
22// auto generated forward declare list
23// clang-format off
24class AllowList;
25class CDNConfig;
26class DebugEndPoint;
28class Experiments;
30class IMinecraftApp;
34class ItemRegistry;
35class ItemRegistryRef;
36class LevelData;
37class LevelSettings;
38class LevelStorage;
41class Minecraft;
43class PermissionsFile;
45class Scheduler;
47class ServerMetrics;
53class Timer;
59struct PortMappingInfo;
60struct ScriptSettings;
63namespace Core { class FilePathManager; }
64namespace Core { class FileStorageArea; }
65namespace Editor { class IEditorManager; }
66namespace NetherNet { struct NetworkID; }
67namespace Scripting { class RegistryManager; }
68namespace ServerInstanceMessenger { class IMessenger; }
69namespace cereal { struct ReflectionCtx; }
70namespace mce { class UUID; }
71// clang-format on
72
75 public ::GameCallbacks,
77public:
78 // ServerInstance inner types define
79 enum class InstanceState : int {
80 Running = 0,
81 Suspended = 1,
82 WaitingLeaveGame = 2,
83 Stopped = 3,
84 NotStarted = 4,
85 };
86
87public:
88 // member variables
89 // NOLINTBEGIN
90 ::ll::TypedStorage<8, 8, ::std::chrono::steady_clock::time_point> mLastSyncTime;
91 ::ll::TypedStorage<8, 8, ::IMinecraftApp const&> mApp;
92 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Minecraft>> mMinecraft;
93 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerNetworkSystem>> mNetwork;
94 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LoopbackPacketSender>> mPacketSender;
95 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Timer>> mSimTimer;
96 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Timer>> mRealTimer;
97 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scheduler>> mScheduler;
98 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::EducationOptions>> mEducationOptions;
99 ::ll::TypedStorage<8, 8, ::LevelStorage*> mStorage;
100 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mInUpdate;
101 ::ll::TypedStorage<4, 4, ::std::atomic<int>> mWriteRefCounter;
102 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mThreadShouldJoin;
103 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mMutexDestruction;
104 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::ServerInstanceEventCoordinator>> mEventCoordinator;
105 ::ll::TypedStorage<4, 4, ::std::atomic<::ServerInstance::InstanceState>> mInstanceState;
106 ::ll::TypedStorage<8, 16, ::std::thread> mServerInstanceThread;
107 ::ll::TypedStorage<8, 80, ::Bedrock::Threading::Mutex> mResumeMutex;
108 ::ll::TypedStorage<8, 72, ::std::condition_variable> mResumeSignal;
109 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Scripting::RegistryManager>> mScriptRegistryManager;
110 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ServerScriptManager>> mServerScriptManager;
111 ::ll::TypedStorage<8, 64, ::std::function<void(char const*)>> mScriptWatchdogCriticalErrorCallback;
112 ::ll::TypedStorage<8, 64, ::std::function<void(char const*, char const*)>> mUnrecoverableErrorCallback;
113 ::ll::TypedStorage<1, 1, bool> mHandledLevelCorruption;
114 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TextFilteringProcessor>> mTextFilteringProcessor;
115 ::ll::TypedStorage<8, 8, ::std::chrono::microseconds> mWakeupInterval;
116 ::ll::TypedStorage<8, 32, ::std::string> mLevelId;
117 ::ll::TypedStorage<8, 32, ::std::string> mServerName;
118 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::WorldSessionEndPoint>> mWorldSessionEndPoint;
119 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Core::FileStorageArea>> mStorageAreaForLevel;
120 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::ItemRegistry>> mServerItemRegistry;
121 ::ll::TypedStorage<1, 1, bool> mEnableItemStackNetManager;
122 ::ll::TypedStorage<1, 1, bool> mEnableRealmsStories;
123 ::ll::TypedStorage<1, 1, bool> mbInitialized;
124 ::ll::TypedStorage<1, 1, bool> mbFlaggedForEarlyDestruction;
125 ::ll::TypedStorage<8, 8, ::ServiceRegistrationToken<::ServerInstance>> mServiceRegistrationToken;
126 ::ll::TypedStorage<1, 1, bool> mHasScheduledLeaveGame;
127 ::ll::TypedStorage<1, 1, bool> mCriticalDiskErrorTelemetrySent;
128 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Editor::IEditorManager>> mEditorManager;
129 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::CDNConfig>> mCDNConfig;
130 ::ll::TypedStorage<8, 24, ::Bedrock::NonOwnerPointer<::ServerTextSettings>> mServerTextSettings;
131 ::ll::TypedStorage<8, 24, ::Bedrock::NotNullNonOwnerPtr<::cereal::ReflectionCtx>> mCerealContext;
132 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::LinkedAssetValidator>> mLinkedAssetValidator;
133 ::ll::TypedStorage<1, 1, ::ServerGraphicsSettings> mGraphicsSettings;
134 ::ll::TypedStorage<8, 8, ::gsl::not_null<::std::unique_ptr<::ServerInstanceMessenger::IMessenger>>> mMessenger;
135 ::ll::TypedStorage<8, 64, ::brstd::move_only_function<bool() const>> mShouldDisableNetworkOnSuspend;
136 // NOLINTEND
137
138public:
139 // prevent constructor by default
140 ServerInstance& operator=(ServerInstance const&);
143
144public:
145 // virtual functions
146 // NOLINTBEGIN
147 // vIndex: 0
148 virtual ~ServerInstance() /*override*/;
149
150 // vIndex: 19
151 virtual void onLowMemory(::LowMemorySeverity) /*override*/;
152
153 // vIndex: 1
154 virtual void onLevelCorrupt() /*override*/;
155
156 // vIndex: 2
157 virtual void onCriticalScriptError(char const* clientDisconnectMessage, char const* logMessage) /*override*/;
158
159 // vIndex: 3
160 virtual void onGameModeChanged() /*override*/;
161
162 // vIndex: 5
163 virtual void onTick(int nTick, int maxTick) /*override*/;
164
165 // vIndex: 6
166 virtual void onInternetUpdate() /*override*/;
167
168 // vIndex: 7
169 virtual void onGameSessionReset() /*override*/;
170
171 // vIndex: 8
172 virtual void onLevelExit() /*override*/;
173
174 // vIndex: 9
175 virtual void onRequestResourceReload() /*override*/;
176
177 // vIndex: 2
178 virtual void onLowDiskSpace(bool const bSet) /*override*/;
179
180 // vIndex: 3
181 virtual void onOutOfDiskSpace(bool const bSet) /*override*/;
182
183 // vIndex: 4
184 virtual void onCriticalDiskError(bool const bSet, ::Core::LevelStorageState const& errorCode) /*override*/;
185
186 // vIndex: 4
187 virtual void onAppSuspended() /*override*/;
188
189 // vIndex: 5
190 virtual void onAppResumed() /*override*/;
191
192 // vIndex: 10
193 virtual void updateScreens() /*override*/;
194 // NOLINTEND
195
196public:
197 // member functions
198 // NOLINTBEGIN
199 MCAPI ServerInstance(
200 ::IMinecraftApp& app,
201 ::Bedrock::NotNullNonOwnerPtr<::ServerInstanceEventCoordinator> const& coordinator
202 );
203
204 MCAPI void _resetServerScriptManager();
205
206 MCAPI void _shutdownStorage(::Bedrock::UniqueOwnerPointer<::LevelStorage>& storage);
207
208 MCAPI void _update();
209
210 MCAPI bool _useClientSideChunkGeneration(::LevelData* levelData) const;
211
212 MCAPI void disconnectAllClientsWithMessage(::std::string msg);
213
214 MCAPI ::Bedrock::NonOwnerPointer<::Editor::IEditorManager> getEditorManager() const;
215
216 MCAPI ::ItemRegistryRef getServerItemRegistry() const;
217
218 MCAPI bool initializeServer(
219 ::IMinecraftApp& app,
220 ::AllowList& allowList,
221 ::PermissionsFile* permissionsFile,
222 ::std::optional<::PacketGroupDefinition::PacketGroupBuilder> packetGroupBuilder,
223 ::Bedrock::NotNullNonOwnerPtr<::Core::FilePathManager> const& pathManager,
224 ::std::chrono::seconds maxPlayerIdleTime,
225 ::std::string levelId,
226 ::std::string levelName,
227 ::std::string serverName,
228 ::LevelSettings levelSettings,
229 int maxChunkRadius,
230 bool shouldAnnounce,
231 ::ConnectionDefinition connectionDefinition,
232 ::NetworkServerConfig networkServerConfig,
233 ::mce::UUID const& localPlayerId,
234 ::IMinecraftEventing& eventing,
235 ::Bedrock::NotNullNonOwnerPtr<::IResourcePackRepository> const& resourcePackRepository,
236 ::Bedrock::NotNullNonOwnerPtr<::IContentTierManager const> const& contentTierManager,
237 ::ResourcePackManager& clientResourcePackManager,
238 ::std::function<::Bedrock::UniqueOwnerPointer<::LevelStorage>(::Scheduler&)> createLevelStorageCallback,
239 ::std::string const& basePath,
240 ::Bedrock::NotNullNonOwnerPtr<::LevelData> levelData,
241 ::std::unique_ptr<::EducationOptions> educationOptions,
242 ::ResourcePackManager* localServerResourcePackManager,
243 ::std::function<void()> criticalSaveCallback,
244 ::std::function<void()> compactionCallback,
245 ::ServerMetrics* serverMetrics,
246 ::DebugEndPoint* debugEndPoint,
247 bool enableWorldSessionEndPoint,
248 ::std::shared_ptr<::Core::FileStorageArea> storageAreaForLevel,
249 ::NetworkSettingOptions const& networkSettings,
250 bool enableItemStackNetManager,
251 bool enableItemTransactionLogger,
252 bool enableRealmsStories,
253 ::std::optional<::PlayerMovementSettings> playerMovementSettings,
254 ::ScriptSettings&& scriptSettings,
255 ::Experiments const& levelExperiments,
256 bool disableLanSignaling,
257 bool isServerVisibleToLanDiscovery,
258 bool enablePacketRateLimiting,
259 float worldSizeMB,
260 ::std::optional<bool> clientSideGenerationEnabled,
261 ::ForceBlockNetworkIdsAreHashes blockNetworkIdsAreHashes,
262 ::Bedrock::NotNullNonOwnerPtr<::NetworkSessionOwner> networkSessionOwner,
265 ::PortMappingInfo const& portMappingInfo,
266 ::NetherNet::LogSeverity defaultLogSeverity,
267 ::TextProcessorInitParams textProcessorInitParams,
268 ::std::optional<::NetherNet::NetworkID> netherNetId,
270 ::std::optional<bool> disableClientVibrantVisuals,
271 ::std::unique_ptr<::IPacketSerializationController> packetController,
272 ::ServerNetworkHandlerDependencies&& serverNetworkOptions,
273 ::brstd::move_only_function<bool() const> shouldDisableNetworkOnSuspend
274 );
275
276 MCAPI void leaveGameSync();
277
278 MCAPI void queueForServerThread(::std::function<void()> command);
279
280 MCAPI void setScriptWatchdogCriticalErrorCallback(::std::function<void(char const*)> criticalErrorCallback);
281
282 MCAPI void
283 setUnrecoverableErrorCallback(::std::function<void(char const*, char const*)> unrecoverableErrorCallback);
284
285 MCAPI void startServerThread();
286 // NOLINTEND
287
288public:
289 // static functions
290 // NOLINTBEGIN
291 MCAPI static bool forceOffClientChunkGeneration(::LevelData& levelData);
292 // NOLINTEND
293
294public:
295 // static variables
296 // NOLINTBEGIN
297 MCAPI static ::std::chrono::nanoseconds const& SERVER_MAX_DELAY_BEFORE_SLOWDOWN();
298 // NOLINTEND
299
300public:
301 // constructor thunks
302 // NOLINTBEGIN
303 MCAPI void*
304 $ctor(::IMinecraftApp& app, ::Bedrock::NotNullNonOwnerPtr<::ServerInstanceEventCoordinator> const& coordinator);
305 // NOLINTEND
306
307public:
308 // destructor thunk
309 // NOLINTBEGIN
310 MCAPI void $dtor();
311 // NOLINTEND
312
313public:
314 // virtual function thunks
315 // NOLINTBEGIN
316 MCAPI void $onLevelCorrupt();
317
318 MCAPI void $onCriticalScriptError(char const* clientDisconnectMessage, char const* logMessage);
319
320 MCFOLD void $onGameModeChanged();
321
322 MCFOLD void $onTick(int nTick, int maxTick);
323
324 MCFOLD void $onInternetUpdate();
325
326 MCFOLD void $onGameSessionReset();
327
328 MCFOLD void $onLevelExit();
329
330 MCAPI void $onRequestResourceReload();
331
332 MCAPI void $onLowDiskSpace(bool const bSet);
333
334 MCAPI void $onOutOfDiskSpace(bool const bSet);
335
336 MCAPI void $onCriticalDiskError(bool const bSet, ::Core::LevelStorageState const& errorCode);
337
338 MCAPI void $onAppSuspended();
339
340 MCAPI void $onAppResumed();
341
342 MCFOLD void $updateScreens();
343 // NOLINTEND
344
345public:
346 // vftables
347 // NOLINTBEGIN
348 MCNAPI static void** $vftableForGameCallbacks();
349
351
352 MCNAPI static void** $vftableForAppPlatformListener();
353
355 // NOLINTEND
356};
Definition AllowList.h:14
Definition AppPlatformListener.h:15
Definition EnableNonOwnerReferences.h:7
Definition NonOwnerPointer.h:9
Definition UniqueOwnerPointer.h:11
Definition CDNConfig.h:9
Definition StorageAreaStateListener.h:16
Definition DebugEndPoint.h:17
Definition EducationOptions.h:16
Definition Experiments.h:14
Definition GameCallbacks.h:5
Definition IContentTierManager.h:13
Definition IMinecraftApp.h:17
Definition IMinecraftEventing.h:149
Definition IPacketSerializationController.h:9
Definition IResourcePackRepository.h:34
Definition ItemRegistryRef.h:34
Definition ItemRegistry.h:43
Definition LevelData.h:49
Definition LevelSettings.h:38
Definition LevelStorage.h:25
Definition LinkedAssetValidator.h:8
Definition LoopbackPacketSender.h:21
Definition Minecraft.h:58
Definition NetworkSessionOwner.h:9
Definition PermissionsFile.h:17
Definition ResourcePackManager.h:24
Definition Scheduler.h:13
Definition ServerInstanceEventCoordinator.h:18
Definition ServerInstance.h:76
static MCAPI void ** $vftableForGameCallbacks()
static MCAPI void ** $vftableForAppPlatformListener()
static MCAPI void ** $vftableForEnableNonOwnerReferences()
static MCAPI void ** $vftableForStorageAreaStateListener()
Definition ServerMetrics.h:10
Definition ServerNetworkSystem.h:31
Definition ServerScriptManager.h:73
Definition ServerTextSettings.h:8
Definition SignalingService.h:38
Definition TextFilteringProcessor.h:18
Definition Timer.h:5
Definition WorldSessionEndPoint.h:10
Definition move_only_function.h:9
Definition UUID.h:7
Definition ConnectionDefinition.h:5
Definition NetworkServerConfig.h:9
Definition NetworkSettingOptions.h:9
Definition PlayerMovementSettings.h:9
Definition PortMappingInfo.h:5
Definition ScriptSettings.h:18
Definition ServerNetworkHandlerDependencies.h:5
Definition TextProcessorInitParams.h:5