summaryrefslogtreecommitdiff
path: root/src/common/grfio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/grfio.c')
-rw-r--r--src/common/grfio.c24
1 files changed, 1 insertions, 23 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 614678da8..b59c2b63d 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -47,7 +47,6 @@ typedef struct FILELIST {
// (NOTE: probably meant to be used to override grf contents by files in the data directory)
//#define GRFIO_LOCAL
-
// stores info about every loaded file
FILELIST* filelist = NULL;
int filelist_entrys = 0;
@@ -61,14 +60,12 @@ int gentry_maxentry = 0;
// the path to the data directory
char data_dir[1024] = "";
-
// little endian char array to uint conversion
static unsigned int getlong(unsigned char* p)
{
return (p[0] << 0 | p[1] << 8 | p[2] << 16 | p[3] << 24);
}
-
static void NibbleSwap(unsigned char* src, int len)
{
while( len > 0 )
@@ -79,7 +76,6 @@ static void NibbleSwap(unsigned char* src, int len)
}
}
-
/// Substitutes some specific values for others, leaves rest intact. Obfuscation.
/// NOTE: Operation is symmetric (calling it twice gives back the original input).
static uint8_t grf_substitution(uint8_t in)
@@ -142,7 +138,6 @@ static void grf_shuffle_dec(BIT64* src)
*src = out;
}
-
static void grf_decode_header(unsigned char* buf, size_t len)
{
BIT64* p = (BIT64*)buf;
@@ -156,7 +151,6 @@ static void grf_decode_header(unsigned char* buf, size_t len)
// the rest is plaintext, done.
}
-
static void grf_decode_full(unsigned char* buf, size_t len, int cycle)
{
BIT64* p = (BIT64*)buf;
@@ -195,7 +189,6 @@ static void grf_decode_full(unsigned char* buf, size_t len, int cycle)
}
}
-
/// Decodes grf data.
/// @param buf data to decode (in-place)
/// @param len length of the data
@@ -235,7 +228,6 @@ static void grf_decode(unsigned char* buf, size_t len, char entry_type, int entr
}
}
-
/******************************************************
*** Zlib Subroutines ***
******************************************************/
@@ -246,14 +238,12 @@ unsigned long grfio_crc32(const unsigned char* buf, unsigned int len)
return crc32(crc32(0L, Z_NULL, 0), buf, len);
}
-
/// zlib uncompress
int decode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen)
{
return uncompress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen);
}
-
/// zlib compress
int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned long sourceLen) {
if( *destLen == 0 ) /* [Ind/Hercules] */
@@ -264,7 +254,6 @@ int encode_zip(void* dest, unsigned long* destLen, const void* source, unsigned
return compress((Bytef*)dest, destLen, (const Bytef*)source, sourceLen);
}
-
/***********************************************************
*** File List Subroutines ***
***********************************************************/
@@ -370,12 +359,10 @@ static void filelist_compact(void)
}
}
-
/***********************************************************
*** Grfio Subroutines ***
***********************************************************/
-
/// Combines are resource path with the data folder location to create local resource path.
static void grfio_localpath_create(char* buffer, size_t size, const char* filename)
{
@@ -399,7 +386,6 @@ static void grfio_localpath_create(char* buffer, size_t size, const char* filena
buffer[i] = '/';
}
-
/// Reads a file into a newly allocated buffer (from grf or data directory).
void *grfio_reads(const char *fname, int *size)
{
@@ -449,7 +435,7 @@ void *grfio_reads(const char *fname, int *size)
// Archive[GRF] File Read
char *grfname = gentry_table[entry->gentry - 1];
FILE *in = fopen(grfname, "rb");
-
+
if (in != NULL) {
int fsize = entry->srclen_aligned;
unsigned char *buf = (unsigned char *)aMalloc(fsize);
@@ -496,7 +482,6 @@ void *grfio_reads(const char *fname, int *size)
return NULL;
}
-
/// Decodes encrypted filename from a version 01xx grf index.
static char* decode_filename(unsigned char* buf, int len)
{
@@ -508,7 +493,6 @@ static char* decode_filename(unsigned char* buf, int len)
return (char*)buf;
}
-
/// Compares file extension against known large file types.
/// @return true if the file should undergo full mode 0 decryption, and true otherwise.
static bool isFullEncrypt(const char* fname)
@@ -525,7 +509,6 @@ static bool isFullEncrypt(const char* fname)
return true;
}
-
/// Loads all entries in the specified grf file into the filelist.
/// @param gentry index of the grf file name in the gentry_table
static int grfio_entryread(const char *grfname, int gentry)
@@ -691,7 +674,6 @@ static int grfio_entryread(const char *grfname, int gentry)
return 0; // 0:no error
}
-
static bool grfio_parse_restable_row(const char* row)
{
char w1[256], w2[256];
@@ -733,7 +715,6 @@ static bool grfio_parse_restable_row(const char* row)
return false;
}
-
/// Grfio Resource file check.
static void grfio_resourcecheck(void)
{
@@ -785,7 +766,6 @@ static void grfio_resourcecheck(void)
}
}
-
/// Reads a grf file and adds it to the list.
static int grfio_add(const char* fname)
{
@@ -802,7 +782,6 @@ static int grfio_add(const char* fname)
return grfio_entryread(fname, gentry_entrys - 1);
}
-
/// Finalizes grfio.
void grfio_final(void)
{
@@ -829,7 +808,6 @@ void grfio_final(void)
gentry_entrys = gentry_maxentry = 0;
}
-
/// Initializes grfio.
void grfio_init(const char* fname)
{