فهرست منبع

* Fixed local files could not be aliased with resnametable.txt in grfio (bugreport:2203, since r5152).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14648 54d463be-8e91-2dee-dedb-b68131a5f0ec
ai4rei 14 سال پیش
والد
کامیت
7eae5b9381
2فایلهای تغییر یافته به همراه33 افزوده شده و 4 حذف شده
  1. 1 0
      Changelog-Trunk.txt
  2. 32 4
      src/common/grfio.c

+ 1 - 0
Changelog-Trunk.txt

@@ -1,6 +1,7 @@
 Date	Added
 
 2011/01/01
+	* Fixed local files could not be aliased with resnametable.txt in grfio (bugreport:2203, since r5152). [Ai4rei]
 	* Cleanups to grfio. [Ai4rei]
 	- Replaced strncpy with safestrncpy (bugreport:3080).
 	- Ensured, that all local paths are normalized and work whether or not the data dir ends with '/'.

+ 32 - 4
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;