LeviLamina
Loading...
Searching...
No Matches
DBChunkStorage.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/platform/threading/ThreadLocalObject.h"
7#include "mc/world/level/chunk/ChunkSource.h"
8#include "mc/world/level/chunk/LevelChunkFormat.h"
9#include "mc/world/level/storage/ConsoleChunkBlender.h"
10
11// auto generated forward declare list
12// clang-format off
13class BaseGameVersion;
14class BlendingData;
16class ChunkKey;
17class ChunkPos;
18class ChunkViewSource;
20class DBStorage;
21class Experiments;
22class IDataInput;
23class LevelChunk;
26class Scheduler;
27class TaskGroup;
31// clang-format on
32
34public:
35 // DBChunkStorage inner types declare
36 // clang-format off
38 // clang-format on
39
40 // DBChunkStorage inner types define
42 public:
43 // member variables
44 // NOLINTBEGIN
47 // NOLINTEND
48
49 public:
50 // prevent constructor by default
54 };
55
56 enum class ChunkCacheStatus : int {
57 Missing = 0,
58 Available = 1,
59 DontCache = 2,
60 };
61
62public:
63 // member variables
64 // NOLINTBEGIN
65 ::ll::TypedStorage<8, 64, ::std::unordered_map<::DBChunkStorageKey, ::DBChunkStorage::ChunkCacheStatus>>
66 mHasChunkCache;
67 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mHasChunkCacheSharedMutex;
68 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ChunkPos, ::std::pair<bool, ::std::shared_ptr<::BlendingData>>>>
69 mChunkBlendingDataCache;
70 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mChunkBlendingDataSharedMutex;
71 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mAttenuatorSharedMutex;
72 ::ll::TypedStorage<8, 8, ::DBStorage&> mStorage;
73 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::LevelStorageWriteBatch>>> mBufferPool;
74 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter>>> mDiscardBatch;
75 ::ll::TypedStorage<8, 64, ::std::unordered_set<::ChunkPos>> mLiveChunksBeingSaved;
76 ::ll::
77 TypedStorage<8, 64, ::std::unordered_map<::ChunkPos, ::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter>>>
78 mDiscardedWhileLiveSaved;
79 ::ll::TypedStorage<1, 1, bool> mBatch;
80 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mIOTaskGroup;
81 ::ll::TypedStorage<8, 32, ::BaseGameVersion> mCurrentLevelVersion;
82 // NOLINTEND
83
84public:
85 // virtual functions
86 // NOLINTBEGIN
87 // vIndex: 0
88 virtual ~DBChunkStorage() /*override*/;
89
90 // vIndex: 1
91 virtual void shutdown() /*override*/;
92
93 // vIndex: 2
94 virtual bool isShutdownDone() /*override*/;
95
96 // vIndex: 11
97 virtual void loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad) /*override*/;
98
99 // vIndex: 5
100 virtual bool isChunkKnown(::ChunkPos const& chunkPos) /*override*/;
101
102 // vIndex: 6
103 virtual bool isChunkSaved(::ChunkPos const& chunkPos) /*override*/;
104
105 // vIndex: 9
106 virtual bool postProcess(::ChunkViewSource& neighborhood) /*override*/;
107
108 // vIndex: 10
109 virtual void checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc) /*override*/;
110
111 // vIndex: 14
112 virtual bool saveLiveChunk(::LevelChunk& lc) /*override*/;
113
114 // vIndex: 15
115 virtual void writeEntityChunkTransfer(::LevelChunk& lc) /*override*/;
116
117 // vIndex: 16
118 virtual void writeEntityChunkTransfersToUnloadedChunk(
119 ::ChunkKey const& chunkKey,
120 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
121 ) /*override*/;
122
123 // vIndex: 20
124 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr) /*override*/;
125
126 // vIndex: 18
127 virtual void hintDiscardBatchBegin() /*override*/;
128
129 // vIndex: 19
130 virtual void hintDiscardBatchEnd() /*override*/;
131
132 // vIndex: 22
133 virtual void flushPendingDiscardedChunkWrites() /*override*/;
134
135 // vIndex: 23
136 virtual void flushThreadBatch() /*override*/;
137
138 // vIndex: 29
139 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider() /*override*/;
140
141 // vIndex: 30
142 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary() /*override*/;
143
144 // vIndex: 17
145 virtual void deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk) /*override*/;
146
147 // vIndex: 33
148 virtual bool chunkPosNeedsBlending(::ChunkPos const& cp) /*override*/;
149 // NOLINTEND
150
151public:
152 // member functions
153 // NOLINTBEGIN
154 MCAPI DBChunkStorage(
155 ::std::unique_ptr<::ChunkSource> parent,
156 ::DBStorage& storage,
157 ::Scheduler& scheduler,
158 ::Experiments const& experiments
159 );
160
161 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>> _cacheSeamlessChunkBlendingData(
162 ::ChunkPos chunkPos,
163 bool isCompleted,
164 ::std::shared_ptr<::BlendingData> blendingData
165 );
166
167 MCAPI bool
168 _checkSubChunksUseAbsoluteIndices(::DBChunkStorageKey key, ::LevelChunk const& lc, bool& flatworldsNeedFixup) const;
169
170 MCAPI void _deserializeIndependentActorStorage(::LevelChunk& lc, ::std::string const& storageKeyDigestBuffer);
171
172 MCAPI ::std::optional<::LevelChunkFormat> _getLevelChunkFormat(::std::string_view prefix, ::std::string& buffer);
173
174 MCAPI bool _hasChunk(::DBChunkStorageKey const& key);
175
176 MCAPI bool _hasChunkUncached(::DBChunkStorageKey const& key);
177
178 MCAPI ::std::pair<bool, ::std::unique_ptr<::PersistentBlendData>>
179 _levelChunkCanBeUsedForBlending(::DBChunkStorageKey const& lcKey);
180
181 MCAPI void _loadAndBlendFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
182
183 MCAPI bool _loadChunkFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
184
185 MCAPI void _saveBlendData(
187 ::std::string_view prefix,
188 ::std::string& buffer,
190 ) const;
191
192 MCAPI void
193 _serializeChunk(::LevelChunk& lc, ::LevelStorageWriteBatch& batch, bool markEntitiesProcesedOnChunkDiscard);
194
195 MCAPI void _serializeEntities(
196 ::LevelChunk& lc,
198 ::std::string& buffer,
199 bool markEntitiesProcesedOnChunkDiscard
200 );
201
202 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>>
203 _tryGetBlendingDataForChunk(::ChunkPos const& checkPosition);
204
205 MCAPI ::std::string _upgradeActorStorage(::ChunkKey chunkKey, ::std::string_view& legacyActorData);
206
207 MCAPI void
208 _writeActorDigest(::LevelStorageWriteBatch& batch, ::ChunkKey const& chunkKey, ::std::string const& digestBuffer);
209
210 MCAPI void _writeDiscardChunksBatch();
211 // NOLINTEND
212
213public:
214 // static functions
215 // NOLINTBEGIN
216 MCAPI static ::std::vector<::std::string> _deserializeChunkActorStorageKeys(::IDataInput& digestStream);
217
218 MCAPI static ::ConsoleChunkBlender::BlenderMode
219 _getBlenderMode(::LevelChunk const& lc, ::Experiments const& experiments);
220
221 MCAPI static ::std::string deserializeActorStorageToString(
222 bool hasActorDigestVersionTag,
223 ::std::string const& storageKeyDigestBuffer,
224 ::std::function<bool(::std::string_view, ::std::string&)> loadDataCallback
225 );
226 // NOLINTEND
227
228public:
229 // static variables
230 // NOLINTBEGIN
231 MCAPI static ::Bedrock::Threading::ThreadLocalObject<::LevelStorageWriteBatch>& threadBatch();
232
233 MCAPI static ::Bedrock::Threading::ThreadLocalObject<::std::string>& threadBuffer();
234 // NOLINTEND
235
236public:
237 // constructor thunks
238 // NOLINTBEGIN
239 MCAPI void* $ctor(
240 ::std::unique_ptr<::ChunkSource> parent,
241 ::DBStorage& storage,
242 ::Scheduler& scheduler,
243 ::Experiments const& experiments
244 );
245 // NOLINTEND
246
247public:
248 // destructor thunk
249 // NOLINTBEGIN
250 MCAPI void $dtor();
251 // NOLINTEND
252
253public:
254 // virtual function thunks
255 // NOLINTBEGIN
256 MCAPI void $shutdown();
257
258 MCAPI bool $isShutdownDone();
259
260 MCAPI void $loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
261
262 MCFOLD bool $isChunkKnown(::ChunkPos const& chunkPos);
263
264 MCFOLD bool $isChunkSaved(::ChunkPos const& chunkPos);
265
266 MCAPI bool $postProcess(::ChunkViewSource& neighborhood);
267
268 MCAPI void $checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
269
270 MCAPI bool $saveLiveChunk(::LevelChunk& lc);
271
272 MCAPI void $writeEntityChunkTransfer(::LevelChunk& lc);
273
274 MCAPI void $writeEntityChunkTransfersToUnloadedChunk(
275 ::ChunkKey const& chunkKey,
276 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
277 );
278
279 MCAPI void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
280
281 MCAPI void $hintDiscardBatchBegin();
282
283 MCAPI void $hintDiscardBatchEnd();
284
285 MCAPI void $flushPendingDiscardedChunkWrites();
286
287 MCAPI void $flushThreadBatch();
288
289 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
290
291 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
292
293 MCAPI void $deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
294
295 MCAPI bool $chunkPosNeedsBlending(::ChunkPos const& cp);
296 // NOLINTEND
297
298public:
299 // vftables
300 // NOLINTBEGIN
301 MCAPI static void** $vftable();
302 // NOLINTEND
303};
Definition BaseGameVersion.h:13
Definition BlendingDataProvider.h:5
Definition BlendingData.h:5
Definition ChunkKey.h:14
Definition ChunkPos.h:11
Definition ChunkSource.h:34
Definition ChunkViewSource.h:22
Definition DBChunkStorageKey.h:8
Definition DBChunkStorage.h:33
Definition DBStorage.h:30
Definition Experiments.h:14
Definition IDataInput.h:8
Definition LevelChunkMetaDataDictionary.h:11
Definition LevelChunk.h:73
Definition LevelStorageWriteBatch.h:14
Definition Scheduler.h:13
Definition TaskGroup.h:22
Definition ActorUnloadedChunkTransferEntry.h:11
Definition DBChunkStorage.h:41
Definition LevelChunkFinalDeleter.h:5
Definition PersistentBlendData.h:13
Definition buffer.h:5
Definition Alias.h:14