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