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/ChunkSource.h"
9#include "mc/world/level/storage/ConsoleChunkBlender.h"
10#include "mc/world/level/storage/db_helpers/Category.h"
11
12// auto generated forward declare list
13// clang-format off
14class BaseGameVersion;
15class BlendingData;
17class ChunkKey;
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 // prevent constructor by default
86 DBChunkStorage& operator=(DBChunkStorage const&);
89
90public:
91 // virtual functions
92 // NOLINTBEGIN
93 // vIndex: 0
94 virtual ~DBChunkStorage() /*override*/;
95
96 // vIndex: 1
97 virtual void shutdown() /*override*/;
98
99 // vIndex: 2
100 virtual bool isShutdownDone() /*override*/;
101
102 // vIndex: 14
103 virtual void loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad) /*override*/;
104
105 // vIndex: 5
106 virtual bool isChunkKnown(::ChunkPos const& chunkPos) /*override*/;
107
108 // vIndex: 6
109 virtual bool isChunkSaved(::ChunkPos const& chunkPos) /*override*/;
110
111 // vIndex: 9
112 virtual bool structurePostProcessChunk(::ChunkViewSource& neighborhood) /*override*/;
113
114 // vIndex: 10
115 virtual bool decorationPostProcessChunk(::ChunkViewSource& neighborhood) /*override*/;
116
117 // vIndex: 11
118 virtual void checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc) /*override*/;
119
120 // vIndex: 12
121 virtual bool verifyChunkNeedsNeighborAwareUpgrade(::LevelChunk& lc) /*override*/;
122
123 // vIndex: 13
124 virtual void neighborAwareChunkUpgrade(::LevelChunk& levelChunk, ::ChunkViewSource& neighborhood) /*override*/;
125
126 // vIndex: 17
127 virtual bool saveLiveChunk(::LevelChunk& lc) /*override*/;
128
129 // vIndex: 18
130 virtual void writeEntityChunkTransfer(::LevelChunk& lc) /*override*/;
131
132 // vIndex: 19
133 virtual void writeEntityChunkTransfersToUnloadedChunk(
134 ::ChunkKey const& chunkKey,
135 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
136 ) /*override*/;
137
138 // vIndex: 23
139 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr) /*override*/;
140
141 // vIndex: 21
142 virtual void hintDiscardBatchBegin() /*override*/;
143
144 // vIndex: 22
145 virtual void hintDiscardBatchEnd() /*override*/;
146
147 // vIndex: 25
148 virtual void flushPendingDiscardedChunkWrites() /*override*/;
149
150 // vIndex: 26
151 virtual void flushThreadBatch() /*override*/;
152
153 // vIndex: 32
154 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider() /*override*/;
155
156 // vIndex: 33
157 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary() /*override*/;
158
159 // vIndex: 20
160 virtual void deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk) /*override*/;
161
162 // vIndex: 36
163 virtual bool chunkPosNeedsBlending(::ChunkPos const& cp) /*override*/;
164 // NOLINTEND
165
166public:
167 // member functions
168 // NOLINTBEGIN
169 MCAPI DBChunkStorage(
170 ::std::unique_ptr<::ChunkSource> parent,
171 ::DBStorage& storage,
172 ::Scheduler& scheduler,
173 ::Experiments const& experiments
174 );
175
176 MCAPI void _batchDelete(
178 ::std::string const& key,
179 ::DBHelpers::Category category,
180 ::std::string_view reason
181 );
182
183 MCAPI void _batchPut(
185 ::std::string const& key,
186 ::std::string&& buffer,
187 ::DBHelpers::Category category,
188 ::std::string_view reason
189 );
190
191 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>> _cacheSeamlessChunkBlendingData(
192 ::ChunkPos chunkPos,
193 bool isCompleted,
194 ::std::shared_ptr<::BlendingData> blendingData
195 );
196
197 MCAPI bool
198 _checkSubChunksUseAbsoluteIndices(::DBChunkStorageKey key, ::LevelChunk const& lc, bool& flatworldsNeedFixup) const;
199
200 MCAPI void _deserializeIndependentActorStorage(::LevelChunk& lc, ::std::string const& storageKeyDigestBuffer);
201
202 MCAPI ::std::shared_ptr<::LevelStorageWriteBatch> _getBuffer();
203
204 MCAPI bool _hasChunk(::DBChunkStorageKey const& key);
205
206 MCAPI bool _hasChunkUncached(::DBChunkStorageKey const& key);
207
208 MCAPI ::std::pair<bool, ::std::unique_ptr<::PersistentBlendData>>
209 _levelChunkCanBeUsedForBlending(::DBChunkStorageKey const& lcKey);
210
211 MCAPI void _loadAndBlendFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
212
213 MCAPI bool _loadChunkFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
214
215 MCAPI void _saveBlendData(
217 ::std::string_view prefix,
218 ::std::string& buffer,
220 ) const;
221
222 MCAPI void
223 _serializeChunk(::LevelChunk& lc, ::LevelStorageWriteBatch& batch, bool markEntitiesProcesedOnChunkDiscard);
224
225 MCAPI void _serializeEntities(
226 ::LevelChunk& lc,
228 ::std::string& buffer,
229 bool markEntitiesProcesedOnChunkDiscard
230 );
231
232 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>>
233 _tryGetBlendingDataForChunk(::ChunkPos const& checkPosition);
234
235 MCAPI ::std::string _upgradeActorStorage(::ChunkKey chunkKey, ::std::string_view& legacyActorData);
236
237 MCAPI void
238 _writeActorDigest(::LevelStorageWriteBatch& batch, ::ChunkKey const& chunkKey, ::std::string const& digestBuffer);
239
240 MCAPI void _writeDiscardChunksBatch();
241 // NOLINTEND
242
243public:
244 // static functions
245 // NOLINTBEGIN
246 MCAPI static ::std::vector<::std::string> _deserializeChunkActorStorageKeys(::IDataInput& digestStream);
247
248 MCAPI static ::ConsoleChunkBlender::BlenderMode
249 _getBlenderMode(::LevelChunk const& lc, ::Experiments const& experiments);
250
251 MCAPI static ::std::string deserializeActorStorageToString(
252 bool hasActorDigestVersionTag,
253 ::std::string const& storageKeyDigestBuffer,
254 ::std::function<bool(::std::string_view, ::std::string&)> loadDataCallback
255 );
256 // NOLINTEND
257
258public:
259 // static variables
260 // NOLINTBEGIN
261 MCAPI static ::LevelStorageWriteBatch& threadBatch();
262
263 MCAPI static ::std::string& threadBuffer();
264 // NOLINTEND
265
266public:
267 // constructor thunks
268 // NOLINTBEGIN
269 MCAPI void* $ctor(
270 ::std::unique_ptr<::ChunkSource> parent,
271 ::DBStorage& storage,
272 ::Scheduler& scheduler,
273 ::Experiments const& experiments
274 );
275 // NOLINTEND
276
277public:
278 // destructor thunk
279 // NOLINTBEGIN
280 MCAPI void $dtor();
281 // NOLINTEND
282
283public:
284 // virtual function thunks
285 // NOLINTBEGIN
286 MCAPI void $shutdown();
287
288 MCAPI bool $isShutdownDone();
289
290 MCAPI void $loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
291
292 MCFOLD bool $isChunkKnown(::ChunkPos const& chunkPos);
293
294 MCFOLD bool $isChunkSaved(::ChunkPos const& chunkPos);
295
296 MCAPI bool $structurePostProcessChunk(::ChunkViewSource& neighborhood);
297
298 MCAPI bool $decorationPostProcessChunk(::ChunkViewSource& neighborhood);
299
300 MCAPI void $checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
301
302 MCAPI bool $verifyChunkNeedsNeighborAwareUpgrade(::LevelChunk& lc);
303
304 MCAPI void $neighborAwareChunkUpgrade(::LevelChunk& levelChunk, ::ChunkViewSource& neighborhood);
305
306 MCAPI bool $saveLiveChunk(::LevelChunk& lc);
307
308 MCAPI void $writeEntityChunkTransfer(::LevelChunk& lc);
309
310 MCAPI void $writeEntityChunkTransfersToUnloadedChunk(
311 ::ChunkKey const& chunkKey,
312 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
313 );
314
315 MCAPI void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
316
317 MCAPI void $hintDiscardBatchBegin();
318
319 MCAPI void $hintDiscardBatchEnd();
320
321 MCAPI void $flushPendingDiscardedChunkWrites();
322
323 MCAPI void $flushThreadBatch();
324
325 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
326
327 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
328
329 MCAPI void $deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
330
331 MCAPI bool $chunkPosNeedsBlending(::ChunkPos const& cp);
332 // NOLINTEND
333
334public:
335 // vftables
336 // NOLINTBEGIN
337 MCNAPI static void** $vftable();
338 // NOLINTEND
339};
Definition BaseGameVersion.h:8
Definition BlendingDataProvider.h:5
Definition BlendingData.h:5
Definition ChunkKey.h:14
Definition ChunkPos.h:11
Definition ChunkSource.h:36
Definition ChunkViewSource.h:22
Definition DBChunkStorageKey.h:13
Definition DBChunkStorage.h:33
static MCAPI void ** $vftable()
Definition DBStorage.h:40
Definition Experiments.h:14
Definition IDataInput.h:8
Definition LevelChunkMetaDataDictionary.h:11
Definition LevelChunk.h:78
Definition LevelStorageWriteBatch.h:14
Definition Scheduler.h:13
Definition TaskGroup.h:53
Definition ActorUnloadedChunkTransferEntry.h:13
Definition DBChunkStorage.h:41
Definition LevelChunkFinalDeleter.h:5
Definition PersistentBlendData.h:8
Definition buffer.h:5
Definition Alias.h:14