# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /home/lighta/Documents/Myscript/RO/Servs/ra2/src
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: common/core.c
--- common/core.c Base (BASE)
+++ common/core.c Locally Modified (Based On LOCAL)
@@ -237,8 +237,8 @@
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));
Index: common/grfio.c
--- common/grfio.c Base (BASE)
+++ common/grfio.c Locally Modified (Based On LOCAL)
@@ -403,7 +403,7 @@
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 \n");
fclose(in);
if( size )
@@ -422,16 +422,17 @@
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 \n");
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 @@
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 @@
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 @@
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 \n");
rSize = getlong(eheader); // Read Size
eSize = getlong(eheader+4); // Extend Size
@@ -578,7 +579,7 @@
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);
Index: map/script.c
--- map/script.c Base (BASE)
+++ map/script.c Locally Modified (Based On LOCAL)
@@ -6125,9 +6125,8 @@
return 0;
}
nbargs = script_lastdata(st)+1;
- ShowInfo("nb args = %d\n",nbargs);
if(nbargs%2){
- ShowError("buildin_checkweight: Invalid nb of args should be a multiple of 2.\n"); // returns string, regardless of what it was
+ ShowError("buildin_checkweight: Invalid nb of args should be a multiple of 2.\n");
script_pushint(st,0);
return 1;
}
@@ -6216,7 +6215,7 @@
if( !data_isreference(data_it) || !data_isreference(data_nb))
{
- ShowError("script:checkweight3: parameter not a variable\n");
+ ShowError("script:checkweight2: parameter not a variable\n");
script_pushint(st,0);
return 1;// not a variable
}
@@ -6229,12 +6228,12 @@
if( not_array_variable(*name_it) || not_array_variable(*name_nb))
{
- ShowError("script:checkweight3: illegal scope\n");
+ ShowError("script:checkweight2: illegal scope\n");
script_pushint(st,0);
return 1;// not supported
}
if(is_string_variable(name_it) || is_string_variable(name_nb)){
- ShowError("script:checkweight3: illegal type, need int\n");
+ ShowError("script:checkweight2: illegal type, need int\n");
script_pushint(st,0);
return 1;// not supported
}
@@ -6254,12 +6253,12 @@
if(fail) continue; //cpntonie to depop rest
if(itemdb_exists(nameid) == NULL ){
- ShowError("buildin_checkweight3: Invalid item '%d'.\n", nameid);
+ ShowError("buildin_checkweight2: Invalid item '%d'.\n", nameid);
fail=1;
continue;
}
if(amount < 0 ){
- ShowError("buildin_checkweight3: Invalid amount '%d'.\n", amount);
+ ShowError("buildin_checkweight2: Invalid amount '%d'.\n", amount);
fail = 1;
continue;
}
Index: tool/mapcache.c
--- tool/mapcache.c Base (BASE)
+++ tool/mapcache.c Locally Modified (Based On LOCAL)
@@ -176,8 +176,8 @@
encode_zip(write_buf, &len, m->cells, m->xs*m->ys);
// Fill the map header
- if (sizeof(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed.
- ShowWarning ("Map name '%s' size '%d' is too long. Truncating to '%d'.\n", name, sizeof(name), MAP_NAME_LENGTH);
+ if (strlen(name) > MAP_NAME_LENGTH) // It does not hurt to warn that there are maps with name longer than allowed.
+ ShowWarning ("Map name '%s' size '%d' is too long. Truncating to '%d'.\n", name, strlen(name), MAP_NAME_LENGTH);
strncpy(info.name, name, MAP_NAME_LENGTH);
info.xs = MakeShortLE(m->xs);
info.ys = MakeShortLE(m->ys);
@@ -201,12 +201,11 @@
{
int i;
struct map_info info;
- size_t fileReadCount;
fseek(map_cache_fp, sizeof(struct main_header), SEEK_SET);
for(i = 0; i < header.map_count; i++) {
- fileReadCount = fread(&info, sizeof(info), 1, map_cache_fp);
+ if(fread(&info, sizeof(info), 1, map_cache_fp) != 1) printf("An error as occured in fread while reading map_cache\n");
if(strcmp(name, info.name) == 0) // Map found
return 1;
else // Map not found, jump to the beginning of the next map info header
@@ -305,8 +304,7 @@
header.file_size = sizeof(struct main_header);
header.map_count = 0;
} else {
- size_t fileReadCount;
- fileReadCount = fread(&header, sizeof(struct main_header), 1, map_cache_fp);
+ if(fread(&header, sizeof(struct main_header), 1, map_cache_fp) != 1){ printf("An error as occured while reading map_cache_fp \n"); }
header.file_size = GetULong((unsigned char *)&(header.file_size));
header.map_count = GetUShort((unsigned char *)&(header.map_count));
}