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/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: 11
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 postProcess(::ChunkViewSource& neighborhood) /*override*/;
113
114 // vIndex: 10
115 virtual void checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc) /*override*/;
116
117 // vIndex: 14
118 virtual bool saveLiveChunk(::LevelChunk& lc) /*override*/;
119
120 // vIndex: 15
121 virtual void writeEntityChunkTransfer(::LevelChunk& lc) /*override*/;
122
123 // vIndex: 16
124 virtual void writeEntityChunkTransfersToUnloadedChunk(
125 ::ChunkKey const& chunkKey,
126 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
127 ) /*override*/;
128
129 // vIndex: 20
130 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr) /*override*/;
131
132 // vIndex: 18
133 virtual void hintDiscardBatchBegin() /*override*/;
134
135 // vIndex: 19
136 virtual void hintDiscardBatchEnd() /*override*/;
137
138 // vIndex: 22
139 virtual void flushPendingDiscardedChunkWrites() /*override*/;
140
141 // vIndex: 23
142 virtual void flushThreadBatch() /*override*/;
143
144 // vIndex: 29
145 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider() /*override*/;
146
147 // vIndex: 30
148 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary() /*override*/;
149
150 // vIndex: 17
151 virtual void deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk) /*override*/;
152
153 // vIndex: 33
154 virtual bool chunkPosNeedsBlending(::ChunkPos const& cp) /*override*/;
155 // NOLINTEND
156
157public:
158 // member functions
159 // NOLINTBEGIN
160 MCAPI DBChunkStorage(
161 ::std::unique_ptr<::ChunkSource> parent,
162 ::DBStorage& storage,
163 ::Scheduler& scheduler,
164 ::Experiments const& experiments
165 );
166
167 MCAPI void _batchDelete(
169 ::std::string const& key,
170 ::DBHelpers::Category category,
171 ::std::string_view reason
172 );
173
174 MCAPI void _batchPut(
176 ::std::string const& key,
177 ::std::string&& buffer,
178 ::DBHelpers::Category category,
179 ::std::string_view reason
180 );
181
182 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>> _cacheSeamlessChunkBlendingData(
183 ::ChunkPos chunkPos,
184 bool isCompleted,
185 ::std::shared_ptr<::BlendingData> blendingData
186 );
187
188 MCAPI bool
189 _checkSubChunksUseAbsoluteIndices(::DBChunkStorageKey key, ::LevelChunk const& lc, bool& flatworldsNeedFixup) const;
190
191 MCAPI void _deserializeIndependentActorStorage(::LevelChunk& lc, ::std::string const& storageKeyDigestBuffer);
192
193 MCAPI ::std::shared_ptr<::LevelStorageWriteBatch> _getBuffer();
194
195 MCAPI bool _hasChunk(::DBChunkStorageKey const& key);
196
197 MCAPI bool _hasChunkUncached(::DBChunkStorageKey const& key);
198
199 MCAPI ::std::pair<bool, ::std::unique_ptr<::PersistentBlendData>>
200 _levelChunkCanBeUsedForBlending(::DBChunkStorageKey const& lcKey);
201
202 MCAPI void _loadAndBlendFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
203
204 MCAPI bool _loadChunkFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
205
206 MCAPI void _saveBlendData(
208 ::std::string_view prefix,
209 ::std::string& buffer,
211 ) const;
212
213 MCAPI void
214 _serializeChunk(::LevelChunk& lc, ::LevelStorageWriteBatch& batch, bool markEntitiesProcesedOnChunkDiscard);
215
216 MCAPI void _serializeEntities(
217 ::LevelChunk& lc,
219 ::std::string& buffer,
220 bool markEntitiesProcesedOnChunkDiscard
221 );
222
223 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>>
224 _tryGetBlendingDataForChunk(::ChunkPos const& checkPosition);
225
226 MCAPI ::std::string _upgradeActorStorage(::ChunkKey chunkKey, ::std::string_view& legacyActorData);
227
228 MCAPI void
229 _writeActorDigest(::LevelStorageWriteBatch& batch, ::ChunkKey const& chunkKey, ::std::string const& digestBuffer);
230
231 MCAPI void _writeDiscardChunksBatch();
232 // NOLINTEND
233
234public:
235 // static functions
236 // NOLINTBEGIN
237 MCAPI static ::std::vector<::std::string> _deserializeChunkActorStorageKeys(::IDataInput& digestStream);
238
239 MCAPI static ::ConsoleChunkBlender::BlenderMode
240 _getBlenderMode(::LevelChunk const& lc, ::Experiments const& experiments);
241
242 MCAPI static ::std::string deserializeActorStorageToString(
243 bool hasActorDigestVersionTag,
244 ::std::string const& storageKeyDigestBuffer,
245 ::std::function<bool(::std::string_view, ::std::string&)> loadDataCallback
246 );
247 // NOLINTEND
248
249public:
250 // static variables
251 // NOLINTBEGIN
252 MCAPI static ::LevelStorageWriteBatch& threadBatch();
253
254 MCAPI static ::std::string& threadBuffer();
255 // NOLINTEND
256
257public:
258 // constructor thunks
259 // NOLINTBEGIN
260 MCAPI void* $ctor(
261 ::std::unique_ptr<::ChunkSource> parent,
262 ::DBStorage& storage,
263 ::Scheduler& scheduler,
264 ::Experiments const& experiments
265 );
266 // NOLINTEND
267
268public:
269 // destructor thunk
270 // NOLINTBEGIN
271 MCAPI void $dtor();
272 // NOLINTEND
273
274public:
275 // virtual function thunks
276 // NOLINTBEGIN
277 MCAPI void $shutdown();
278
279 MCAPI bool $isShutdownDone();
280
281 MCAPI void $loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
282
283 MCFOLD bool $isChunkKnown(::ChunkPos const& chunkPos);
284
285 MCFOLD bool $isChunkSaved(::ChunkPos const& chunkPos);
286
287 MCAPI bool $postProcess(::ChunkViewSource& neighborhood);
288
289 MCAPI void $checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
290
291 MCAPI bool $saveLiveChunk(::LevelChunk& lc);
292
293 MCAPI void $writeEntityChunkTransfer(::LevelChunk& lc);
294
295 MCAPI void $writeEntityChunkTransfersToUnloadedChunk(
296 ::ChunkKey const& chunkKey,
297 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
298 );
299
300 MCAPI void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
301
302 MCAPI void $hintDiscardBatchBegin();
303
304 MCAPI void $hintDiscardBatchEnd();
305
306 MCAPI void $flushPendingDiscardedChunkWrites();
307
308 MCAPI void $flushThreadBatch();
309
310 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
311
312 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
313
314 MCAPI void $deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
315
316 MCAPI bool $chunkPosNeedsBlending(::ChunkPos const& cp);
317 // NOLINTEND
318
319public:
320 // vftables
321 // NOLINTBEGIN
322 MCNAPI static void** $vftable();
323 // NOLINTEND
324};
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:33
static MCAPI void ** $vftable()
Definition DBStorage.h:40
Definition Experiments.h:14
Definition IDataInput.h:8
Definition LevelChunkMetaDataDictionary.h:11
Definition LevelChunk.h:77
Definition LevelStorageWriteBatch.h:14
Definition Scheduler.h:13
Definition TaskGroup.h:48
Definition ActorUnloadedChunkTransferEntry.h:13
Definition DBChunkStorage.h:41
Definition LevelChunkFinalDeleter.h:5
Definition PersistentBlendData.h:8
Definition buffer.h:5
Definition Alias.h:14