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/util/BaseGameVersion.h"
7#include "mc/world/level/ChunkPos.h"
8#include "mc/world/level/chunk/ActorDigestFormat.h"
9#include "mc/world/level/chunk/ChunkSource.h"
10#include "mc/world/level/chunk/LevelChunk.h"
11#include "mc/world/level/chunk/LevelChunkFormat.h"
12#include "mc/world/level/storage/ConsoleChunkBlender.h"
13#include "mc/world/level/storage/DBChunkStorageKey.h"
14
15// auto generated forward declare list
16// clang-format off
17class BaseGameVersion;
18class BlendingData;
20class ChunkKey;
21class ChunkViewSource;
22class DBStorage;
23class Experiments;
24class IDataInput;
25class LevelChunk;
28class Scheduler;
29class TaskGroup;
32struct DimensionType;
35// clang-format on
36
37class DBChunkStorage : public ::ChunkSource {
38public:
39 // DBChunkStorage inner types declare
40 // clang-format off
42 // clang-format on
43
44 // DBChunkStorage inner types define
45 enum class ChunkCacheStatus : int {
46 Missing = 0,
47 Available = 1,
48 DontCache = 2,
49 };
50
51 struct PreCavesAndCliffsMetaData {
52 public:
53 // member variables
54 // NOLINTBEGIN
57 // NOLINTEND
58
59 public:
60 // prevent constructor by default
61 PreCavesAndCliffsMetaData& operator=(PreCavesAndCliffsMetaData const&);
62 PreCavesAndCliffsMetaData(PreCavesAndCliffsMetaData const&);
63 PreCavesAndCliffsMetaData();
64 };
65
66public:
67 // member variables
68 // NOLINTBEGIN
69 ::ll::TypedStorage<8, 64, ::std::unordered_map<::DBChunkStorageKey, ::DBChunkStorage::ChunkCacheStatus>>
70 mHasChunkCache;
71 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mHasChunkCacheSharedMutex;
72 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ChunkPos, ::std::pair<bool, ::std::shared_ptr<::BlendingData>>>>
73 mChunkBlendingDataCache;
74 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mChunkBlendingDataSharedMutex;
75 ::ll::TypedStorage<8, 8, ::std::shared_mutex> mAttenuatorSharedMutex;
76 ::ll::TypedStorage<8, 8, ::DBStorage&> mStorage;
77 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::LevelStorageWriteBatch>>> mBufferPool;
78 ::ll::TypedStorage<8, 24, ::std::vector<::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter>>> mDiscardBatch;
79 ::ll::TypedStorage<8, 64, ::std::unordered_set<::ChunkPos>> mLiveChunksBeingSaved;
80 ::ll::
81 TypedStorage<8, 64, ::std::unordered_map<::ChunkPos, ::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter>>>
82 mDiscardedWhileLiveSaved;
83 ::ll::TypedStorage<1, 1, bool> mBatch;
84 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::TaskGroup>> mIOTaskGroup;
85 ::ll::TypedStorage<8, 32, ::BaseGameVersion> mCurrentLevelVersion;
86 // NOLINTEND
87
88public:
89 // prevent constructor by default
90 DBChunkStorage& operator=(DBChunkStorage const&);
91 DBChunkStorage(DBChunkStorage const&);
92 DBChunkStorage();
93
94public:
95 // virtual functions
96 // NOLINTBEGIN
97 virtual ~DBChunkStorage() /*override*/;
98
99 virtual void shutdown() /*override*/;
100
101 virtual bool isShutdownDone() /*override*/;
102
103 virtual void loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad) /*override*/;
104
105 virtual bool isChunkKnown(::ChunkPos const& chunkPos) /*override*/;
106
107 virtual bool isChunkSaved(::ChunkPos const& chunkPos) /*override*/;
108
109 virtual bool structurePostProcessChunk(::ChunkViewSource& neighborhood) /*override*/;
110
111 virtual bool decorationPostProcessChunk(::ChunkViewSource& neighborhood) /*override*/;
112
113 virtual void checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc) /*override*/;
114
115 virtual bool verifyChunkNeedsNeighborAwareUpgrade(::LevelChunk& lc) /*override*/;
116
117 virtual void neighborAwareChunkUpgrade(::LevelChunk& levelChunk, ::ChunkViewSource& neighborhood) /*override*/;
118
119 virtual void deleteAllChunkData(
120 ::std::unordered_set<::ChunkPos> excludedChunks,
121 ::std::function<void()> completionCallback,
122 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
123 ) /*override*/;
124
125 virtual void deleteStoredChunkData(
126 ::std::unordered_set<::ChunkPos> chunksToDelete,
127 ::std::function<void()> completionCallback,
128 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
129 ) /*override*/;
130
131 virtual bool saveLiveChunk(::LevelChunk& lc) /*override*/;
132
133 virtual void writeEntityChunkTransfer(::LevelChunk& lc) /*override*/;
134
135 virtual void writeEntityChunkTransfersToUnloadedChunk(
136 ::ChunkKey const& chunkKey,
137 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
138 ) /*override*/;
139
140 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr) /*override*/;
141
142 virtual void hintDiscardBatchBegin() /*override*/;
143
144 virtual void hintDiscardBatchEnd() /*override*/;
145
146 virtual void flushPendingDiscardedChunkWrites() /*override*/;
147
148 virtual void flushThreadBatch() /*override*/;
149
150 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider() /*override*/;
151
152 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary() /*override*/;
153
154 virtual void deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk) /*override*/;
155
156 virtual bool chunkPosNeedsBlending(::ChunkPos const& cp) /*override*/;
157 // NOLINTEND
158
159public:
160 // member functions
161 // NOLINTBEGIN
162 MCAPI DBChunkStorage(
163 ::std::unique_ptr<::ChunkSource> parent,
164 ::DBStorage& storage,
165 ::Scheduler& scheduler,
166 ::Experiments const&
167 );
168
169 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>> _cacheSeamlessChunkBlendingData(
170 ::ChunkPos chunkPos,
171 bool isCompleted,
172 ::std::shared_ptr<::BlendingData> blendingData
173 );
174
175 MCAPI bool
176 _checkSubChunksUseAbsoluteIndices(::DBChunkStorageKey key, ::LevelChunk const& lc, bool& flatworldsNeedFixup) const;
177
178 MCAPI bool _deleteChunkData(::ChunkPos const& pos, ::LevelStorageWriteBatch& batch);
179
180 MCAPI void _deleteChunkEntityData(::DBChunkStorageKey const& key, ::LevelStorageWriteBatch& batch);
181
182 MCAPI void _deserializeIndependentActorStorage(::LevelChunk& lc, ::std::string const& storageKeyDigestBuffer);
183
184 MCAPI ::std::shared_ptr<::LevelStorageWriteBatch> _getBuffer();
185
186 MCAPI ::LevelChunk::Neighbors _getChunkNeighbors(::ChunkPos lc, ::DimensionType dimensionType);
187
188 MCAPI ::std::optional<::LevelChunkFormat> _getLevelChunkFormat(::std::string_view prefix, ::std::string& buffer);
189
190 MCAPI ::LevelChunk::Neighbors _getNeighborsUsedForBlending(::ChunkPos chunkPos, ::DimensionType dimensonType);
191
192 MCAPI bool _hasChunk(::DBChunkStorageKey const& key);
193
194 MCAPI bool _hasChunkUncached(::DBChunkStorageKey const& key);
195
196 MCAPI ::std::pair<bool, ::std::unique_ptr<::PersistentBlendData>>
197 _levelChunkCanBeUsedForBlending(::DBChunkStorageKey const& lcKey);
198
199 MCAPI void _loadAndBlendFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
200
201 MCAPI bool _loadChunkFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
202
203 MCAPI void _saveBlendData(
205 ::std::string_view prefix,
206 ::std::string& buffer,
208 ) const;
209
210 MCAPI void
211 _serializeChunk(::LevelChunk& lc, ::LevelStorageWriteBatch& batch, bool markEntitiesProcesedOnChunkDiscard);
212
213 MCAPI void _serializeEntities(
214 ::LevelChunk& lc,
216 ::std::string& buffer,
217 bool markEntitiesProcesedOnChunkDiscard
218 );
219
220 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>>
221 _tryGetBlendingDataForChunk(::ChunkPos const& checkPosition);
222
223 MCAPI ::std::optional<::DBChunkStorageKey> _tryGetChunkKeyFromString(::std::string_view key);
224
225 MCAPI ::std::string _upgradeActorStorage(::ChunkKey chunkKey, ::std::string_view& legacyActorData);
226
227 MCAPI void
228 _writeActorDigest(::LevelStorageWriteBatch& batch, ::ChunkKey const& chunkKey, ::std::string const& digestBuffer);
229
230 MCAPI void _writeActorDigestFormatVersion(
232 ::ChunkKey const& chunkKey,
233 ::ActorDigestFormat formatVersion
234 );
235
236 MCAPI void _writeDiscardChunksBatch();
237
238 MCAPI void freeCaches();
239 // NOLINTEND
240
241public:
242 // static functions
243 // NOLINTBEGIN
244 MCAPI static ::std::vector<::std::string> _deserializeChunkActorStorageKeys(::IDataInput& digestStream);
245
246 MCAPI static ::ConsoleChunkBlender::BlenderMode _getBlenderMode(::LevelChunk const& lc, ::Experiments const&);
247
248 MCAPI static ::std::string deserializeActorStorageToString(
249 bool hasActorDigestVersionTag,
250 ::std::string const& storageKeyDigestBuffer,
251 ::std::function<bool(::std::string_view, ::std::string&)> loadDataCallback
252 );
253 // NOLINTEND
254
255public:
256 // static variables
257 // NOLINTBEGIN
258 MCAPI static ::LevelStorageWriteBatch& threadBatch();
259
260 MCAPI static ::std::string& threadBuffer();
261 // NOLINTEND
262
263public:
264 // constructor thunks
265 // NOLINTBEGIN
266 MCAPI void*
267 $ctor(::std::unique_ptr<::ChunkSource> parent, ::DBStorage& storage, ::Scheduler& scheduler, ::Experiments const&);
268 // NOLINTEND
269
270public:
271 // destructor thunk
272 // NOLINTBEGIN
273 MCAPI void $dtor();
274 // NOLINTEND
275
276public:
277 // virtual function thunks
278 // NOLINTBEGIN
279 MCAPI void $shutdown();
280
281 MCAPI bool $isShutdownDone();
282
283 MCAPI void $loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
284
285 MCFOLD bool $isChunkKnown(::ChunkPos const& chunkPos);
286
287 MCFOLD bool $isChunkSaved(::ChunkPos const& chunkPos);
288
289 MCAPI bool $structurePostProcessChunk(::ChunkViewSource& neighborhood);
290
291 MCAPI bool $decorationPostProcessChunk(::ChunkViewSource& neighborhood);
292
293 MCAPI void $checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
294
295 MCAPI bool $verifyChunkNeedsNeighborAwareUpgrade(::LevelChunk& lc);
296
297 MCAPI void $neighborAwareChunkUpgrade(::LevelChunk& levelChunk, ::ChunkViewSource& neighborhood);
298
299 MCAPI void $deleteAllChunkData(
300 ::std::unordered_set<::ChunkPos> excludedChunks,
301 ::std::function<void()> completionCallback,
302 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
303 );
304
305 MCAPI void $deleteStoredChunkData(
306 ::std::unordered_set<::ChunkPos> chunksToDelete,
307 ::std::function<void()> completionCallback,
308 ::std::shared_ptr<::ChunkDeletionMetadata> metadata
309 );
310
311 MCAPI bool $saveLiveChunk(::LevelChunk& lc);
312
313 MCAPI void $writeEntityChunkTransfer(::LevelChunk& lc);
314
315 MCAPI void $writeEntityChunkTransfersToUnloadedChunk(
316 ::ChunkKey const& chunkKey,
317 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
318 );
319
320 MCAPI void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
321
322 MCFOLD void $hintDiscardBatchBegin();
323
324 MCAPI void $hintDiscardBatchEnd();
325
326 MCAPI void $flushPendingDiscardedChunkWrites();
327
328 MCAPI void $flushThreadBatch();
329
330 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
331
332 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
333
334 MCAPI void $deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
335
336 MCAPI bool $chunkPosNeedsBlending(::ChunkPos const& cp);
337
338
339 // NOLINTEND
340
341public:
342 // vftables
343 // NOLINTBEGIN
344 MCNAPI static void** $vftable();
345 // NOLINTEND
346};
Definition BaseGameVersion.h:13
Definition BlendingDataProvider.h:5
Definition BlendingData.h:14
Definition ChunkKey.h:14
Definition ChunkPos.h:11
Definition ChunkViewSource.h:23
Definition DBChunkStorageKey.h:8
static MCAPI void ** $vftable()
Definition DBStorage.h:40
Definition Experiments.h:14
Definition IDataInput.h:8
Definition LevelChunkMetaDataDictionary.h:11
Definition LevelChunk.h:87
Definition LevelStorageWriteBatch.h:14
Definition Scheduler.h:15
Definition TaskGroup.h:55
Definition ActorUnloadedChunkTransferEntry.h:13
Definition ChunkDeletionMetadata.h:5
Definition DBChunkStorage.h:51
Definition DimensionType.h:5
Definition LevelChunkFinalDeleter.h:10
Definition PersistentBlendData.h:10
Definition buffer.h:5
Definition Alias.h:14