From 9ef634559f3cde232586b1dc6fd00bea3f3d8e53 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 10 Jul 2011 06:17:06 +0000 Subject: * Merged changes from trunk [14827:14894/trunk]. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/branches/renewal@14895 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/grfio.c | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) (limited to 'src/common/grfio.c') diff --git a/src/common/grfio.c b/src/common/grfio.c index e7549ecb4..cb242fe5d 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -1,19 +1,18 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include -#include -#include -#include - -#include "grfio.h" - #include "../common/cbasetypes.h" #include "../common/showmsg.h" #include "../common/malloc.h" #include "../common/strlib.h" #include "../common/utils.h" +#include "grfio.h" +#include +#include +#include +#include +#include //---------------------------- // file entry table struct @@ -221,6 +220,23 @@ unsigned long grfio_crc32 (const unsigned char* buf, unsigned int len) return crc32(crc32(0L, Z_NULL, 0), buf, len); } + +/////////////////////////////////////////////////////////////////////////////// +/// Grf data sub : zip decode +int decode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) +{ + return uncompress(dest, destLen, source, sourceLen); +} + + +/////////////////////////////////////////////////////////////////////////////// +/// Grf data sub : zip encode +int encode_zip(unsigned char* dest, unsigned long* destLen, const unsigned char* source, unsigned long sourceLen) +{ + return compress(dest, destLen, source, sourceLen); +} + + /*********************************************************** *** File List Subroutines *** ***********************************************************/ @@ -431,9 +447,9 @@ void* grfio_reads(char* fname, int* size) if (entry->cycle >= 0) decode_des_etc(buf, entry->srclen_aligned, entry->cycle == 0, entry->cycle); len = entry->declen; - uncompress(buf2, &len, buf, entry->srclen); + decode_zip(buf2, &len, buf, entry->srclen); if (len != (uLong)entry->declen) { - ShowError("uncompress size mismatch err: %d != %d\n", (int)len, entry->declen); + ShowError("decode_zip size mismatch err: %d != %d\n", (int)len, entry->declen); aFree(buf); aFree(buf2); return NULL; @@ -580,7 +596,7 @@ static int grfio_entryread(char* grfname, int gentry) grf_filelist = (unsigned char *)aMallocA(eSize); // Get a Extend Size fread(rBuf,1,rSize,fp); fclose(fp); - uncompress(grf_filelist, &eSize, rBuf, rSize); // Decode function + decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function list_size = eSize; aFree(rBuf); -- cgit v1.2.3-70-g09d2