From 35f6c6cfb89988885f6f2a647cc0fc8dac14f10e Mon Sep 17 00:00:00 2001 From: ai4rei Date: Sun, 2 Jan 2011 00:20:51 +0000 Subject: * Fixed local files could not be aliased with resnametable.txt in grfio (bugreport:2203, since r5152). git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14648 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/common/grfio.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/common/grfio.c b/src/common/grfio.c index 9f57f4e25..3c0960f30 100644 --- a/src/common/grfio.c +++ b/src/common/grfio.c @@ -13,6 +13,7 @@ #include "../common/showmsg.h" #include "../common/malloc.h" #include "../common/strlib.h" +#include "../common/utils.h" //---------------------------- @@ -458,7 +459,7 @@ void* grfio_reads(char* fname, int* size) char lfname[256]; int declen; - grfio_localpath_create(lfname, sizeof(lfname), fname); + grfio_localpath_create(lfname, sizeof(lfname), ( entry && entry->fnd ) ? entry->fnd : fname); in = fopen(lfname, "rb"); if (in != NULL) { @@ -708,9 +709,10 @@ static int grfio_entryread(char* grfname, int gentry) *------------------------------------------*/ static void grfio_resourcecheck(void) { - char w1[256], w2[256], src[256], dst[256], restable[256], line[256]; + char w1[256], w2[256], src[256], dst[256], restable[256], line[256], local[256]; char *ptr, *buf; FILELIST* entry; + FILELIST fentry; int size; FILE* fp; int i = 0; @@ -732,13 +734,26 @@ static void grfio_resourcecheck(void) // create new entries reusing the original's info if (entry != NULL) {// alias for GRF resource - FILELIST fentry; memcpy(&fentry, entry, sizeof(FILELIST)); safestrncpy(fentry.fn, src, sizeof(fentry.fn)); fentry.fnd = aStrdup(dst); filelist_modify(&fentry); i++; } + else + { + grfio_localpath_create(local, sizeof(local), dst); + + if( exists(local) ) + {// alias for local resource + memset(&fentry, 0, sizeof(fentry)); + //fentry.gentry = 0; + safestrncpy(fentry.fn, src, sizeof(fentry.fn)); + fentry.fnd = aStrdup(dst); + filelist_modify(&fentry); + i++; + } + } } } fclose(fp); @@ -761,13 +776,26 @@ static void grfio_resourcecheck(void) entry = filelist_find(dst); if (entry != NULL) {// alias for GRF resource - FILELIST fentry; memcpy(&fentry, entry, sizeof(FILELIST)); safestrncpy(fentry.fn, src, sizeof(fentry.fn)); fentry.fnd = aStrdup(dst); filelist_modify(&fentry); i++; } + else + { + grfio_localpath_create(local, sizeof(local), dst); + + if( exists(local) ) + {// alias for local resource + memset(&fentry, 0, sizeof(fentry)); + //fentry.gentry = 0; + safestrncpy(fentry.fn, src, sizeof(fentry.fn)); + fentry.fnd = aStrdup(dst); + filelist_modify(&fentry); + i++; + } + } } ptr = strchr(ptr, '\n'); // Next line if (!ptr) break; -- cgit v1.2.3-60-g2f50