diff options
author | hemagx <hemagx2@gmail.com> | 2016-03-01 08:16:37 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-07-12 20:58:44 +0200 |
commit | d0358265beff02fd9c094ba480f1a9583035cf64 (patch) | |
tree | 6c8433dfda39ba19a721e66f70b0f11fce45eeeb /src/common/grfio.c | |
parent | b0a4a441f582810c91aeec458fdbe7cc6cc78db9 (diff) | |
download | hercules-d0358265beff02fd9c094ba480f1a9583035cf64.tar.gz hercules-d0358265beff02fd9c094ba480f1a9583035cf64.tar.bz2 hercules-d0358265beff02fd9c094ba480f1a9583035cf64.tar.xz hercules-d0358265beff02fd9c094ba480f1a9583035cf64.zip |
Interface grfio.c
Diffstat (limited to 'src/common/grfio.c')
-rw-r--r-- | src/common/grfio.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c index 7f860acc6..fdd599ae7 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -2,7 +2,7 @@ * This file is part of Hercules. * http://herc.ws - http://github.com/HerculesWS/Hercules * - * Copyright (C) 2012-2015 Hercules Dev Team + * Copyright (C) 2012-2016 Hercules Dev Team * Copyright (C) Athena Dev Teams * * Hercules is free software: you can redistribute it and/or modify @@ -76,6 +76,9 @@ int gentry_maxentry = 0; // the path to the data directory char data_dir[1024] = ""; +struct grfio_interface grfio_s; +struct grfio_interface *grfio; + // little endian char array to uint conversion static unsigned int getlong(unsigned char* p) { @@ -472,7 +475,7 @@ void *grfio_reads(const char *fname, int *size) uLongf len; grf_decode(buf, fsize, entry->type, entry->srclen); len = entry->declen; - decode_zip(buf2, &len, buf, entry->srclen); + grfio->decode_zip(buf2, &len, buf, entry->srclen); if (len != (uLong)entry->declen) { ShowError("decode_zip size mismatch err: %d != %d\n", (int)len, entry->declen); aFree(buf); @@ -639,7 +642,7 @@ static int grfio_entryread(const char *grfname, int gentry) } fclose(fp); grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size - decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function + grfio->decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function aFree(rBuf); entrys = getlong(grf_header+0x26) - 7; @@ -759,7 +762,7 @@ static void grfio_resourcecheck(void) } // read resnametable from loaded GRF's, only if it cannot be loaded from the data directory - buf = (char *)grfio_reads("data\\resnametable.txt", &size); + buf = grfio->reads("data\\resnametable.txt", &size); if( buf != NULL ) { char *ptr; @@ -871,3 +874,15 @@ void grfio_init(const char* fname) // Resource check grfio_resourcecheck(); } + +void grfio_defaults(void) +{ + grfio = &grfio_s; + grfio->init = grfio_init; + grfio->final = grfio_final; + grfio->reads = grfio_reads; + grfio->find_file = grfio_find_file; + grfio->crc32 = grfio_crc32; + grfio->decode_zip = decode_zip; + grfio->encode_zip = encode_zip; +} |