the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#pragma once
2#include "FileHeader.h"
3
4#ifdef _XBOX_ONE
5#include "..\Minecraft.Client\Durango\DurangoExtras\xcompress.h"
6#endif
7
8class Compression
9{
10public:
11 // Enum maps directly some external tools
12 enum ECompressionTypes
13 {
14 eCompressionType_None = 0,
15 eCompressionType_RLE = 1,
16 eCompressionType_LZXRLE = 2,
17 eCompressionType_ZLIBRLE = 3,
18 eCompressionType_PS3ZLIB = 4
19 };
20
21private:
22 // 4J added so we can have separate contexts and rleBuf for different threads
23 class ThreadStorage
24 {
25 public:
26 Compression *compression;
27 ThreadStorage();
28 ~ThreadStorage();
29 };
30 static DWORD tlsIdx;
31 static ThreadStorage *tlsDefault;
32public:
33 // Each new thread that needs to use Compression will need to call one of the following 2 functions, to either create its own
34 // local storage, or share the default storage already allocated by the main thread
35 static void CreateNewThreadStorage();
36 static void UseDefaultThreadStorage();
37 static void ReleaseThreadStorage();
38
39 static Compression *getCompression();
40
41public:
42 HRESULT Compress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
43 HRESULT Decompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
44 HRESULT CompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
45 HRESULT DecompressLZXRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
46 HRESULT CompressRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
47 HRESULT DecompressRLE(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
48#ifndef _XBOX
49 static VOID VitaVirtualDecompress(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
50#endif
51
52 void SetDecompressionType(ECompressionTypes type) { m_decompressType = type; } // for loading a save from a different platform (Sony cloud storage cross play)
53 ECompressionTypes GetDecompressionType() { return m_decompressType; }
54 void SetDecompressionType(ESavePlatform platform);
55
56 Compression();
57 ~Compression();
58private:
59
60 HRESULT DecompressWithType(void *pDestination, unsigned int *pDestSize, void *pSource, unsigned int SrcSize);
61
62#if defined __ORBIS__ || defined __PS3__
63#else
64 XMEMCOMPRESSION_CONTEXT compressionContext;
65 XMEMDECOMPRESSION_CONTEXT decompressionContext;
66#endif
67 CRITICAL_SECTION rleCompressLock;
68 CRITICAL_SECTION rleDecompressLock;
69
70 unsigned char rleCompressBuf[1024*100];
71 static const unsigned int staticRleSize = 1024*200;
72 unsigned char rleDecompressBuf[staticRleSize];
73 ECompressionTypes m_decompressType;
74 ECompressionTypes m_localDecompressType;
75
76};
77
78//extern Compression gCompression;
79
80#if defined __ORBIS__ || defined _DURANGO || defined _WIN64 || defined __PSVITA__
81#define APPROPRIATE_COMPRESSION_TYPE Compression::eCompressionType_ZLIBRLE
82#elif defined __PS3__
83#define APPROPRIATE_COMPRESSION_TYPE Compression::eCompressionType_PS3ZLIB
84#else
85#define APPROPRIATE_COMPRESSION_TYPE Compression::eCompressionType_LZXRLE
86#endif