diff options
| author | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
|---|---|---|
| committer | daoge_cmd <3523206925@qq.com> | 2026-03-01 12:16:08 +0800 |
| commit | b691c43c44ff180d10e7d4a9afc83b98551ff586 (patch) | |
| tree | 3e9849222cbc6ba49f2f1fc6e5fe7179632c7390 /Minecraft.World/RegionFileCache.h | |
| parent | def8cb415354ac390b7e89052a50605285f1aca9 (diff) | |
Initial commit
Diffstat (limited to 'Minecraft.World/RegionFileCache.h')
| -rw-r--r-- | Minecraft.World/RegionFileCache.h | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Minecraft.World/RegionFileCache.h b/Minecraft.World/RegionFileCache.h new file mode 100644 index 00000000..03e576cc --- /dev/null +++ b/Minecraft.World/RegionFileCache.h @@ -0,0 +1,35 @@ +#pragma once +#include "RegionFile.h" +#include "Reference.h" +#include "File.h" + +class RegionFileCache +{ + friend class ConsoleSaveFileOriginal; +private: + static const int MAX_CACHE_SIZE = 256; + + unordered_map<File, RegionFile *, FileKeyHash, FileKeyEq> cache; + + static RegionFileCache s_defaultCache; + +public: + // Made public and non-static so we can have a cache for input and output files + RegionFileCache() {} + + RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized + void _clear(); // 4J - TODO was synchronized + int _getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); + DataInputStream *_getChunkDataInputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); + DataOutputStream *_getChunkDataOutputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); + + // Keep static version for general game usage + static RegionFile *getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getRegionFile(saveFile, prefix, chunkX, chunkZ); } + static void clear() { s_defaultCache._clear(); } + static int getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getSizeDelta(saveFile, prefix, chunkX, chunkZ); } + static DataInputStream *getChunkDataInputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getChunkDataInputStream(saveFile, prefix, chunkX, chunkZ); } + static DataOutputStream *getChunkDataOutputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) { return s_defaultCache._getChunkDataOutputStream(saveFile, prefix, chunkX, chunkZ); } + +private: + bool useSplitSaves(ESavePlatform platform); +}; |
