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