Revert "Update to ZSTD"

This reverts commit f3a175c640.
This commit is contained in:
GabsPuNs
2026-06-05 20:21:06 -04:00
parent f3a175c640
commit 90cf815860
12 changed files with 131 additions and 65 deletions

View File

@@ -29,10 +29,18 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
MemSect(31);
File file;
if(useSplitSaves(saveFile->getSavePlatform()))
file = File(prefix + wstring(L"r.") + std::to_wstring(chunkX >> 4) + L"." + std::to_wstring(chunkZ >> 4) + L".mcr");
else
file = File( prefix + wstring(L"r.") + std::to_wstring(chunkX>>5) + L"." + std::to_wstring(chunkZ>>5) + L".mcr" );
{
bool isNew = saveFile->doesFileExist(ConsoleSavePath(L"region_format_16"));
if (isNew)
file = File(prefix + wstring(L"r.") + std::to_wstring(chunkX >> 4) + L"." + std::to_wstring(chunkZ >> 4) + L".mcr");
else
file = File(prefix + wstring(L"r.") + std::to_wstring(chunkX >> 5) + L"." + std::to_wstring(chunkZ >> 5) + L".mcr");
}
else
{
file = File( prefix + wstring(L"r.") + std::to_wstring(chunkX>>5) + L"." + std::to_wstring(chunkZ>>5) + L".mcr" );
}
MemSect(0);
RegionFile *ref = nullptr;
@@ -49,15 +57,19 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst
// 4J Stu - Remove for new save files
/*
if (!regionDir.exists())
{
regionDir.mkdirs();
}
*/
if (cache.size() >= MAX_CACHE_SIZE)
{
_clear();
}
RegionFile *reg = new RegionFile(saveFile, &file);
cache[file] = reg; // 4J - this was originally a softReferenc
return reg;
}
void RegionFileCache::_clear() // 4J - TODO was synchronized
@@ -66,8 +78,9 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized
{
RegionFile *regionFile = it.second;
if (regionFile != nullptr)
{
regionFile->close();
}
delete regionFile;
}
cache.clear();
@@ -82,21 +95,34 @@ int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const wstring &pre
DataInputStream *RegionFileCache::_getChunkDataInputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
{
RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ);
if (useSplitSaves(saveFile->getSavePlatform()))
bool isNew = saveFile->doesFileExist(ConsoleSavePath(L"region_format_16"));
if (useSplitSaves(saveFile->getSavePlatform()) && isNew)
{
return r->getChunkDataInputStream(chunkX & 15, chunkZ & 15);
}
else
{
return r->getChunkDataInputStream(chunkX & 31, chunkZ & 31);
}
}
DataOutputStream *RegionFileCache::_getChunkDataOutputStream(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ)
{
RegionFile* r = _getRegionFile(saveFile, prefix, chunkX, chunkZ);
if (useSplitSaves(saveFile->getSavePlatform()))
bool isNew = saveFile->doesFileExist(ConsoleSavePath(L"region_format_16"));
if (useSplitSaves(saveFile->getSavePlatform()) && isNew)
{
return r->getChunkDataOutputStream(chunkX & 15, chunkZ & 15);
}
else
{
return r->getChunkDataOutputStream(chunkX & 31, chunkZ & 31);
}
}
RegionFileCache::~RegionFileCache()
{
_clear();