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