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