diff options
author | glighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-23 05:53:29 +0000 |
---|---|---|
committer | glighta <glighta@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-11-23 05:53:29 +0000 |
commit | 5c776e41bf6c13498e9575ee88aa2b2d47185f9e (patch) | |
tree | c5fd29d4eb4e6df15b393cd68c1e8b16350b5101 /src/common | |
parent | 15762b30698842255bc545dee68705fad3447a4b (diff) | |
download | hercules-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')
-rw-r--r-- | src/common/core.c | 8 | ||||
-rw-r--r-- | src/common/grfio.c | 23 |
2 files changed, 16 insertions, 15 deletions
diff --git a/src/common/core.c b/src/common/core.c index dbd1c9d3d..e1f99885b 100644 --- a/src/common/core.c +++ b/src/common/core.c @@ -237,8 +237,8 @@ const char* get_svn_revision(void) else { // Bin File format - fgets(line, sizeof(line), fp); // Get the name - fgets(line, sizeof(line), fp); // Get the entries kind + if ( fgets(line, sizeof(line), fp) == NULL ) { printf("Can't get bin name\n"); } // Get the name + if ( fgets(line, sizeof(line), fp) == NULL ) { printf("Can't get entries kind\n"); } // Get the entries kind if(fgets(line, sizeof(line), fp)) // Get the rev numver { snprintf(svn_version_buffer, sizeof(svn_version_buffer), "%d", atoi(line)); @@ -263,7 +263,7 @@ const char* get_svn_revision(void) *--------------------------------------*/ static void display_title(void) { //ClearScreen(); // clear screen and go up/left (0, 0 position in text) - + ShowMessage("\n"); ShowMessage(""CL_PASS" "CL_BOLD" "CL_PASS""CL_CLL""CL_NORMAL"\n"); ShowMessage(""CL_PASS" "CL_BT_WHITE" rAthena Development Team presents "CL_PASS""CL_CLL""CL_NORMAL"\n"); @@ -345,7 +345,7 @@ int main (int argc, char **argv) timer_final(); socket_final(); db_final(); - mempool_final(); + mempool_final(); rathread_final(); #endif 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 ) |