From d0358265beff02fd9c094ba480f1a9583035cf64 Mon Sep 17 00:00:00 2001 From: hemagx Date: Tue, 1 Mar 2016 08:16:37 +0200 Subject: Interface grfio.c --- src/common/grfio.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'src/common/grfio.c') 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; +} -- cgit v1.2.3-70-g09d2