Jelajahi Sumber

-Fix geoipreading cache for Windows, bugreport:6923

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@16960 54d463be-8e91-2dee-dedb-b68131a5f0ec
glighta 12 tahun lalu
induk
melakukan
7711b41dc0
2 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 2 2
      src/char/inter.c
  2. 2 2
      src/common/grfio.c

+ 2 - 2
src/char/inter.c

@@ -378,10 +378,10 @@ const char * geoip_countryname[253] = {"Unknown","Asia/Pacific Region","Europe",
 unsigned char *geoip_cache;
 void geoip_readdb(void){
 	struct stat bufa;
-	FILE *db=fopen("./db/GeoIP.dat","r");
+	FILE *db=fopen("./db/GeoIP.dat","rb");
 	fstat(fileno(db), &bufa);
 	geoip_cache = (unsigned char *) malloc(sizeof(unsigned char) * bufa.st_size);
-	if(fread(geoip_cache, sizeof(unsigned char), bufa.st_size, db) != bufa.st_size) { ShowError("geoip_cache reading didn't read all elements"); }
+	if(fread(geoip_cache, sizeof(unsigned char), bufa.st_size, db) != bufa.st_size) { ShowError("geoip_cache reading didn't read all elements \n"); }
 	fclose(db);
 	ShowStatus("Finished Reading "CL_GREEN"GeoIP"CL_RESET" Database.\n");
 }

+ 2 - 2
src/common/grfio.c

@@ -403,7 +403,7 @@ void* grfio_reads(const char* fname, int* size)
 			declen = ftell(in);
 			fseek(in,0,SEEK_SET);
 			buf2 = (unsigned char *)aMalloc(declen+1);  // +1 for resnametable zero-termination
-			if(fread(buf2, 1, declen, in) != declen) printf("An error occured in fread grfio_reads, fname=%s \n",fname);
+			if(fread(buf2, 1, declen, in) != declen) ShowError("An error occured in fread grfio_reads, fname=%s \n",fname);
 			fclose(in);
 
 			if( size )
@@ -425,7 +425,7 @@ void* grfio_reads(const char* fname, int* size)
 			int fsize = entry->srclen_aligned;
 			unsigned char *buf = (unsigned char *)aMalloc(fsize);
 			fseek(in, entry->srcpos, 0);
-			if(fread(buf, 1, fsize, in) != fsize) printf("An error occured in fread in grfio_reads, grfname=%s\n",grfname);
+			if(fread(buf, 1, fsize, in) != fsize) ShowError("An error occured in fread in grfio_reads, grfname=%s\n",grfname);
 			fclose(in);
 
 			buf2 = (unsigned char *)aMalloc(entry->declen+1);  // +1 for resnametable zero-termination