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