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
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& levelChunk) /*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 ::std::pair<bool, ::std::shared_ptr<::BlendingData>> _cacheSeamlessChunkBlendingData(
168 ::ChunkPos chunkPos,
169 bool isCompleted,
170 ::std::shared_ptr<::BlendingData> blendingData
171 );
172
173 MCAPI bool
174 _checkSubChunksUseAbsoluteIndices(::DBChunkStorageKey key, ::LevelChunk const& lc, bool& flatworldsNeedFixup) const;
175
176 MCAPI void _deserializeIndependentActorStorage(::LevelChunk& lc, ::std::string const& storageKeyDigestBuffer);
177
178 MCAPI ::std::optional<::LevelChunkFormat> _getLevelChunkFormat(::std::string_view prefix, ::std::string& buffer);
179
180 MCAPI bool _hasChunk(::DBChunkStorageKey const& key);
181
182 MCAPI bool _hasChunkUncached(::DBChunkStorageKey const& key);
183
184 MCAPI ::std::pair<bool, ::std::unique_ptr<::PersistentBlendData>>
185 _levelChunkCanBeUsedForBlending(::DBChunkStorageKey const& lcKey);
186
187 MCAPI void _loadAndBlendFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
188
189 MCAPI bool _loadChunkFromDB(::LevelChunk& lc, ::LevelChunk& generatedChunk, ::ChunkViewSource& neighborhood);
190
191 MCAPI void _saveBlendData(
193 ::std::string_view prefix,
194 ::std::string& buffer,
196 ) const;
197
198 MCAPI void
199 _serializeChunk(::LevelChunk& lc, ::LevelStorageWriteBatch& batch, bool markEntitiesProcesedOnChunkDiscard);
200
201 MCAPI void _serializeEntities(
202 ::LevelChunk& lc,
204 ::std::string& buffer,
205 bool markEntitiesProcesedOnChunkDiscard
206 );
207
208 MCAPI ::std::pair<bool, ::std::shared_ptr<::BlendingData>>
209 _tryGetBlendingDataForChunk(::ChunkPos const& checkPosition);
210
211 MCAPI ::std::string _upgradeActorStorage(::ChunkKey chunkKey, ::std::string_view& legacyActorData);
212
213 MCAPI void
214 _writeActorDigest(::LevelStorageWriteBatch& batch, ::ChunkKey const& chunkKey, ::std::string const& digestBuffer);
215
216 MCAPI void _writeDiscardChunksBatch();
217 // NOLINTEND
218
219public:
220 // static functions
221 // NOLINTBEGIN
222 MCAPI static ::std::vector<::std::string> _deserializeChunkActorStorageKeys(::IDataInput& digestStream);
223
224 MCAPI static ::ConsoleChunkBlender::BlenderMode
225 _getBlenderMode(::LevelChunk const& lc, ::Experiments const& experiments);
226
227 MCAPI static ::std::string deserializeActorStorageToString(
228 bool hasActorDigestVersionTag,
229 ::std::string const& storageKeyDigestBuffer,
230 ::std::function<bool(::std::string_view, ::std::string&)> loadDataCallback
231 );
232 // NOLINTEND
233
234public:
235 // static variables
236 // NOLINTBEGIN
237 MCAPI static ::LevelStorageWriteBatch& threadBatch();
238
239 MCAPI static ::std::string& threadBuffer();
240 // NOLINTEND
241
242public:
243 // constructor thunks
244 // NOLINTBEGIN
245 MCAPI void* $ctor(
246 ::std::unique_ptr<::ChunkSource> parent,
247 ::DBStorage& storage,
248 ::Scheduler& scheduler,
249 ::Experiments const& experiments
250 );
251 // NOLINTEND
252
253public:
254 // destructor thunk
255 // NOLINTBEGIN
256 MCAPI void $dtor();
257 // NOLINTEND
258
259public:
260 // virtual function thunks
261 // NOLINTBEGIN
262 MCAPI void $shutdown();
263
264 MCAPI bool $isShutdownDone();
265
266 MCAPI void $loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
267
268 MCFOLD bool $isChunkKnown(::ChunkPos const& chunkPos);
269
270 MCFOLD bool $isChunkSaved(::ChunkPos const& chunkPos);
271
272 MCAPI bool $postProcess(::ChunkViewSource& neighborhood);
273
274 MCAPI void $checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
275
276 MCAPI bool $saveLiveChunk(::LevelChunk& lc);
277
278 MCAPI void $writeEntityChunkTransfer(::LevelChunk& levelChunk);
279
280 MCAPI void $writeEntityChunkTransfersToUnloadedChunk(
281 ::ChunkKey const& chunkKey,
282 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
283 );
284
285 MCAPI void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
286
287 MCAPI void $hintDiscardBatchBegin();
288
289 MCAPI void $hintDiscardBatchEnd();
290
291 MCAPI void $flushPendingDiscardedChunkWrites();
292
293 MCAPI void $flushThreadBatch();
294
295 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
296
297 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
298
299 MCAPI void $deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
300
301 MCAPI bool $chunkPosNeedsBlending(::ChunkPos const& cp);
302 // NOLINTEND
303
304public:
305 // vftables
306 // NOLINTBEGIN
307 MCNAPI static void** $vftable();
308 // NOLINTEND
309};
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:8
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:74
Definition LevelStorageWriteBatch.h:14
Definition Scheduler.h:13
Definition TaskGroup.h:104
Definition ActorUnloadedChunkTransferEntry.h:13
Definition DBChunkStorage.h:41
Definition LevelChunkFinalDeleter.h:5
Definition PersistentBlendData.h:13
Definition buffer.h:5
Definition Alias.h:14