summaryrefslogtreecommitdiff
path: root/src/common/grfio.c
diff options
context:
space:
mode:
authorglighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-23 05:53:29 +0000
committerglighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec>2012-11-23 05:53:29 +0000
commit5c776e41bf6c13498e9575ee88aa2b2d47185f9e (patch)
treec5fd29d4eb4e6df15b393cd68c1e8b16350b5101 /src/common/grfio.c
parent15762b30698842255bc545dee68705fad3447a4b (diff)
downloadhercules-5c776e41bf6c13498e9575ee88aa2b2d47185f9e.tar.gz
hercules-5c776e41bf6c13498e9575ee88aa2b2d47185f9e.tar.bz2
hercules-5c776e41bf6c13498e9575ee88aa2b2d47185f9e.tar.xz
hercules-5c776e41bf6c13498e9575ee88aa2b2d47185f9e.zip
-Apply mkdu95 fix for bugreport:5145 preventing clone if player dead, (for slave and evil clone)
-Fix old fread, fgets warnings, displaying a msg errors when failed now -Cleaning checkweight debug showinfo git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16952 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common/grfio.c')
-rw-r--r--src/common/grfio.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/common/grfio.c b/src/common/grfio.c
index 2305b6fcd..882b3ba36 100644
--- a/src/common/grfio.c
+++ b/src/common/grfio.c
@@ -81,7 +81,7 @@ static void NibbleSwap(unsigned char* src, int len)
static uint8_t grf_substitution(uint8_t in)
{
uint8_t out;
-
+
switch( in )
{
case 0x00: out = 0x2B; break;
@@ -348,7 +348,7 @@ static void filelist_compact(void)
{
if (filelist == NULL)
return;
-
+
if (filelist_entrys < filelist_maxentry) {
filelist = (FILELIST *)aRealloc(filelist, filelist_entrys * sizeof(FILELIST));
filelist_maxentry = filelist_entrys;
@@ -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
- (void)fread(buf2, 1, declen, in);
+ if(fread(buf2, 1, declen, in) != declen) printf("An error occured in fread grfio_reads, fname=%s \n",fname);
fclose(in);
if( size )
@@ -422,16 +422,17 @@ void* grfio_reads(const char* fname, int* size)
char* grfname = gentry_table[entry->gentry - 1];
FILE* in = fopen(grfname, "rb");
if( in != NULL ) {
- unsigned char *buf = (unsigned char *)aMalloc(entry->srclen_aligned);
+ int fsize = entry->srclen_aligned;
+ unsigned char *buf = (unsigned char *)aMalloc(fsize);
fseek(in, entry->srcpos, 0);
- (void)fread(buf, 1, entry->srclen_aligned, in);
+ if(fread(buf, 1, fsize, in) != fsize) printf("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
if( entry->type & FILELIST_TYPE_FILE )
{// file
uLongf len;
- grf_decode(buf, entry->srclen_aligned, entry->type, entry->srclen);
+ grf_decode(buf, fsize, entry->type, entry->srclen);
len = entry->declen;
decode_zip(buf2, &len, buf, entry->srclen);
if (len != (uLong)entry->declen) {
@@ -507,7 +508,7 @@ static int grfio_entryread(const char* grfname, int gentry)
grf_size = ftell(fp);
fseek(fp,0,SEEK_SET);
- (void)fread(grf_header,1,0x2e,fp);
+ if(fread(grf_header,1,0x2e,fp) != 0x2e) { ShowError("Couldn't read all grf_header element of %s \n", grfname); }
if( strcmp((const char*)grf_header,"Master of Magic") != 0 || fseek(fp,getlong(grf_header+0x1e),SEEK_CUR) != 0 ) {
fclose(fp);
ShowError("GRF %s read error\n", grfname);
@@ -519,7 +520,7 @@ static int grfio_entryread(const char* grfname, int gentry)
if( grf_version == 0x01 ) {// ****** Grf version 01xx ******
list_size = grf_size - ftell(fp);
grf_filelist = (unsigned char *) aMalloc(list_size);
- (void)fread(grf_filelist,1,list_size,fp);
+ if(fread(grf_filelist,1,list_size,fp) != list_size) { ShowError("Couldn't read all grf_filelist element of %s \n", grfname); }
fclose(fp);
entrys = getlong(grf_header+0x26) - getlong(grf_header+0x22) - 7;
@@ -566,7 +567,7 @@ static int grfio_entryread(const char* grfname, int gentry)
unsigned char *rBuf;
uLongf rSize, eSize;
- (void)fread(eheader,1,8,fp);
+ if(fread(eheader,1,8,fp) != 8) ShowError("An error occured in fread while reading eheader buffer\n");
rSize = getlong(eheader); // Read Size
eSize = getlong(eheader+4); // Extend Size
@@ -578,7 +579,7 @@ static int grfio_entryread(const char* grfname, int gentry)
rBuf = (unsigned char *)aMalloc(rSize); // Get a Read Size
grf_filelist = (unsigned char *)aMalloc(eSize); // Get a Extend Size
- (void)fread(rBuf,1,rSize,fp);
+ if(fread(rBuf,1,rSize,fp) != rSize) ShowError("An error occured in fread \n");
fclose(fp);
decode_zip(grf_filelist, &eSize, rBuf, rSize); // Decode function
aFree(rBuf);
@@ -699,7 +700,7 @@ static void grfio_resourcecheck(void)
ShowStatus("Done reading '"CL_WHITE"%d"CL_RESET"' entries in '"CL_WHITE"%s"CL_RESET"'.\n", i, "resnametable.txt");
return; // we're done here!
}
-
+
// read resnametable from loaded GRF's, only if it cannot be loaded from the data directory
buf = (char *)grfio_reads("data\\resnametable.txt", &size);
if( buf != NULL )