Skip to content

Commit 3dd79d9

Browse files
committed
Merge pull request #1379 from actinism/v3.5.0
Compatibility with latest TexturePacker SpriteSheets Using PVR+zlib
2 parents c6311e3 + 8577abf commit 3dd79d9

File tree

2 files changed

+416
-213
lines changed

2 files changed

+416
-213
lines changed

cocos2d/Support/ZipUtils.h

+48-21
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
* http://themanaworld.org/
1111
* from the mapreader.cpp file
1212
*
13+
* Some modifications were taken from:
14+
* https://www.codeandweb.com/texturepacker/contentprotection
15+
*
1316
*/
14-
17+
1518
#ifndef __CC_ZIP_UTILS_H
1619
#define __CC_ZIP_UTILS_H
1720

@@ -21,61 +24,85 @@
2124
extern "C" {
2225
#endif
2326

24-
/* XXX: pragma pack ??? */
25-
/** @struct CCZHeader
26-
*/
27-
struct CCZHeader {
28-
uint8_t sig[4]; // signature. Should be 'CCZ!' 4 bytes
29-
uint16_t compression_type; // should 0
30-
uint16_t version; // should be 2 (although version type==1 is also supported)
31-
uint32_t reserved; // Reserved for users.
32-
uint32_t len; // size of the uncompressed file
33-
};
27+
/**
28+
* Set the TexturePacker encryption key
29+
*
30+
* If your key used to encrypt the pvr.ccz file is
31+
* aaaaaaaabbbbbbbbccccccccdddddddd
32+
* you have to call this function 4 times:
33+
* caw_setkey_part(0, 0xaaaaaaaa);
34+
* caw_setkey_part(1, 0xbbbbbbbb);
35+
* caw_setkey_part(2, 0xcccccccc);
36+
* caw_setkey_part(3, 0xdddddddd);
37+
*
38+
* Distribute the call accross some files but make sure
39+
* to call all of the parts *before* loading the first
40+
* spritesheet.
41+
*
42+
* @param index part of the key [0..3]
43+
* @param value value of the key part
44+
*/
45+
void caw_setkey_part(int index, uint32_t value);
46+
47+
/* XXX: pragma pack ??? */
48+
/** @struct CCZHeader
49+
*/
50+
struct CCZHeader {
51+
uint8_t sig[4]; // signature. Should be 'CCZ!' 4 bytes
52+
uint16_t compression_type; // should 0
53+
uint16_t version; // should be 2 (although version type==1 is also supported)
54+
uint32_t reserved; // Reserverd for users.
55+
uint32_t len; // size of the uncompressed file
56+
};
3457

35-
enum {
36-
CCZ_COMPRESSION_ZLIB, // zlib format.
37-
CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet)
38-
CCZ_COMPRESSION_GZIP, // gzip format (not supported yet)
39-
CCZ_COMPRESSION_NONE, // plain (not supported yet)
40-
};
58+
enum {
59+
CCZ_COMPRESSION_ZLIB, // zlib format.
60+
CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet)
61+
CCZ_COMPRESSION_GZIP, // gzip format (not supported yet)
62+
CCZ_COMPRESSION_NONE, // plain (not supported yet)
63+
};
4164

4265
/** @file
4366
* Zip helper functions
4467
*/
45-
68+
4669
/**
4770
* Inflates either zlib or gzip deflated memory. The inflated memory is
4871
* expected to be freed by the caller.
4972
*
50-
* It will allocate 256k for the destination buffer. If it is not enough it will multiply the previous buffer size per 2, until there is enough memory.
73+
* It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory.
5174
* @returns the length of the deflated buffer
5275
*
76+
@since v0.8.1
5377
*/
5478
int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out);
5579

5680
/**
5781
* Inflates either zlib or gzip deflated memory. The inflated memory is
5882
* expected to be freed by the caller.
5983
*
60-
* outlengthHint is assumed to be the needed room to allocate the inflated buffer.
84+
* outLengthHint is assumed to be the needed room to allocate the inflated buffer.
6185
*
6286
* @returns the length of the deflated buffer
6387
*
88+
@since v1.0.0
6489
*/
65-
int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outlengthHint );
90+
int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLengthHint );
6691

6792

6893
/** inflates a GZip file into memory
6994
*
7095
* @returns the length of the deflated buffer
7196
*
97+
* @since v0.99.5
7298
*/
7399
int ccInflateGZipFile(const char *filename, unsigned char **out);
74100

75101
/** inflates a CCZ file into memory
76102
*
77103
* @returns the length of the deflated buffer
78104
*
105+
* @since v0.99.5
79106
*/
80107
int ccInflateCCZFile(const char *filename, unsigned char **out);
81108

0 commit comments

Comments
 (0)