added 360 support and fixed vita again again

This commit is contained in:
552eden
2026-08-13 00:04:53 +03:00
parent 92891de261
commit 1005e64629
17 changed files with 591 additions and 208 deletions
+41 -6
View File
@@ -1,6 +1,6 @@
#include "stdafx.h"
#include "compression.h"
#if defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64
#if defined __ORBIS__ || defined __PS3__ || defined _DURANGO || defined _WIN64 || defined _XBOX
#include "..\Minecraft.Client\Common\zlib\zlib.h"
#endif
@@ -54,7 +54,7 @@ Compression *Compression::getCompression()
return tls->compression;
}
HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize, bool bForceZlib)
{
EnterCriticalSection(&rleCompressLock);
//static unsigned char rleBuf[1024*100];
@@ -105,7 +105,8 @@ HRESULT Compression::CompressLZXRLE(void *pDestination, unsigned int *pDestSize,
PIXEndNamedEvent();
PIXBeginNamedEvent(0,"Secondary compression");
Compress(pDestination, pDestSize, rleCompressBuf, rleSize);
if( bForceZlib ) CompressZlib(pDestination, pDestSize, rleCompressBuf, rleSize);
else Compress(pDestination, pDestSize, rleCompressBuf, rleSize);
PIXEndNamedEvent();
LeaveCriticalSection(&rleCompressLock);
// printf("Compressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize);
@@ -180,7 +181,7 @@ HRESULT Compression::CompressRLE(void *pDestination, unsigned int *pDestSize, vo
return S_OK;
}
HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize, bool bForceZlib)
{
EnterCriticalSection(&rleDecompressLock);
// 4J Stu - Fix for #13676 - Crash: Crash while attempting to load a world after updating TU
@@ -200,12 +201,14 @@ HRESULT Compression::DecompressLZXRLE(void *pDestination, unsigned int *pDestSiz
{
rleSize = *pDestSize;
dynamicRleBuf = new unsigned char[rleSize];
Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize);
if( bForceZlib ) DecompressZlib(dynamicRleBuf, &rleSize, pSource, SrcSize);
else Decompress(dynamicRleBuf, &rleSize, pSource, SrcSize);
pucIn = (unsigned char *)dynamicRleBuf;
}
else
{
Decompress(rleDecompressBuf, &rleSize, pSource, SrcSize);
if( bForceZlib ) DecompressZlib(rleDecompressBuf, &rleSize, pSource, SrcSize);
else Decompress(rleDecompressBuf, &rleSize, pSource, SrcSize);
pucIn = (unsigned char *)rleDecompressBuf;
}
@@ -297,8 +300,40 @@ HRESULT Compression::DecompressRLE(void *pDestination, unsigned int *pDestSize,
}
// zlib on every platform.
HRESULT Compression::CompressZlib(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
{
#if defined __PS3__
uint32_t destSize = (uint32_t)(*pDestSize);
bool res = EdgeZLib::Compress(pDestination, &destSize, pSource, SrcSize);
*pDestSize = (unsigned int)destSize;
return ( ( res ) ? S_OK : -1 );
#else
uLongf destSize = (uLongf)(*pDestSize);
int res = ::compress((Bytef *)pDestination, &destSize, (Bytef *)pSource, SrcSize);
*pDestSize = (unsigned int)destSize;
return ( ( res == Z_OK ) ? S_OK : -1 );
#endif
}
HRESULT Compression::DecompressZlib(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
{
#if defined __PS3__
uLongf destSize = (uLongf)(*pDestSize);
bool res = uncompress((Bytef *)pDestination, &destSize, (Bytef *)pSource, SrcSize);
*pDestSize = (unsigned int)destSize;
return ( ( res ) ? S_OK : -1 );
#else
uLongf destSize = (uLongf)(*pDestSize);
int res = ::uncompress((Bytef *)pDestination, &destSize, (Bytef *)pSource, SrcSize);
*pDestSize = (unsigned int)destSize;
return ( ( res == Z_OK ) ? S_OK : -1 );
#endif
}
HRESULT Compression::Compress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize)
{
//THIS IS THE OLD IMPL. USE HRESULT Compression::CompressZlib()
// Using zlib for x64 compression - 360 is using native 360 compression and PS3 a stubbed non-compressing version of this
#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__
SIZE_T destSize = (SIZE_T)(*pDestSize);